|
-
June 3rd, 2010, 05:58 AM
#1
Changing MFC GDI in thread
Hello,
I have an MCF application in which I have started several CWinThreads that interact with the main window.
Now I'm trying to change the system menu in the window in one of the threads, but my attempts at this have so long failed. Is this not possible?
At first I tried this, which gave me an exception in runtime
Code:
AfxGetMainWnd()->GetSystemMenu(FALSE)->EnableMenuItem( SC_CLOSE, MF_BYCOMMAND | MF_ENABLED );
After some googling, I realized that this has to be thread safe and so I have tried different variants of this.
The below now runs in the code, but it doesn't enable the close button as desired. (The close button has been disabled by the main window before starting the WinThreads.
Code:
HMENU hMenu =AfxGetMainWnd()->GetSystemMenu(FALSE)->GetSafeHmenu();
EnableMenuItem(hMenu, SC_CLOSE, MF_BYCOMMAND | MF_ENABLED );
Any hints on how one can do this?
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
|