home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.c++
- Path: sparky!uunet!think.com!sdd.hp.com!zaphod.mps.ohio-state.edu!cis.ohio-state.edu!news.sei.cmu.edu!weinstoc
- From: weinstoc@sei.cmu.edu (Chuck Weinstock)
- Subject: Help with OWL Dialogs
- Message-ID: <1992Nov16.145858.26887@sei.cmu.edu>
- Sender: netnews@sei.cmu.edu (Netnews)
- Organization: The Software Engineering Institute
- Date: Mon, 16 Nov 1992 14:58:58 GMT
- Lines: 123
-
-
- I was wondering if anyone could help me with a problem I'm having using OWL
- dialogs. The code below is supposed to implement a simple dialog box with one
- edit text item in it. The dialog itself is defined in a .rc file.
-
- When executed the dialog box comes up on the screen just fine, but when I
- click on "OK", it exits and an error dialog pops up indiciating an error code
- of -1 was sent and asking if it should continue or not. Can anyone suggest
- why this is happening and how to avoid it?
-
- Chuck Weinstock
-
- #include <edit.h>
- #include <owl.h>
-
- #define D_ONE_ITEM 3101
- #define FM_EXIT 2101
- #define DM_ONE 2102
-
- struct {
- char DataOne[6];
- } DialogOneData;
-
- class TDialogOne : public TDialog {
-
- TEdit* Data;
-
- public:
-
- TDialogOne(PTWindowsObject);
- };
-
- TDialogOne::TDialogOne(PTWindowsObject AParent) :
- TDialog(AParent,"DIALOG_1")
- {
- Data = new TEdit(this,DM_ONE,6);
- TransferBuffer = (LPSTR) &DialogOneData;
- };
-
- class TTestOwl : public TWindow {
-
- public:
-
- TTestOwl(PTWindowsObject AParent,LPSTR Title) :
- TWindow(AParent,Title) {}
- LPSTR GetClassName() {return "TestOwl";}
- void GetWindowClass(WNDCLASS&);
- virtual void HandleDialogOne(RTMessage) = [CM_FIRST + DM_ONE];
- virtual void Exit(RTMessage) = [CM_FIRST + FM_EXIT] {
- CloseWindow();
- }
- };
-
- void TTestOwl::GetWindowClass(WNDCLASS& wndClass)
- {
- TWindow::GetWindowClass(wndClass);
-
- // attach a menu to the main window
- wndClass.lpszMenuName = "TestMenu";
- }
-
- void TTestOwl::HandleDialogOne(RTMessage)
- {
- int Result;
-
- Result = GetApplication()->ExecDialog(new TDialogOne(this));
- }
-
- class TUserApplication: public TApplication {
-
- public:
-
- TUserApplication(LPSTR AName,
- HINSTANCE AnInstance,
- HINSTANCE APrevInstance,
- LPSTR ACmdLine,
- int ACmdShow)
-
- : TApplication(AName, AnInstance,
- APrevInstance,
- ACmdLine, ACmdShow) {}
- virtual void InitMainWindow();
- };
-
- LPSTR APPLICATION_NAME =
- "Test Owl";
-
- void TUserApplication::InitMainWindow()
- {
- MainWindow = new TTestOwl(NULL,
- APPLICATION_NAME);
- }
-
- int PASCAL WinMain(HINSTANCE AnInstance, HINSTANCE APrevInstance,
- LPSTR ACmdLine, int ACmdShow)
- {
- TUserApplication Application(APPLICATION_NAME,
- AnInstance,
- APrevInstance,
- ACmdLine,
- ACmdShow);
- Application.nCmdShow = SW_SHOWMAXIMIZED;
- Application.Run();
- return Application.Status;
- }
-
- In case it matters, here is the dialog definition from the .rc file:
-
- DIALOG_1 DIALOG 18, 18, 142, 92
- STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
- CLASS "BorDlg"
- CAPTION "DIALOG_1"
- BEGIN
- CONTROL "Button", IDOK, "BorBtn", BS_DEFPUSHBUTTON | WS_CHILD | WS_VISIBLE | WS_TABSTOP, 100, 62, 32, 20
- EDITTEXT D_ONE_ITEM, 48, 24, 53, 12, ES_LEFT | WS_CHILD | WS_VISIBLE | WS_BORDER | WS_TABSTOP
- RTEXT "Data", -1, 13, 26, 30, 8, SS_RIGHT | WS_CHILD | WS_VISIBLE | WS_GROUP
- END
-
-
- Chuck Weinstock weinstock@sei.cmu.edu
- Software Engineering Institute (412) 268-7719
- Carnegie Mellon University (412) 268-5758 (Fax)
- Pittsburgh, PA 15213
-