Ergodyne
June 3rd, 2010, 05:58 AM
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
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.
HMENU hMenu =AfxGetMainWnd()->GetSystemMenu(FALSE)->GetSafeHmenu();
EnableMenuItem(hMenu, SC_CLOSE, MF_BYCOMMAND | MF_ENABLED );
Any hints on how one can do this?
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
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.
HMENU hMenu =AfxGetMainWnd()->GetSystemMenu(FALSE)->GetSafeHmenu();
EnableMenuItem(hMenu, SC_CLOSE, MF_BYCOMMAND | MF_ENABLED );
Any hints on how one can do this?