Click to See Complete Forum and Search --> : Why do modal dialogs that are opened through a menu item’s click event process all wi
BigEd781
September 25th, 2008, 08:24 PM
So for the past day or so I have been fixing a bug that is caused by a modal dialog. I work on an application which communicates with the server through the Windows message pump. When I use ShowDialog() to show a modal form, the message pump is blocked and none of my messages are processed, yet they do build up in the queue (expected behavior).
However, I recently noticed that if a modal form is opened through a menu item's click event, the messages are pumped to the main form and processed. Does anyone know why these messages are not blocked when a modal form is shown through a menu item's click event?
MMH
September 26th, 2008, 02:25 AM
Try opening the modal dialog like this:
form.ShowDialog(this);
BigEd781
September 26th, 2008, 02:49 AM
So, I suppose I should have mentioned that I am already doing that. Thank you for your reply though, this is the first one I have got over three different forums.
boudino
September 26th, 2008, 03:58 AM
Why do you use message loop to communicate with the server? It seems to me as not a good idea. Could the communication run in its own thread without a message loop? Than no blocking should occure. If you are using poll model, I think that common Timer should work fine.
BigEd781
September 26th, 2008, 12:06 PM
Well, that is true. It would be better to use a receive thread and a send thread to do this, but that is not the application that I have inherited and there isnot enough time in this release to change this. We do plan on changing this behavior soon, but in the meantime I really just need to figure this one out. I have a workaround that I do not like and I really just want to understand what is special about the click event of a menu item.
cjard
September 26th, 2008, 12:31 PM
the thread that creates aparticular control owns the message pump for it. is there any chance that your dialog or the menu is using a thread other than the main window thread, for creation of the dialog?
BigEd781
September 26th, 2008, 03:44 PM
So, I think that the problem is in my application (sorry). I found some code deep down in the guts of the app that was preventing messages from being processed, even though they were being queued. Thanks everyone who tried to help here, I presented a problem that does not really make sense. Sorry for wasting your time, and thanks again.
codeguru.com
Copyright Internet.com Inc., All Rights Reserved.