|
-
Apr 8th, 2003, 06:02 PM
#1
Thread Starter
Member
Force a Form to Hide
How would I force a form to hide? After logging off and logging back on, the forms on my VB Service app no longer respond to the .Hide command nor the visible property ... any ideas?
-
Apr 8th, 2003, 09:20 PM
#2
How about using this...
Code:
'SHOWWINDOW COMMANDS
Public Const SW_HIDE = 0
Public Const SW_SHOWNORMAL = 1
Public Const SW_NORMAL = 1
Public Const SW_SHOWMINIMIZED = 2
Public Const SW_SHOWMAXIMIZED = 3
Public Const SW_MAXIMIZE = 3
Public Const SW_SHOWNOACTIVATE = 4
Public Const SW_SHOW = 5
Public Const SW_MINIMIZE = 6
Public Const SW_SHOWMINNOACTIVE = 7
Public Const SW_SHOWNA = 8
Public Const SW_RESTORE = 9
Public Const SW_SHOWDEFAULT = 10
Public Const SW_MAX = 10
Public Declare Function ShowWindow Lib "user32" (ByVal hwnd As Long, ByVal nCmdShow As Long) As Long
Call ShowWindow(App.hwnd, SW_HIDE)
Last edited by RobDog888; Apr 8th, 2003 at 09:23 PM.
-
Apr 9th, 2003, 04:37 PM
#3
Thread Starter
Member
Ok, the problem was that for some reason the Form_QueryUnload doesn't get called when the Form's close button is clicked ...
Can anyone suggest a solution to this? Maybe subclassing the form to recieve the clicked event of the form's close button?
-
Apr 9th, 2003, 05:14 PM
#4
-
Apr 10th, 2003, 01:27 PM
#5
Thread Starter
Member
Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
ShowWindow Me.hwnd, SW_HIDE
End Sub
Real complex stuff...
But the unload method is not the problem, I even tested it by making a message box popup if queryunload is called, but it never does, thus it is never called. And the X button on the form goes acts wierd too, after the log off/log on it doesn't "act" normally ... its hard to explain ... it doesn't depress properly sometimes ...
Maybe there is some way I can use API to re-initialize the form controls? I know you can manipulate them with API ... anything is worth a try.
Last edited by VB_GOD; Apr 10th, 2003 at 01:33 PM.
-
Apr 10th, 2003, 01:35 PM
#6
Originally posted by VB_GOD
Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
ShowWindow Me.hwnd, SW_HIDE
End Sub
lol well that is why...
first of all... your in the queryunload routine..which means hiding the form is pointless.. because it is being unloaded from memory... plus the fact that you are sending a message via api to the window (which is why .show/.hide and .visible doesn't work after you do this).. you don't need to do this... try something like this
VB Code:
Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
if UnloadMode = vbFormControlMenu Then'X button
Cancel = True
Me.Hide
end if
End Sub
this will make it so when the form is closed... if the user closed it with the X button.. it doesn't unload the form from memory.. but just hides it.. and you can get it back using the .show method of the form
-
Apr 10th, 2003, 01:53 PM
#7
Thread Starter
Member
Still doesn't work .....
I think windows messes it up when it logs off ... even if I intercept WM_ENDSESSION = &H16 or WM_QUERYENDSESSION = &H11 messages to the form or not.
-
Apr 10th, 2003, 02:01 PM
#8
Originally posted by VB_GOD
Still doesn't work .....
I think windows messes it up when it logs off ... even if I intercept WM_ENDSESSION = &H16 or WM_QUERYENDSESSION = &H11 messages to the form or not.
well then try
VB Code:
Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
if UnloadMode = vbFormControlMenu or UnloadMode = vbAppWindows Then'X button
Cancel = True
Me.Hide
end if
End Sub
although windows might unload the form anyway... u would have to try it
-
Apr 10th, 2003, 02:22 PM
#9
Thread Starter
Member
I would say that fixes it ... but only because it prevents windows from shutting down in the first place . So this is not of much help .. lol.
-
Apr 10th, 2003, 02:28 PM
#10
Originally posted by VB_GOD
I would say that fixes it ... but only because it prevents windows from shutting down in the first place . So this is not of much help .. lol.
maybe I don't understand what you are looking to do then.. i thought you didn't want it to shutdown.. only hide
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|