home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #27 / NN_1992_27.iso / spool / comp / lang / cplus / 16354 < prev    next >
Encoding:
Text File  |  1992-11-16  |  3.4 KB  |  134 lines

  1. Newsgroups: comp.lang.c++
  2. Path: sparky!uunet!think.com!sdd.hp.com!zaphod.mps.ohio-state.edu!cis.ohio-state.edu!news.sei.cmu.edu!weinstoc
  3. From: weinstoc@sei.cmu.edu (Chuck Weinstock)
  4. Subject: Help with OWL Dialogs
  5. Message-ID: <1992Nov16.145858.26887@sei.cmu.edu>
  6. Sender: netnews@sei.cmu.edu (Netnews)
  7. Organization: The Software Engineering Institute
  8. Date: Mon, 16 Nov 1992 14:58:58 GMT
  9. Lines: 123
  10.  
  11.  
  12. I was wondering if anyone could help me with a problem I'm having using OWL
  13. dialogs.  The code below is supposed to implement a simple dialog box with one
  14. edit text item in it.  The dialog itself is defined in a .rc file.
  15.  
  16. When executed the dialog box comes up on the screen just fine, but when I
  17. click on "OK", it exits and an error dialog pops up indiciating an error code
  18. of -1 was sent and asking if it should continue or not.  Can anyone suggest
  19. why this is happening and how to avoid it?
  20.  
  21. Chuck Weinstock
  22.  
  23. #include <edit.h>
  24. #include <owl.h>
  25.  
  26. #define D_ONE_ITEM    3101
  27. #define FM_EXIT    2101
  28. #define DM_ONE    2102
  29.  
  30. struct {
  31.     char DataOne[6];
  32. } DialogOneData;
  33.  
  34. class TDialogOne : public TDialog {
  35.  
  36.     TEdit* Data;
  37.  
  38. public:
  39.  
  40.     TDialogOne(PTWindowsObject);
  41. };
  42.  
  43. TDialogOne::TDialogOne(PTWindowsObject AParent) :
  44.     TDialog(AParent,"DIALOG_1")
  45. {
  46.     Data = new TEdit(this,DM_ONE,6);
  47.     TransferBuffer = (LPSTR) &DialogOneData;
  48. };
  49.  
  50. class TTestOwl : public TWindow {
  51.  
  52. public:
  53.  
  54.     TTestOwl(PTWindowsObject AParent,LPSTR Title) :
  55.         TWindow(AParent,Title) {}
  56.     LPSTR GetClassName() {return "TestOwl";}
  57.     void GetWindowClass(WNDCLASS&);
  58.     virtual void HandleDialogOne(RTMessage) = [CM_FIRST + DM_ONE];
  59.     virtual void Exit(RTMessage) = [CM_FIRST + FM_EXIT] {
  60.         CloseWindow();
  61.     }
  62. };
  63.  
  64. void TTestOwl::GetWindowClass(WNDCLASS& wndClass)
  65. {
  66.      TWindow::GetWindowClass(wndClass);
  67.  
  68.      // attach a menu to the main window
  69.      wndClass.lpszMenuName  = "TestMenu";
  70. }
  71.  
  72. void TTestOwl::HandleDialogOne(RTMessage)
  73. {
  74.     int Result;
  75.  
  76.     Result = GetApplication()->ExecDialog(new TDialogOne(this));
  77. }
  78.  
  79. class TUserApplication: public TApplication {
  80.  
  81. public:
  82.  
  83.      TUserApplication(LPSTR AName,
  84.         HINSTANCE AnInstance,
  85.         HINSTANCE APrevInstance,
  86.                 LPSTR ACmdLine,
  87.                 int ACmdShow)
  88.  
  89.           :  TApplication(AName, AnInstance,
  90.                     APrevInstance,
  91.                     ACmdLine, ACmdShow) {}
  92.      virtual void InitMainWindow();
  93. };
  94.  
  95. LPSTR APPLICATION_NAME =
  96.   "Test Owl";
  97.  
  98. void TUserApplication::InitMainWindow()
  99. {
  100.      MainWindow = new TTestOwl(NULL,
  101.                          APPLICATION_NAME);
  102. }
  103.  
  104. int PASCAL WinMain(HINSTANCE AnInstance, HINSTANCE APrevInstance,
  105.          LPSTR ACmdLine, int ACmdShow)
  106. {
  107.      TUserApplication Application(APPLICATION_NAME,
  108.              AnInstance,
  109.              APrevInstance,
  110.              ACmdLine,
  111.              ACmdShow);
  112.      Application.nCmdShow = SW_SHOWMAXIMIZED;
  113.      Application.Run();
  114.      return Application.Status;
  115. }
  116.  
  117. In case it matters, here is the dialog definition from the .rc file:
  118.  
  119. DIALOG_1 DIALOG 18, 18, 142, 92
  120. STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
  121. CLASS "BorDlg"
  122. CAPTION "DIALOG_1"
  123. BEGIN
  124.     CONTROL "Button", IDOK, "BorBtn", BS_DEFPUSHBUTTON | WS_CHILD | WS_VISIBLE | WS_TABSTOP, 100, 62, 32, 20
  125.     EDITTEXT D_ONE_ITEM, 48, 24, 53, 12, ES_LEFT | WS_CHILD | WS_VISIBLE | WS_BORDER | WS_TABSTOP
  126.     RTEXT "Data", -1, 13, 26, 30, 8, SS_RIGHT | WS_CHILD | WS_VISIBLE | WS_GROUP
  127. END
  128.  
  129.  
  130. Chuck Weinstock                weinstock@sei.cmu.edu
  131. Software Engineering Institute        (412) 268-7719
  132. Carnegie Mellon University        (412) 268-5758 (Fax)
  133. Pittsburgh, PA 15213
  134.