home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #27 / NN_1992_27.iso / spool / comp / os / msdos / programm / 10699 < prev    next >
Encoding:
Text File  |  1992-11-17  |  3.4 KB  |  150 lines

  1. Newsgroups: comp.os.msdos.programmer
  2. Path: sparky!uunet!zaphod.mps.ohio-state.edu!cis.ohio-state.edu!news.sei.cmu.edu!weinstoc
  3. From: weinstoc@sei.cmu.edu (Chuck Weinstock)
  4. Subject: OWL Help?
  5. Message-ID: <1992Nov17.145826.4758@sei.cmu.edu>
  6. Sender: netnews@sei.cmu.edu (Netnews)
  7. Organization: The Software Engineering Institute
  8. Date: Tue, 17 Nov 1992 14:58:26 GMT
  9. Lines: 139
  10.  
  11.  
  12. The OWL program below works just fine when I ask it to display the dialog box,
  13. but an error window pops up upon exit from the dialog saying that an error
  14. message -1 was received and asking whether it should continue.  I've tried
  15. everything I could think of to fix this problem and I'm fresh out of ideas.
  16. Can anyone out there help me?
  17.  
  18. Chuck Weinstock
  19.  
  20. #include <edit.h>
  21. #include <owl.h>
  22.  
  23. #define D_ONE_ITEM    3101
  24. #define FM_EXIT    2101
  25. #define DM_ONE    2102
  26.  
  27. struct {
  28.     char DataOne[6];
  29. } DialogOneData;
  30.  
  31. class TDialogOne : public TDialog {
  32.  
  33.     TEdit* Data;
  34.  
  35. public:
  36.  
  37.     TDialogOne(PTWindowsObject);
  38. };
  39.  
  40. TDialogOne::TDialogOne(PTWindowsObject AParent) :
  41.     TDialog(AParent,"DIALOG_1")
  42. {
  43.     Data = new TEdit(this,DM_ONE,6);
  44.     TransferBuffer = (LPSTR) &DialogOneData;
  45. };
  46.  
  47. class TTestOwl : public TWindow {
  48.  
  49. public:
  50.  
  51.     TTestOwl(PTWindowsObject AParent,LPSTR Title) :
  52.         TWindow(AParent,Title) {}
  53.     LPSTR GetClassName() {return "TestOwl";}
  54.     void GetWindowClass(WNDCLASS&);
  55.     virtual void HandleDialogOne(RTMessage) = [CM_FIRST + DM_ONE];
  56.     virtual void Exit(RTMessage) = [CM_FIRST + FM_EXIT] {
  57.         CloseWindow();
  58.     }
  59. };
  60.  
  61. void TTestOwl::GetWindowClass(WNDCLASS& wndClass)
  62. {
  63.      TWindow::GetWindowClass(wndClass);
  64.  
  65.      // attach a menu to the main window
  66.      wndClass.lpszMenuName  = "TestMenu";
  67. }
  68.  
  69. void TTestOwl::HandleDialogOne(RTMessage)
  70. {
  71.     int Result;
  72.  
  73.     Result = GetApplication()->ExecDialog(new TDialogOne(this));
  74. }
  75.  
  76. class TUserApplication: public TApplication {
  77.  
  78. public:
  79.  
  80.      TUserApplication(LPSTR AName,
  81.         HINSTANCE AnInstance,
  82.         HINSTANCE APrevInstance,
  83.                 LPSTR ACmdLine,
  84.                 int ACmdShow)
  85.  
  86.           :  TApplication(AName, AnInstance,
  87.                     APrevInstance,
  88.                     ACmdLine, ACmdShow) {}
  89.      virtual void InitMainWindow();
  90. };
  91.  
  92. LPSTR APPLICATION_NAME =
  93.   "Test Owl";
  94.  
  95. void TUserApplication::InitMainWindow()
  96. {
  97.      MainWindow = new TTestOwl(NULL,
  98.                          APPLICATION_NAME);
  99. }
  100.  
  101. int PASCAL WinMain(HINSTANCE AnInstance, HINSTANCE APrevInstance,
  102.          LPSTR ACmdLine, int ACmdShow)
  103. {
  104.      TUserApplication Application(APPLICATION_NAME,
  105.              AnInstance,
  106.              APrevInstance,
  107.              ACmdLine,
  108.              ACmdShow);
  109.      Application.nCmdShow = SW_SHOWMAXIMIZED;
  110.      Application.Run();
  111.      return Application.Status;
  112. }
  113.  
  114. In case it's useful, here is the .RC file.
  115.  
  116. #define D_ONE_ITEM    3101
  117. #define FM_EXIT    2101
  118. #define DM_ONE    2102
  119.  
  120. TestMenu MENU 
  121. BEGIN
  122.     POPUP "&File"
  123.     BEGIN
  124.         MENUITEM "&Exit", FM_EXIT
  125.     END
  126.  
  127.     POPUP "&Dialogs"
  128.     BEGIN
  129.         MENUITEM "Dialog&1", DM_ONE
  130.     END
  131.  
  132. END
  133.  
  134.  
  135. DIALOG_1 DIALOG 18, 18, 142, 92
  136. STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
  137. CLASS "BorDlg"
  138. CAPTION "DIALOG_1"
  139. BEGIN
  140.     CONTROL "Button", IDOK, "BorBtn", BS_DEFPUSHBUTTON | WS_CHILD | WS_VISIBLE | WS_TABSTOP, 100, 62, 32, 20
  141.     EDITTEXT D_ONE_ITEM, 48, 24, 53, 12, ES_LEFT | WS_CHILD | WS_VISIBLE | WS_BORDER | WS_TABSTOP
  142.     RTEXT "Data", -1, 13, 26, 30, 8, SS_RIGHT | WS_CHILD | WS_VISIBLE | WS_GROUP
  143. END
  144.  
  145.  
  146. Chuck Weinstock                weinstock@sei.cmu.edu
  147. Software Engineering Institute        (412) 268-7719
  148. Carnegie Mellon University        (412) 268-5758 (Fax)
  149. Pittsburgh, PA 15213
  150.