home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 7 / 07.iso / c / c082_144 / 6.ddi / OWLDEMOS.ZIP / DIALTEST.CPP < prev    next >
Encoding:
C/C++ Source or Header  |  1992-06-10  |  2.3 KB  |  83 lines

  1. // ObjectWindows - (C) Copyright 1992 by Borland International
  2.  
  3. #include <owl.h>
  4. #include <dialog.h>
  5. #include "dialtest.h"
  6.  
  7. class TTestDialog : public TDialog
  8. {
  9. public:
  10.   TTestDialog(PTWindowsObject AParent, LPSTR AName)
  11.     : TDialog(AParent, AName) {};
  12.   virtual void HandleButtonMsg(RTMessage Msg)
  13.     = [ID_FIRST + ID_BUTTON];
  14.   virtual void HandleListBoxMsg(RTMessage Msg)
  15.     = [ID_FIRST + ID_LISTBOX];
  16. };
  17.  
  18. class TTestWindow : public TWindow
  19. {
  20. public:
  21.   TTestWindow(PTWindowsObject AParent, LPSTR ATitle);
  22.   virtual void CMTest(RTMessage Msg)
  23.     = [CM_FIRST + CM_TEST];
  24. };
  25.  
  26. class TTestApp : public TApplication
  27. {
  28. public:
  29.   TTestApp(LPSTR AName, HINSTANCE hInstance, HINSTANCE hPrevInstance,
  30.     LPSTR lpCmdLine, int nCmdShow) :
  31.     TApplication(AName, hInstance, hPrevInstance, lpCmdLine, nCmdShow) {};
  32.   virtual void InitMainWindow();
  33. };
  34.  
  35. void TTestDialog::HandleButtonMsg(RTMessage)
  36. {
  37.   SendDlgItemMsg(ID_LISTBOX, LB_ADDSTRING, 0, (LONG)"Item 1");
  38.   SendDlgItemMsg(ID_LISTBOX, LB_ADDSTRING, 0, (LONG)"Item 2");
  39.   SendDlgItemMsg(ID_LISTBOX, LB_ADDSTRING, 0, (LONG)"Item 3");
  40.   SendDlgItemMsg(ID_LISTBOX, LB_ADDSTRING, 0, (LONG)"Item 4");
  41.   SendDlgItemMsg(ID_LISTBOX, LB_ADDSTRING, 0, (LONG)"Item 5");
  42.   SendDlgItemMsg(ID_LISTBOX, LB_ADDSTRING, 0, (LONG)"Item 6");
  43.   SendDlgItemMsg(ID_LISTBOX, LB_ADDSTRING, 0, (LONG)"Item 7");
  44. }
  45.  
  46. void TTestDialog::HandleListBoxMsg(RTMessage Msg)
  47. {
  48.   DWORD Idx;
  49.   char SelectedText[10];
  50.  
  51.   if ( Msg.LP.Hi == LBN_SELCHANGE )
  52.   {
  53.     Idx = SendDlgItemMsg(ID_LISTBOX, LB_GETCURSEL, 0, 0L);
  54.     SendDlgItemMsg(ID_LISTBOX, LB_GETTEXT, (WORD)Idx, (DWORD)SelectedText);
  55.     MessageBox(HWindow, SelectedText, "You selected", MB_OK);
  56.   }
  57. }
  58.  
  59. TTestWindow::TTestWindow(PTWindowsObject AParent, LPSTR ATitle)
  60.   : TWindow(AParent, ATitle)
  61. {
  62.   AssignMenu("COMMANDS");
  63. }
  64.  
  65. void TTestWindow::CMTest(RTMessage)
  66. {
  67.   GetApplication()->ExecDialog(new TTestDialog(this, "TESTDIALOG"));
  68. }
  69.  
  70. void TTestApp::InitMainWindow()
  71. {
  72.   MainWindow = new TTestWindow(NULL, Name);
  73. }
  74.  
  75. int PASCAL WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
  76.   LPSTR lpCmdLine, int nCmdShow)
  77. {
  78.   TTestApp TestApp("Dialog Tester", hInstance, hPrevInstance,
  79.     lpCmdLine, nCmdShow);
  80.   TestApp.Run();
  81.   return (TestApp.Status);
  82. }
  83.