dcsimg
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Page 3 of 3 FirstFirst 123
Results 31 to 36 of 36

Thread: How to disable/grayed-out the 'X' close button in dialog?

  1. #31
    Join Date
    May 2009
    Location
    Bengaluru, India
    Posts
    435

    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.

  2. #32
    GCDEF is offline Elite Member Power Poster
    Join Date
    Nov 2003
    Location
    Florida
    Posts
    12,554

    Re: How to disable/grayed-out the 'X' close button in dialog?

    Quote Originally Posted by vcdebugger View Post
    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);

  3. #33
    2kaud's Avatar
    2kaud is offline Super Moderator Power Poster
    Join Date
    Dec 2012
    Location
    England
    Posts
    6,900

    Re: How to disable/grayed-out the 'X' close button in dialog?

    This article may be of interest http://www.flounder.com/workerthreads.htm
    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++17 Compiler: Microsoft VS2019 (16.3.9)

  4. #34
    Join Date
    May 2009
    Location
    Bengaluru, India
    Posts
    435

    Re: How to disable/grayed-out the 'X' close button in dialog?

    Quote Originally Posted by GCDEF View Post
    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 -

  5. #35
    2kaud's Avatar
    2kaud is offline Super Moderator Power Poster
    Join Date
    Dec 2012
    Location
    England
    Posts
    6,900

    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++17 Compiler: Microsoft VS2019 (16.3.9)

  6. #36
    Arjay's Avatar
    Arjay is offline Moderator / EX MS MVP Power Poster
    Join Date
    Aug 2004
    Posts
    13,146

    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.

Page 3 of 3 FirstFirst 123

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Windows Mobile Development Center


Click Here to Expand Forum to Full Width




On-Demand Webinars (sponsored)