Subj : Dialog boxes To : borland.public.cpp.borlandcpp From : "Rob C." Date : Thu Oct 16 2003 03:23 pm Application win32 I’m having considerable difficulty figuring out dialog boxes. If I could study the code somebody else wrote, I might be able to get over this hurdle. Below is a short program I found in the help files. But, alas, even this returns errors. The error message is listed below (and the message I get by pressing F1), as is the *.rc file I constructed. -------------------------------------- /*/ To use a dialog box as your main window, it is best to make the main window a frame window that has your dialog box as a client window. To do this, derive an application class from TApplication. Aside from a constructor, the only function necessary for this purpose is InitMainWindow. In the InitMainWindow function, construct a frame window object, specifying a dialog box as the client window. In the five-parameter TFrameWindow constructor, pass a pointer to the client window as the third parameter. Your code should look something like this: /*/ #include #include #include class TMyApp : public TApplication { public: TMyApp(char *title) : TApplication(title) {} void InitMainWindow(); }; void TMyApp::InitMainWindow() { //.........[ [ [ "IDD_Dialog1" below is what I put in ] ] ] SetMainWindow(new TFrameWindow(0, "My App", new TDialog(0, "IDD_Dialog1" ), true)); } int OwlMain(int argc, char* argv[]) { return TMyApp("My App").Run(); } /*/ The TFrameWindow constructor turns autocreation on for the dialog box object that you pass as a client, regardless of the state you pass it in. You also must make sure the dialog box resource has certain attributes: Destroying your dialog object does not destroy the frame. You must destroy the frame explicitly. You can no longer dynamically add resources directly to the dialog, because it is not the main window. You must add the resources to the frame window. For example, suppose you added an icon to your dialog using the SetIcon function. You now must use the SetIcon function for your frame window. You cannot specify the caption for your dialog in the resource itself anymore. Instead, you must set the caption through the frame window. You must set the style of the dialog box as follows: Visible (WS_VISIBLE) Child window (WS_CHILD) No Minimize and Maximize buttons, drag bars, system menus, or any of the other standard frame window attributes /*/ -------------------------------------- Info :Making... Info :Making... Info :Resource compiling C:\bc5\robcpp\dialog2.rc Error: dialog2.rc(10,30):Expecting signed short integer F1 results - “Resource Workshop's incremental compiler expects to see a signed short (16-bit) integer or integer expression in this field. This error is usually caused by an undefined identifier. “ -------------------------------------- IDD_DIALOG1 DIALOG 0, 0, 240, 120 EXSTYLE WS_EX_DLGMODALFRAME | WS_EX_CONTEXTHELP STYLE DS_MODALFRAME | DS_3DLOOK | DS_CONTEXTHELP | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU CAPTION "" FONT 8, "MS Sans Serif" { CONTROL "OK", IDOK, "BUTTON", BS_PUSHBUTTON | BS_CENTER | WS_CHILD | WS_VISIBLE | WS_TABSTOP, 186, 6, 50, 14 CONTROL "Cancel", IDCANCEL, "BUTTON", BS_PUSHBUTTON | BS_CENTER | WS_CHILD | WS_VISIBLE | WS_TABSTOP, 186, 26, 50, 14 CONTROL "Help", IDHELP, "BUTTON", BS_PUSHBUTTON | BS_CENTER | WS_CHILD | WS_VISIBLE | WS_TABSTOP, 186, 46, 50, 14 //................ [ [ [ hangs-up ON LINE BELOW, after 1st field and right before IDC_ ] ] ] CONTROL "winnings royalty", IDC_GROUPBOX1, "button", BS_GROUPBOX | WS_CHILD | WS_VISIBLE | WS_GROUP, 4, 8, 172, 96 CONTROL "ScrollBar1", IDC_SCROLLBAR1, "scrollbar", SBS_VERT | WS_CHILD | WS_VISIBLE, 160, 12, 9, 80 CONTROL "Frame1", IDC_STATICFRAME1, "static", SS_ETCHEDFRAME | WS_CHILD | WS_VISIBLE, 30, 43, 114, 33 } IDD_DIALOG1 DIALOG 0, 0, 240, 120 EXSTYLE WS_EX_DLGMODALFRAME | WS_EX_CONTEXTHELP STYLE DS_MODALFRAME | DS_3DLOOK | DS_CONTEXTHELP | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU CAPTION "" FONT 8, "MS Sans Serif" { CONTROL "OK", IDOK, "BUTTON", BS_PUSHBUTTON | BS_CENTER | WS_CHILD | WS_VISIBLE | WS_TABSTOP, 186, 6, 50, 14 CONTROL "Cancel", IDCANCEL, "BUTTON", BS_PUSHBUTTON | BS_CENTER | WS_CHILD | WS_VISIBLE | WS_TABSTOP, 186, 26, 50, 14 CONTROL "Help", IDHELP, "BUTTON", BS_PUSHBUTTON | BS_CENTER | WS_CHILD | WS_VISIBLE | WS_TABSTOP, 186, 46, 50, 14 CONTROL "winn", IDC_GROUPBOX1, "button", BS_GROUPBOX | WS_CHILD | WS_VISIBLE | WS_GROUP, 4, 8, 172, 96 CONTROL "ScrollBar1", IDC_SCROLLBAR1, "scrollbar", SBS_VERT | WS_CHILD | WS_VISIBLE, 160, 12, 9, 80 CONTROL "Frame1", IDC_STATICFRAME1, "static", SS_ETCHEDFRAME | WS_CHILD | WS_VISIBLE, 30, 43, 114, 33 } .