Click here to Skip to main content
15,882,833 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:

I have been a CP member for a decade, I think, but this is my first post on this site. :D First off, I want to thank you for this awesome site!

I encountered a rather strange behavior while working on some VB6 code. We have an ActiveX EXE that has no start-up form. It runs in the background, but contains some forms that can be invoked through COM. There are two forms, one is always invoked non-modally and is kinda a main form (Form A). The other form is always invoked modally (Form B). (This is a requirement and cannot be changed)

Now, consider this scenario:
1. Invoke Form A (non-modally)
2. Invoke Form B (modally)
3. Try to invoke another instance of Form A (non- modally)

When running the EXE from code (i.e., through the VB IDE), the Form B is getting displayed successfully. But when running the EXE directly, an error is displayed stating "Can't show non-modal form when modal form is displayed".

AFAIK, this is the normal behavior; Non-modal windows cannot be invoked from a parent window/executable when a modal window is open. But why the difference in behavior when running through code and when running as a binary?

Another interesting behavior is that, while running the code through the IDE and invoking Form A the second time (step 3), the code executes fine until it hits a breakpoint. Then the entire VB IDE freezes! It does not respond to anything until the modal form is closed. I was totally stumped by this.

I am guessing that the cause is the debugger: perhaps it executes the code on a separate thread, so according to Windows, the modal form is on a separate thread and it does not block the other code from executing until the debugger actively hooks into it. I tried reading into debuggers to find out why this happens, but I couldn't get much out of it.

Any ideas?

Note: We have resigned to displaying an alert when the modal form is open and the user tries to open the non-modal form. The alert asks the user to close the non-modal form first. :| But I am still curious as to why this happens.

Christianirwan 26-Jun-13 5:45am    
It seem to IDE bug/behavior. Was you ask them to Microsoft Corporation or MSDN IDE?
Udayakiran Kallavi 1-Jul-13 9:31am    
Thanks for the reply. No, I did not ask in MSDN. I thought it is not a bug. Will try.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900