home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 7 / 07.iso / c / c082_122 / 10.ddi / STEPS.ZIP / STEP2.CPP < prev    next >
Encoding:
C/C++ Source or Header  |  1992-06-10  |  1.5 KB  |  58 lines

  1. // ObjectWindows - (C) Copyright 1992 by Borland International
  2.  
  3. #include <owl.h>
  4.  
  5. class TMyApp : public TApplication
  6. {
  7. public:
  8.   TMyApp(LPSTR AName, HINSTANCE hInstance, HINSTANCE hPrevInstance,
  9.     LPSTR lpCmdLine, int nCmdShow)
  10.     : TApplication(AName, hInstance, hPrevInstance, lpCmdLine, nCmdShow) {};
  11.   virtual void InitMainWindow();
  12. };
  13.  
  14. _CLASSDEF(TMyWindow)
  15. class TMyWindow : public TWindow
  16. {
  17. public:
  18.   TMyWindow(PTWindowsObject AParent, LPSTR ATitle)
  19.     : TWindow(AParent, ATitle) {};
  20.   virtual BOOL CanClose();
  21.   virtual void WMLButtonDown(RTMessage Msg)
  22.     = [WM_FIRST + WM_LBUTTONDOWN];
  23.   virtual void WMRButtonDown(RTMessage Msg)
  24.     = [WM_FIRST + WM_RBUTTONDOWN];
  25. };
  26.  
  27. BOOL TMyWindow::CanClose()
  28. {
  29.   return MessageBox(HWindow, "Do you want to save?",
  30.     "Drawing has changed", MB_YESNO | MB_ICONQUESTION) == IDNO;
  31. }
  32.  
  33. void TMyWindow::WMLButtonDown(RTMessage)
  34. {
  35.   MessageBox(HWindow, "You have pressed the left mouse button",
  36.     "Message Dispatched", MB_OK);
  37. }
  38.  
  39. void TMyWindow::WMRButtonDown(RTMessage)
  40. {
  41.   MessageBox(HWindow, "You have pressed the right mouse button",
  42.     "Message Dispatched", MB_OK);
  43. }
  44.  
  45. void TMyApp::InitMainWindow()
  46. {
  47.   MainWindow = new TMyWindow(NULL, Name);
  48. }
  49.  
  50. int PASCAL WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
  51.   LPSTR lpCmdLine, int nCmdShow)
  52. {
  53.   TMyApp MyApp("Sample ObjectWindows Program", hInstance, hPrevInstance,
  54.                lpCmdLine, nCmdShow);
  55.   MyApp.Run();
  56.   return MyApp.Status;
  57. }
  58.