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

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