I have two questions?
Does anyone know how to prevent a form from resizing?
I inserted a file in Excel, does anyone know how to detach it through codes? Or attach a file to a Visual Basic program and detach it.
Thanks
Printable View
I have two questions?
Does anyone know how to prevent a form from resizing?
I inserted a file in Excel, does anyone know how to detach it through codes? Or attach a file to a Visual Basic program and detach it.
Thanks
Any one these questions?
To keep the form from resizing, set the border style to "1 - Fixed Single" at design time.
I tried that already, but if you double click on the title bar it turns it into to normal view.
Thanks for repling!
:) :) :)
If you change the Border property to Fixed Single then by double clicking the title bar, it won't do anything.
Both of you are very true indeed.
However, if you maximize form during the form_load, it will change it to the normal size.
I should have been more clear. How do I make it so that it stay maximize. I don't want to use the Resize event with me.windowstate = vbmaximized.
If you want to control the form resizing at runtime, you can do this...
Create a new project and drop a command button on the form. Paste the following code into the form's code window. When you start the project, you can resize the form, maximize it, or minimize it. After you click the command button, however, you cannot do anything to the size of the form. Click the command button again to regain sizing control of the form.
Code:Option Explicit
Private NoResize As Boolean
Private FormWidth As Integer 'Width of form in non-resize mode
Private FormHeight As Integer 'Height of form in non-resize mode
Private Sub Command1_Click()
'This toggles the ability to resize form off and on
If NoResize Then
NoResize = False
Command1.Caption = "Fix current size"
Else
FormWidth = Me.Width
FormHeight = Me.Height
NoResize = True
Command1.Caption = "Change current size"
End If
End Sub
Private Sub Form_Load()
'Start by allowing user to resize form
NoResize = False
Command1.Caption = "Fix current size"
Command1.Width = 1700
End Sub
Private Sub Form_Resize()
If NoResize Then
With Me
'Don't allow minimizing or maximizing the form
If .WindowState = vbMaximized Or _
.WindowState = vbMinimized Then
.WindowState = vbNormal
End If
'Don't allow manually changing size of form
.Width = FormWidth
.Height = FormHeight
End With
End If
End Sub
Why don't you just make the BorderStyle "0 - None" and then in Form_Load() add Me.WindowState = vbMaximized?
Or, if you really need a title bar and want the form maximized and non-resizeable, do this:
Change the borderstyle to "1 - Fixed Single"
Add this to the Form_Load() event:
That should do it.Code:Private Sub Form_Load()
With Me
.Left = 0
.Top = 0
.Width = Screen.Width
.Height = Screen.Height
End With
End Sub
Thanks for your code!
But your code is the almost the same as:
Private Sub Form_Load()
me.windowstate = vbmaximized
End Sub
Private Sub Form_Resize()
me.windowstate = vbmaximized
End Sub
I want to do so that the user cannot even see the process of the resizing.
___________________________________________________
When a form has no Border, it will work. But I have a menu, so it automatically insert a title bar.
Thank you Seaweed and Serge!
I am going to look for an API because I remember there is an API to do this. It start with SetWindowPos I think.
But thank you again.
So it sounds like you really want to know how to turn off the "double-click on title bar = resize form" feature.
That I do not know.
~seaweed
Yes! something like that. If I do find the API, I will post it, but if I don't, I guess I will use your method on the Form_Load.
Thanks Seaweed
Or you can just take the title bar off and replace
it with the ARGradient Control. It can create new title
bar with gradient effetcs. If you are interested, you can emial me and i can send you the control.
I think there's a simpler way. Set the window state to vbmaximized in design mode, then turn the maxbutton property to false.
in the declarations section
dim myheight as integer
dim mywidth as integer
In the FORM_LOAD
myheight= whatever you want it to be
mywidth = whatever you want it to be
in the FORM_RESIZE
if windowstate is not equal to minised (i think its 1)
me.width=myheight
me.height=myheight
end if