Hi!
I made an MFC application, and now i want to turn off the window's close button during i do my copy operations. I did it successfull with this code:
BOOL bEnable = FALSE; // To disable
UINT menuf = bEnable ? (MF_BYCOMMAND) : (MF_BYCOMMAND | MF_GRAYED | MF_DISABLED);
CMenu* pSM = GetSystemMenu( , FALSE );
if ( pSM )
{
pSM->EnableMenuItem( SC_CLOSE, menuf );
}
But now, at the end of my program in my thread ( UINT CopyThread( LPVOID pParam ) ) i want to reenable it, but i can't. I passed earlier to my thread the m_hWnd, and now i wan't to pass this to the GetSystemMenu function but i get a compiler error : error C2440: 'initializing' : cannot convert from 'HMENU' to 'CMenu *'. I'm sure that this is an easy question, but i'm a beginner, so please help, but i can't figure it out, what i'm doing worng!
Thanks in advance!
kampi
Update: I tried this way, which almost works. The Close "X" will be black again, but if i press it, my program doesn't exists. Am i doing something wrong, or this is because something else?
BOOL bEnable = TRUE; // To enable
UINT menuf = bEnable ? (MF_BYCOMMAND) : (MF_BYCOMMAND | MF_GRAYED | MF_DISABLED);
HMENU pSM = ::GetSystemMenu( Test->hWnd, FALSE );
if ( pSM )
{
::EnableMenuItem(pSM, SC_CLOSE, menuf );
}