I'm creating a Windows application using a PropertySheet (Wizard97 type), but I'm unclear how to access the controls from within the dialog callback.
First I setup the property sheet.
psp[1].dwSize = sizeof(PROPSHEETPAGE);
psp[1].dwFlags = PSP_HIDEHEADER ;
psp[1].hInstance = g_hInst;
psp[1].pszTemplate = MAKEINTRESOURCE(IDD_SETUP);
psp[1].pszIcon = NULL;
psp[1].pfnDlgProc = (DLGPROC)ButtonsDlgProc;
psp[1].lParam = 0;
So within the ButtonsDlgProc, I can't access the controls I've added to the dialog.
LRESULT CALLBACK ButtonsDlgProc(HWND hdlg,
UINT uMessage,
WPARAM wParam,
LPARAM lParam)
{
CButton * button;
switch (uMessage)
{
case WM_COMMAND:
switch (wParam)
{
case IDC_CHECK1:
button = (CButton *)GetDlgItem(hdlg, IDC_CHECK1);
button1IsChecked = button->GetCheck();
break;
GetDlgItem returns a handle, but when invoking button->GetCheck(), I get an exception. Is this the proper way to access control members?
The simplest way to achieve it would be