-
September 19th, 2019, 01:46 AM
#31
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.
-
September 19th, 2019, 07:18 AM
#32
Re: How to disable/grayed-out the 'X' close button in dialog?
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);
-
September 19th, 2019, 07:42 AM
#33
Re: How to disable/grayed-out the 'X' close button in dialog?
All advice is offered in good faith only. All my code is tested (unless stated explicitly otherwise) with the latest version of Microsoft Visual Studio (using the supported features of the latest standard) and is offered as examples only - not as production quality. I cannot offer advice regarding any other c/c++ compiler/IDE or incompatibilities with VS. You are ultimately responsible for the effects of your programs and the integrity of the machines they run on. Anything I post, code snippets, advice, etc is licensed as Public Domain https://creativecommons.org/publicdomain/zero/1.0/ and can be used without reference or acknowledgement. Also note that I only provide advice and guidance via the forums - and not via private messages!
C++23 Compiler: Microsoft VS2022 (17.6.5)
-
September 25th, 2019, 03:05 AM
#34
Re: How to disable/grayed-out the 'X' close button in dialog?
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 -
-
September 25th, 2019, 03:23 AM
#35
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.
All advice is offered in good faith only. All my code is tested (unless stated explicitly otherwise) with the latest version of Microsoft Visual Studio (using the supported features of the latest standard) and is offered as examples only - not as production quality. I cannot offer advice regarding any other c/c++ compiler/IDE or incompatibilities with VS. You are ultimately responsible for the effects of your programs and the integrity of the machines they run on. Anything I post, code snippets, advice, etc is licensed as Public Domain https://creativecommons.org/publicdomain/zero/1.0/ and can be used without reference or acknowledgement. Also note that I only provide advice and guidance via the forums - and not via private messages!
C++23 Compiler: Microsoft VS2022 (17.6.5)
-
September 26th, 2019, 02:31 AM
#36
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.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|