tlchavet
asked on
Msgbox Causes VB App to Lose Focus
I have a VB6 app that uses msgboxes to provide information to the user like "Process Complete". For some users, these msgboxes cause the VB app to lose focus and they have to alt-tab back. Is there a way to stop this from happening?
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
To be sure I am understanding both responses, whether I use the standard msgbox or the function MessageBox, to ensure the focus stays in my app I should use the form1.setfocus?
Setting focus just brings focus back to the application. Actually the msgbox itself should be doing that, yet
even doing a better job at it. Clicking the okay button on the msgbox should force your application back
in front of other windows too, which the setting focus will NOT.
The point of using MessageBox is just to allow your application to continue running. Instead of freezing
like the normal command button does.
even doing a better job at it. Clicking the okay button on the msgbox should force your application back
in front of other windows too, which the setting focus will NOT.
The point of using MessageBox is just to allow your application to continue running. Instead of freezing
like the normal command button does.
The reason I do set focus with MessageBox is because I am giving it a false Hwnd, so it is not attached to my program.
That means that when you click okay it will not return to the program. Setting focus will force it to do that. I do not
know that setfocus will help in the case of "msgbox" but you can try it and see. Truthfully, I do not understand why the
msgbox you have currently is not returning focus to the application upon pressing okay.
That means that when you click okay it will not return to the program. Setting focus will force it to do that. I do not
know that setfocus will help in the case of "msgbox" but you can try it and see. Truthfully, I do not understand why the
msgbox you have currently is not returning focus to the application upon pressing okay.
ASKER