Re: How to disable/grayed-out the 'X' close button in dialog?
Thanks for the response VictorN and Salem_C.
In case of any further comments from the users and I may need to use at a worker thread at any cost will try to study in deep and see to resolve that issue.
Re: How to disable/grayed-out the 'X' close button in dialog?
Quote:
Originally Posted by
vcdebugger
To avoid that I moved my Progresscontrol and Edit box updates from worker thread to my OnTimer() function of the main dialog box but still it was crashing to some other places where CString's were handled( by the other applications called using SHellExecute from the worker thread - for which I dont have control over).
Now I have removed the worker thread itself from my code and doing everything in the main thread of CDialog itself. But the dialog window freezes now when the processing is happening and when the user click on Onclose ( X) button it will respond later but not crashing!
You need a message pump. Here's a simple one. Add this in your processing code.
Code:
MSG msg;
while(PeekMessage(&msg, GetSafeHwnd(), 0, 0, PM_REMOVE))
DispatchMessage(&msg);
Re: How to disable/grayed-out the 'X' close button in dialog?
Re: How to disable/grayed-out the 'X' close button in dialog?
Quote:
Originally Posted by
GCDEF
You need a message pump. Here's a simple one. Add this in your processing code.
Code:
MSG msg;
while(PeekMessage(&msg, GetSafeHwnd(), 0, 0, PM_REMOVE))
DispatchMessage(&msg);
where should I put.. In OnCLose() function this is going to infinite loop with msg structure showing 0x00000 value -
Re: How to disable/grayed-out the 'X' close button in dialog?
As GCDEF said in post #32, in your processing code - often as part of a loop that takes time, or between different parts of the processing code. The message pump is there to ensure that windows messages are processed and hence that the UI remains 'responsive' during long periods of processing.
Re: How to disable/grayed-out the 'X' close button in dialog?
Learn how to do proper multithreaded programming. The work goes into a secondary thread and it updates the main ui thread using postmessage. The story has been the same for the past 25 years.