VB - Forms Resizing
When I Load Form2 from Form1, Form1 resizes & hence form2 goes in the background.
Form2 will be displayed untill form1 has finished processing.
How should I go about this?
Web Development
When I Load Form2 from Form1, Form1 resizes & hence form2 goes in the background.
Form2 will be displayed untill form1 has finished processing.
How should I go about this?
I can see what you are trying to do. You want to display a "loading...." message or something like that right? If that is the case, there are 2 ways of accomplishing it. The easy way (which I have come to prefer due to its simplicity), if you can afford displaying only text rather than progress bar and all that, is not to use 2 forms, but only 1 form with a button control placed right in the middle. Let me explain. you put a button in the middle of the form, Make it invisible. change the caption of the button to "Loading...." or whatever you prefer. then when you start any process, simply make the button visible until the process is done, then hide the button. As simple as that. Now if you still want to do it with 2 forms to add progress bar and bells and whistles, then its more complicted. What you would do is show form2 non-modal, Make it "always on top" with an API call, deactivate all the controls in the main form, finish the process, activate all controls again, set the window to"normal" again, and hide form2.
This is the API call code, put this first part on the declarations:
Const HWND_TOPMOST = -1
Const HWND_NOTOPMOST = -2
Const SWP_NOSIZE = &H1
Const SWP_NOMOVE = &H2
Const SWP_NOACTIVATE = &H10
Const SWP_SHOWWINDOW = &H40
Private Declare Sub SetWindowPos Lib "User32" (ByVal hWnd As Long, ByVal hWndInsertAfter As Long, ByVal X As Long, ByVal Y As Long, ByVal cx As Long, ByVal cy As Long, ByVal wFlags As Long)
This is the call to the function that willmake the form TOPMOST, put this line wherever you want to make the window TOPMOST:
SetWindowPos Me.hWnd, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOACTIVATE Or SWP_SHOWWINDOW Or SWP_NOMOVE Or SWP_NOSIZE
If you have any problems, feel free to drop a line at: webmaster@KingsDistributors.com
Good Luck!
by ideafixer
You can set the focus in the on load event of the form you want. Forms!frm_tafcriteria.SetFocus
frm_tafcriteria is the name of my form.
.Setfocus gets the focus on that form.
If you have that in you load event, it will set the focus to the form you want.
You can also use
DoCmd.Restore ' Runs in normal window
DoCmd.Maximize
DoCmd.Minimize
In the "on close" and "on open" events of forms to control if you want them to run in a normal window as opposed to maximized.
Good Luck!
by ideafixer
by sl-campbell
Form2.WindowState = vbMaximized
Form2.ZOrder = 0
Or
Form1.Hide
Form2.SetFocus
This discussion is closed to new replies.
Sort by Trending