Bypass Windows Message other than Open & Close
-
Hey everybody, I need to show a static Dialog having only a label "Please Wait" before a long process starts. Since both dialog & process are in the main thread, the dialog is frozen. Due to this, till the task is completed, if I click or drag the "Please Wait" Dialog, "End Process" pops in. Thus, I just need to bypass all the WINDOWS MESSAGES other than those needed for dlg.show() & dlg.close(). Please help me. To start with I know how to bypass the messages.
protected override void WndProc(ref Message m)
{
if (m.Msg == WM_CLOSE) // All the messages I need to handle
base.WndProc(ref m);
}I just want to know what all messages I'll have to bypass. Also, is there any thing easier way to do this. Thanx in Advance. :-)
-
Hey everybody, I need to show a static Dialog having only a label "Please Wait" before a long process starts. Since both dialog & process are in the main thread, the dialog is frozen. Due to this, till the task is completed, if I click or drag the "Please Wait" Dialog, "End Process" pops in. Thus, I just need to bypass all the WINDOWS MESSAGES other than those needed for dlg.show() & dlg.close(). Please help me. To start with I know how to bypass the messages.
protected override void WndProc(ref Message m)
{
if (m.Msg == WM_CLOSE) // All the messages I need to handle
base.WndProc(ref m);
}I just want to know what all messages I'll have to bypass. Also, is there any thing easier way to do this. Thanx in Advance. :-)
varunpandeyengg wrote:
Thus, I just need to bypass all the WINDOWS MESSAGES
No you need to redesign your process. Move your long running process off the main thread and do the job properly. Mucking around with message handling b/c you are too lazy to use another thread is just dumb.
Never underestimate the power of human stupidity RAH
-
varunpandeyengg wrote:
Thus, I just need to bypass all the WINDOWS MESSAGES
No you need to redesign your process. Move your long running process off the main thread and do the job properly. Mucking around with message handling b/c you are too lazy to use another thread is just dumb.
Never underestimate the power of human stupidity RAH
Due to some limitation of the process, I need to call some functions of main thread plus BeginInvoke isn't performing well. So, I have no choice other than working with Windows Message.
-
Due to some limitation of the process, I need to call some functions of main thread plus BeginInvoke isn't performing well. So, I have no choice other than working with Windows Message.
There is no other way. Running the long running job on new thread is the way to go. Because both the message handling code and long running code are getting executed on the main thread. Which means either one can execute at a time. Since the long running job is blocking the thread, main thread will be in waiting state and your message processing code won't get executed. Why do you think
BeginInvoke
is not performing well? Do you have benchmarks which showsBeginInvoke
is slow?Best wishes, Navaneeth
-
Hey everybody, I need to show a static Dialog having only a label "Please Wait" before a long process starts. Since both dialog & process are in the main thread, the dialog is frozen. Due to this, till the task is completed, if I click or drag the "Please Wait" Dialog, "End Process" pops in. Thus, I just need to bypass all the WINDOWS MESSAGES other than those needed for dlg.show() & dlg.close(). Please help me. To start with I know how to bypass the messages.
protected override void WndProc(ref Message m)
{
if (m.Msg == WM_CLOSE) // All the messages I need to handle
base.WndProc(ref m);
}I just want to know what all messages I'll have to bypass. Also, is there any thing easier way to do this. Thanx in Advance. :-)
That is a bad idea. As others have said, your long operation needs to move to another thread. There are a couple of ways to do that, the best choice depends on the operations. What is it you are doing? How long does it take, and how often does your code need to access the GUI in that time? BTW1: I don't use
Control.BeginInvoke()
; when I need invoking, I useControl.Invoke()
. BTW2: IMO a long operation needs a way to get cancelled (the user sits there waiting and has the time to change his mind); and a progress bar is also nice to have. These are additional reasons to do things properly, i.e. with an extra thread. :)Luc Pattyn [My Articles] Nil Volentibus Arduum