home *** CD-ROM | disk | FTP | other *** search
/ Media Share 13 / mediashare_13.zip / mediashare_13 / ZIPPED / PROGRAM / TBIWIN12.ZIP / WINDOW.CPP < prev    next >
C/C++ Source or Header  |  1992-12-15  |  3KB  |  99 lines

  1. //----------------------------------------------------
  2. // WINDOW.CPP (c) Casper Pedersen 1992
  3. //----------------------------------------------------
  4. // Test program for TBIWindow
  5. // For use of TBIWindow, please read TBIWIN.CPP
  6. // and TBIWIN.H and TBIWIN.DOC
  7. //----------------------------------------------------
  8.  
  9. #include <owl.h>
  10. #include <bwcc.h>
  11. #include "tbiwin.h"
  12.  
  13. //----------------------------------------------------
  14. _CLASSDEF(Win)
  15. class _EXPORT Win : public TBIWindow
  16. {
  17.   protected:
  18.     virtual LPSTR GetClassName() { return("WINDOW"); }
  19.  
  20.   public:
  21.     Win(PTWindowsObject AParent, LPSTR ATitle);
  22.  
  23.     virtual void ButtonActivated(void);
  24.     virtual void Button100(RTMessage) = [CM_FIRST + 100];
  25.     virtual void Button101(RTMessage) = [CM_FIRST + 101];
  26.     virtual void Button102(RTMessage) = [CM_FIRST + 102];
  27. };
  28.  
  29. //----------------------------------------------------
  30. // Construcors for both LEFT and RIGHT placement.
  31. //Win::Win(PTWindowsObject AParent, LPSTR ATitle) : TBIWindow(AParent, ATitle, LEFT)
  32. Win::Win(PTWindowsObject AParent, LPSTR ATitle) : TBIWindow(AParent, ATitle, RIGHT)
  33. {
  34.   AddButton(100);
  35.   AddButton(101);
  36.   AddButton(102);
  37. }
  38.  
  39. //----------------------------------------------------
  40. void Win::ButtonActivated(void)
  41. {
  42.   HDC hdc = GetDC(HWindow);
  43.   char tmp[30];
  44.   wsprintf(tmp,"Button Activate: %d", ButtonActive);
  45.   TextOut(hdc, 10, 10, tmp, lstrlen(tmp));
  46.   ReleaseDC(HWindow, hdc);
  47. }
  48.  
  49. //----------------------------------------------------
  50. void Win::Button100(RTMessage Msg)
  51. {
  52.   HDC hdc = GetDC(HWindow);
  53.   char tmp[30];
  54.   wsprintf(tmp,"Button Activate: %d", Msg.WParam);
  55.   TextOut(hdc, 10, 30, tmp, lstrlen(tmp));
  56.   ReleaseDC(HWindow, hdc);
  57. }
  58.  
  59. //----------------------------------------------------
  60. void Win::Button101(RTMessage)
  61. {
  62.   AboutTBIWindow();
  63. }
  64.  
  65. //----------------------------------------------------
  66. void Win::Button102(RTMessage)
  67. {
  68.   SendMessage(HWindow, WM_CLOSE, 0, 0l);
  69. }
  70.  
  71. //----------------------------------------------------
  72. // Application Base class
  73. //----------------------------------------------------
  74. class T3dApp : public TApplication
  75. {
  76.   public:
  77.    T3dApp(LPSTR Name, HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmd,int nCmdShow):TApplication(Name, hInstance, hPrevInstance, lpCmd, nCmdShow){};
  78.    virtual void InitMainWindow();
  79. };
  80.  
  81. //----------------------------------------------------
  82. // init FrameWin
  83. //----------------------------------------------------
  84. void T3dApp::InitMainWindow()
  85. {
  86.   MainWindow = new Win(NULL, "Test Window");
  87. }
  88.  
  89. //----------------------------------------------------
  90. // Application entry/exit point
  91. //----------------------------------------------------
  92. int PASCAL WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpszCmdLine, int CmdShow)
  93. {
  94.   T3dApp App("WINDOW", hInstance, hPrevInstance, lpszCmdLine, CmdShow);
  95.   App.Run();
  96.   return (App.Status);
  97. }
  98. //----------------------------------------------------
  99.