HWND hwnd = GetDesktopWindow(); // Get desktop window handle EnableWindow(hwnd, true); // Enable the desktop window
CButton *pButton = (CButton *)GetDlgItem(IDC_MYBUTTON); // Get button control pointer pButton->EnableWindow(FALSE); // Disable the button controlThis example shows how to disable a child window (a button control) in an MFC application. The GetDlgItem function is used to obtain a pointer to the button control based on its resource ID, and the EnableWindow function is used to disable it. This code could be part of an MFC dialog or window class that manages a group of controls. The package library for this function is MFC (Microsoft Foundation Classes).