|
-
Oct 2nd, 2006, 09:53 AM
#1
Hyperactive Member
Re: Can't Show Non-Modal Form...
 Originally Posted by clarkgriswald
VB Code:
Private Sub Timer1_Timer()
Dim lProcessID As Long
Dim lID As Long
Timer1.Interval = 0
'get the process ID for prosper
lProcessID = GetWindowThreadProcessId(Me.hWnd, lID)
'close any open message boxes
CloseMessageBox lProcessID
Form2.Show '<----- DANGER, WILL ROBINSON, DANGER
End Sub
My shot in the dark would be the Form2.Show call in the timer loop is directly causing the error. If you call CloseMessageBox and it doesn't successfully close the MsgBox, then then it will try to show Form2 and blow up.
Have you stepped through your code and made sure that it is closing the MsgBox where and when it should be closing?
-
Oct 2nd, 2006, 09:58 AM
#2
Thread Starter
Fanatic Member
Re: Can't Show Non-Modal Form...
Yes, I have tested that the message box is being closed. I can't test it from VB due to the fact that once the message box is displayed timer events will NOT fire, but I have put in a DoEvents loop after the call the CloseMEssageBox and you will see the message box close...then hits the loop, then error pops up. Can't figure this out and it's driving me crazy, I need to handle this case.
-
Oct 2nd, 2006, 11:08 AM
#3
Hyperactive Member
[Edit]
I agree with comment below. You just have the .Show call in the wrong location.
Last edited by Fedhax; Oct 2nd, 2006 at 11:40 AM.
Reason: Completely Misread The Code; Comment Was Wrong
-
Oct 2nd, 2006, 11:31 AM
#4
Member
Re: Can't Show Non-Modal Form...
The MsgBox function is not finished before it has delivered the return value, i.e in the Form_Activate event. That's why. Move Form2.show to Form_Active() after the MsgBox function.
-
Oct 2nd, 2006, 12:16 PM
#5
Thread Starter
Fanatic Member
Re: Can't Show Non-Modal Form...
Ok, we are getting somewhere, but i guess my problem is in the LARGER application, I will have no idea of the source of the message box, I just want to close the window...is there any way I can handle this situation?
-
Oct 2nd, 2006, 12:33 PM
#6
Hyperactive Member
Re: Can't Show Non-Modal Form...
 Originally Posted by clarkgriswald
Ok, we are getting somewhere, but i guess my problem is in the LARGER application, I will have no idea of the source of the message box, I just want to close the window...is there any way I can handle this situation?
Do you have access to edit/modify the larger application?
You are only going to run into problems where you will want to open a form after closing a MsgBox. Under that scenario, you will need to make sure that the routine that calls the MsgBox--in this case, Form_Activate--ends completely or your .Show call follows the MsgBox call.
If you cannot know this information or edit the MsgBox calls, then you are might be up a creek. You could also look into this thread which runs into a similar problem with one of Outlook's modal windows. In his case, he wrote a 2nd program--an ActiveX EXE--to handle the modal form closing that you are trying to place in your program's timer. All it does is run an independent timer--since Outlook is a separate program from his program--to look for the window, simulate's end user input, and closes the window accordingly.
-
Oct 2nd, 2006, 01:16 PM
#7
Thread Starter
Fanatic Member
Re: Can't Show Non-Modal Form...
I actually do have access to the larger application, the one issue is that there are over 700 message box calls spread out over 10 separate referenced objects. This is an annoying issue to say the least, I may have to figure out a different approach altogether.
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
|