



Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!




In this lecture, we will discuss more about the dialog boxes and their commands implementations.
case WM_CTLCOLORSTATIC: switch(GetDlgCtrlID((HWND)lParam)) { case IDC_STATIC_TEXT_COLOR: if(hBrush) // if some brush was created before DeleteObject(hBrush); hBrush = CreateSolidBrush(textColour); // create a brush return (BOOL)hBrush; break;
case IDC_STATIC_BRUSH_COLOR: if(hBrush) // if some brush was created before DeleteObject(hBrush); hBrush = CreateSolidBrush(brushColour); // create a brush return (BOOL)hBrush; break;
default: return FALSE;// perform default message handling
ChooseColor(&chooseclr);
typedef struct { DWORD lStructSize; HWND hwndOwner; HWND hInstance; COLORREF rgbResult; COLORREF * lpCustColors; DWORD Flags; CC_RGBINIT | CC_FULLOPEN | CC_ANYCOLOR LPARAM lCustData; LPCCHOOKPROC lpfnHook; LPCTSTR lpTemplateName; } CHOOSECOLOR, *LPCHOOSECOLOR; return Val???
// REPAINT CONTROL: send WM_CTLCOLORSTATIC druing repainting
GetClientRect(GetDlgItem(hDlg, IDC_STATIC_BRUSH_COLOR), &rect);
InvalidateRect(GetDlgItem(hDlg, IDC_STATIC_BRUSH_COLOR), &rect, TRUE); } Break;
case IDC_BUTTON_DRAW: hDC = GetDC(GetParent(hDlg)); if(IsDlgButtonChecked(hDlg, IDC_RADIO_RECTANGLE) == BST_CHECKED) { hOwnerBrush = CreateHatchBrush(HS_BDIAGONAL, brushColour);
hOldBrush = SelectObject(hDC, hOwnerBrush); Rectangle(hDC, 10, 10, 200, 200);
SelectObject(hDC, hOldBrush); // restore old selection DeleteObject(hOwnerBrush); }
Now create a Modal Dialog box on the about event.
case ID_HELP_ABOUT: DialogBox(hAppInstance, MAKEINTRESOURCE(IDD_DIALOG_ABOUT), hWnd, aboutDialogProc);
LPTSTR strings[5][2] = {{"Application", "Lecture 22"}, {"Author", "M. Shahid Sarfraz"}, {"Institution", "Virtual University"}, {"Year", "2003"}, {"Copyright", "2003 Virtual University"}};
case WM_INITDIALOG: for(i=0; i<5; ++i) { index = SendDlgItemMessage(hDlg,IDC_LIST_ABOUT, LB_ADDSTRING, 0, (LPARAM)strings[i][0]); SendDlgItemMessage(hDlg, IDC_LIST_ABOUT, LB_SE TITEMDATA,index,(LPARAM)strings[i][1]) }
// set current selection to 0 SendDlgItemMessage(hDlg, IDC_LIST_ABOUT, LB_SETCURSEL, 0, 0);
//Check notification messaqges in about dialog box LPTSTR str; case WM_COMMAND: wNotificationCode = HIWORD(wParam); wID = LOWORD(wParam);