CMPT 212
Fall 1997
|
PUSHBUTTON "Add", IDC_ADD_BUTTON, 30, 12, 50, 14
BOOL CALLBACK DialogFunc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) { switch (message) { case WM_COMMAND: switch (LOWORD(wParam)) { case IDC_ADD_BUTTON: ... // use pressed the "Add" button. return 1; ... } ... } return 0; }
LISTBOX IDC_DEPT, 16, 10, 60, 45, LBS_NOTIFY | WS_CHILD | WS_VISIBLE | WS_BORDER | WS_VSCROLL | WS_TABSTOP PUSHBUTTON "Select", IDC_SELECT, 21, 58, 50, 14
#define IDC_DEPT 101 #define IDC_SELECT 102
BOOL CALLBACK DialogFunc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) { switch (message) { case WM_INITDIALOG: SendDlgItemMessage(hwnd, IDC_DEPT, LB_ADDSTRING, 0, (LPARAM) "BISC"); SendDlgItemMessage(hwnd, IDC_DEPT, LB_ADDSTRING, 0, (LPARAM) "CMPT"); SendDlgItemMessage(hwnd, IDC_DEPT, LB_ADDSTRING, 0, (LPARAM) "HIST"); return 1; ... } return 0; }
BOOL CALLBACK DialogFunc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) { long i switch (message) { case WM_COMMAND: switch (LODWORD(wParam)) { case IDC_DEPT: if (HIWORD(wParam) == LBN_DBLCLK) { i = SendDlgItemMessage(hwnd, IDC_DEPT, LB_GETCURSEL, 0, 0L); ... // "i" is the item number. } return 1; case IDC_SELECT: i = SendDlgItemMessage(hwnd, IDC_DEPT, LB_GETCURSEL, 0, 0L); if (i > LB_ERR) { ... // "i" is the item nubmer. } else { ... // no item was selected. } return 1; ... } ... } return 0; }
HWND hDlg; // dialog box handle. int WINAPI WinMain(HINSTANCE hThisInst, HINSTANCE hPrevInst, LPSTR lpszArgs, int nWinMode) { MSG msg; ... while (GetMessage(&msg, NULL, 0)) { if (!IsDialogMessage(hDlg, &msg)) { TranslateMessage(&msg); DispatchMessage(&msg); } } ... }
Return to lecture notes index |
|
This page is maintained by simpson@cs.sfu.ca. | Last updated on 19 Nov 1997. |