Subj : Re: beginning dialog boxes (3) To : borland.public.cpp.borlandcpp From : hedgehog Date : Sun Sep 21 2003 09:35 pm Hi I want that did too that "Push Me" I add... //-- in DEMO.RC -- ACCEL_1 ACCELERATORS { VK_F5, IDC_PUSHBUTTON1, VIRTKEY } //-- in DEMO.RH -- #define ACCEL_1 2 What I should add in DEMO.CPP for enabling an accelerator? PS. Sorry my poor English :-( Ed Mulroy [TeamB] wrote: [snip] > -----File DEMO.CPP------ > #define STRICT > #include > #include "demo.rh" > > BOOL CALLBACK DlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM) > { > static char endmsg[132] = ""; > > switch (msg) > { > case WM_INITDIALOG : > { > SetDlgItemText(hwnd, IDC_EDIT1, > "Write something into this control"); > break; > } > case WM_COMMAND : > { > switch (LOWORD(wParam)) > { > case IDC_PUSHBUTTON1 : > { > MessageBox(hwnd, > "You pressed the middle button", "", MB_OK); > break; > } > case IDOK : > { > lstrcpy(endmsg, "You pressed Ok"); > } // fall through > case IDCANCEL : > { > if (!endmsg[0]) > lstrcpy(endmsg, "You pressed Esc or Cancel"); > > MessageBox(hwnd, endmsg, "", MB_OK); > GetDlgItemText(hwnd, IDC_EDIT1, > endmsg, sizeof(endmsg) - 1); > EndDialog(hwnd, (int) endmsg); > break; > } > } > break; > } > } > > return FALSE; > } > > int WINAPI WinMain(HINSTANCE hInst, HINSTANCE, LPSTR, int) > { > char *s = (char *) > DialogBox(hInst, MAKEINTRESOURCE(DIALOG_1), HWND_DESKTOP, DlgProc); > > MessageBox(HWND_DESKTOP, s, "You typed in this", MB_OK); > return 0; > } > -----File DEMO.RC------- > #include "demo.rh" > DIALOG_1 DIALOG 6, 15, 194, 119 > STYLE DS_MODALFRAME | WS_POPUP | WS_VISIBLE | WS_CAPTION > CAPTION "Dialog Box Caption" > FONT 8, "MS Sans Serif" > { > DEFPUSHBUTTON "OK", IDOK, 27, 94, 50, 14 > PUSHBUTTON "Cancel", IDCANCEL, 110, 94, 50, 14 > PUSHBUTTON "Push Me", IDC_PUSHBUTTON1, 72, 48, 50, 14 > EDITTEXT IDC_EDIT1, 42, 20, 126, 12 > } > -----File DEMO.RH------- > #define DIALOG_1 1 > #define IDC_PUSHBUTTON1 101 > #define IDC_EDIT1 102 > ------------------- > > .. Ed .