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

  1. // ObjectWindows - (C) Copyright 1992 by Borland International
  2.  
  3. #include <owl.h>
  4. #include <windobj.h>
  5. #include <string.h>
  6.  
  7. const int BitMapWidth  = 640;
  8. const int BitMapHeight = 480;
  9.  
  10. const COLORREF Colors[3][16] = {
  11.     {0x00FFFFFFl,0x00E0E0E0l,0x00C0C0FFl,0x00C0E0FFl,0x00E0FFFFl,0x00C0FFC0l,0x00FFFFC0l,0x00FFC0C0l,
  12.      0x00FFC0FFl,0x000000C0l,0x000040C0l,0x0000C0C0l,0x0000C000l,0x00C0C000l,0x00C00000l,0x00C000C0l},
  13.     {0x00C0C0C0l,0x00404040l,0x008080FFl,0x0080C0FFl,0x0080FFFFl,0x0080FF80l,0x00FFFF80l,0x00FF8080l,
  14.      0x00FF80FFl,0x00000080l,0x00004080l,0x00008080l,0x00008000l,0x00808000l,0x00800000l,0x00800080l},
  15.     {0x00808080l,0x00000000l,0x000000FFl,0x000080FFl,0x0000FFFFl,0x0000FF00l,0x00FFFF00l,0x00FF0000l,
  16.      0x00FF00FFl,0x00000040l,0x00404080l,0x00004040l,0x00004000l,0x00404000l,0x00400000l,0x00400040l}};
  17.  
  18. const int ToolCount = 6;
  19.  
  20. const int LineCount = 8;
  21. const int LineBarWidth = LineCount * 4 + 6 + (1 + 2 + 3 + 4 + 5 + 7 + 9 + 12);
  22. const int LineWidth[ LineCount ] = { 1, 2, 3, 4, 5, 7, 9, 12 };
  23.  
  24. _CLASSDEF(TDrawTool)
  25. _CLASSDEF(TCanvas)
  26.  
  27. struct TState {
  28.      PTDrawTool DrawTool;
  29.          HBITMAP   BitMap;
  30.          int       PenSize;
  31.          COLORREF  PenColor;
  32.          COLORREF  BrushColor;
  33. };
  34. typedef TState* PTState;
  35.  
  36. class TDrawTool
  37. {
  38. protected:
  39.          HCURSOR Cursor;
  40.          HICON Icon;
  41.          PTState State;
  42.          HWND Window;
  43.          HPEN Pen;
  44.          HBRUSH Brush;
  45.          HDC DC;
  46.          HPEN OrigPen;
  47.          HBRUSH OrigBrush;
  48. public:
  49.          TDrawTool( LPSTR IconName);
  50.          void MouseDown( HWND AWindow, int X, int Y, PTState AState);
  51.          void MouseMove( int X, int Y);
  52.          void MouseUp();
  53.          virtual void DrawBegin( int, int) {};       // Abstract draw methods will be implemented
  54.          virtual void DrawTo( int, int) {};          // in derrived classes
  55.      virtual void DrawEnd() {};
  56.      HCURSOR GetCursor() { return Cursor; };     // Classes other than derrived may want
  57.      HICON GetIcon() { return Icon; };           // access to these member fields
  58. };
  59.  
  60. _CLASSDEF(TPenTool)
  61.  
  62. class TPenTool : public TDrawTool
  63. {
  64. protected:
  65.      HPEN BrushPen;
  66.     HPEN OrigBrushPen;
  67. public:
  68.      TPenTool( LPSTR IconName ) : TDrawTool( IconName ) {};
  69.      virtual void DrawBegin( int X, int Y);
  70.      virtual void DrawTo( int X, int Y);
  71.      virtual void DrawEnd();
  72. };
  73.  
  74. _CLASSDEF(TFillTool)
  75.  
  76. class TFillTool : public TDrawTool
  77. {
  78. public:
  79.      TFillTool( LPSTR IconName ) : TDrawTool( IconName ) {};
  80.          virtual void DrawBegin( int X, int Y);
  81. };
  82.  
  83. _CLASSDEF(TBoxTool)
  84.  
  85. class TBoxTool : public TDrawTool
  86. {
  87. protected:
  88.          BOOL Filled;
  89.          int X1, Y1, X2, Y2;
  90. public:
  91.          TBoxTool( LPSTR IconName, BOOL AFilled )
  92.           : TDrawTool( IconName ) { Filled = AFilled; };
  93.          virtual void DrawBegin( int X, int Y);
  94.          virtual void DrawTo( int X, int Y);
  95.          virtual void DrawEnd();
  96.          virtual void DrawObject() {};
  97. };
  98.  
  99. _CLASSDEF(TRectTool)
  100.  
  101. class TRectTool : public TBoxTool
  102. {
  103. public:  TRectTool( LPSTR IconName, BOOL AFilled )
  104.           : TBoxTool( IconName, AFilled ) {};
  105.          virtual void DrawObject();
  106. };
  107.  
  108. _CLASSDEF(TEllipseTool)
  109.  
  110. class TEllipseTool : public TBoxTool
  111. {
  112. public:  TEllipseTool( LPSTR IconName, BOOL AFilled )
  113.               : TBoxTool( IconName, AFilled ) {};
  114.          virtual void DrawObject();
  115. };
  116.  
  117. _CLASSDEF(TPalette)
  118.  
  119. class TPalette : public TWindow
  120. {
  121. private:
  122.          PTState State;
  123. public:
  124.      TPalette( PTWindowsObject AParent, PTState AState );
  125.          virtual void Paint( HDC PaintDC, PAINTSTRUCT& PaintInfo );
  126.          void SelectColor( TMessage& Message, COLORREF& Color );
  127.          virtual void WMLButtonDown( TMessage& Message ) = [ WM_FIRST + WM_LBUTTONDOWN ];
  128.          virtual void WMRButtonDown( TMessage& Message ) = [ WM_FIRST + WM_RBUTTONDOWN ];
  129. };
  130.  
  131. _CLASSDEF(TToolBar)
  132.  
  133. class TToolBar : public TWindow
  134. {
  135. private:
  136.          PTState State;
  137.          PTDrawTool Tools[ ToolCount ];
  138. public:
  139.          TToolBar( PTWindowsObject AParent, PTState AState );
  140.          virtual ~TToolBar();
  141.          virtual void Paint( HDC PaintDC, PAINTSTRUCT& PaintInfo );
  142.          virtual void WMLButtonDown( TMessage& Message ) = [ WM_FIRST + WM_LBUTTONDOWN ];
  143. };
  144.  
  145. _CLASSDEF(TLineBar)
  146.  
  147. class TLineBar : public TWindow
  148. {
  149. public:
  150.          TLineBar( PTWindowsObject AParent, PTState AState );
  151.          virtual void Paint( HDC PaintDC, PAINTSTRUCT& PaintInfo );
  152.          virtual void WMLButtonDown( TMessage& Message ) = [ WM_FIRST + WM_LBUTTONDOWN ];
  153. private:
  154.          PTState State;
  155.          void Notch( HDC PaintDC, int X, int W, int Y, int DY );
  156. };
  157.  
  158. // TCanvas has already been _CLASSDEF'd
  159.  
  160. class TCanvas : public TWindow
  161. {
  162. private:
  163.          PTState State;
  164.          BOOL Drawing;
  165. public:
  166.          TCanvas( PTWindowsObject AParent, PTState AState );
  167.          virtual ~TCanvas();
  168.          virtual LPSTR GetClassName() { return "TCanvas"; };
  169.      virtual void Paint( HDC PaintDC, PAINTSTRUCT& PaintInfo );
  170.          virtual void WMLButtonDown( TMessage& Message ) = [ WM_FIRST + WM_LBUTTONDOWN ];
  171.          virtual void WMLButtonUp( TMessage& Message ) = [ WM_FIRST + WM_LBUTTONUP ];
  172.          virtual void WMMouseMove( TMessage& Message ) = [ WM_FIRST + WM_MOUSEMOVE ];
  173.          virtual void WMSetCursor( TMessage& Message ) = [ WM_FIRST + WM_SETCURSOR ];
  174. };
  175.  
  176. _CLASSDEF(TPaintWin)
  177.  
  178. class TPaintWin : public TWindow
  179. {
  180. private:
  181.          TState State;
  182.          PTPalette Palette;
  183.          PTToolBar ToolBar;
  184.          PTLineBar LineBar;
  185.          PTCanvas Canvas;
  186. public:
  187.          TPaintWin( PTWindowsObject AParent, LPSTR ATitle);
  188.          virtual LPSTR GetClassName() { return "TPaintWin"; };
  189.          virtual void GetWindowClass( WNDCLASS& WndClass );
  190.          virtual void WMSize( TMessage& Message ) = [ WM_FIRST + WM_SIZE ];
  191. };
  192.  
  193.  
  194. class TPaintApp : public TApplication
  195. {
  196. public:
  197.     TPaintApp( LPSTR name, HINSTANCE hInstance,
  198.           HINSTANCE hPrevInstance, LPSTR lpCmd,
  199.           int nCmdShow)
  200.             : TApplication(name, hInstance,
  201.                    hPrevInstance, lpCmd, nCmdShow) {};
  202.     virtual void InitMainWindow( void );
  203. };
  204.  
  205.  
  206. // --------------- TDrawTool ------------------------
  207.  
  208. TDrawTool::TDrawTool( LPSTR IconName )
  209. {
  210.   char Temp[30];
  211.  
  212.   _fstrcpy(Temp, IconName);
  213.   strncat(Temp, "Tool", sizeof(Temp)-1);
  214.   Icon = LoadIcon(GetApplicationObject()->hInstance, Temp);
  215.  
  216.   _fstrcpy(Temp, IconName);
  217.   strncat(Temp, "Cursor", sizeof(Temp)-1);
  218.   Cursor = LoadCursor(GetApplicationObject()->hInstance, Temp);
  219. };
  220.  
  221. void TDrawTool::MouseDown( HWND AWindow, int X, int Y, PTState AState )
  222. {
  223.   Window = AWindow;
  224.   State = AState;
  225.   SetCapture(Window);
  226.   Pen = CreatePen(PS_SOLID, State->PenSize, State->PenColor);
  227.   Brush = CreateSolidBrush(State->BrushColor);
  228.   DC = GetDC(Window);
  229.   OrigPen = (HPEN)SelectObject(DC, Pen);
  230.   OrigBrush = (HBRUSH)SelectObject(DC, Brush);
  231.   DrawBegin(X, Y);
  232. };
  233.  
  234. void TDrawTool::MouseMove( int X, int Y )
  235. {
  236.   DrawTo(X, Y);
  237. };
  238.  
  239. void TDrawTool::MouseUp()
  240. {
  241.   DrawEnd();
  242.   ReleaseCapture();
  243.   SelectObject(DC, OrigPen);
  244.   SelectObject(DC, OrigBrush);
  245.   DeleteObject(Brush);
  246.   DeleteObject(Pen);
  247.   ReleaseDC(Window, DC);
  248. };
  249.  
  250.  
  251. // --------------- TPenTool ------------------------
  252.  
  253. void TPenTool::DrawBegin( int X, int Y )
  254. {
  255.   BrushPen = CreatePen(PS_SOLID, State->PenSize, State->BrushColor);
  256.   OrigBrushPen = (HPEN)SelectObject(DC, BrushPen);
  257.   MoveTo(DC, X, Y);
  258. };
  259.  
  260. void TPenTool::DrawTo( int X, int Y )
  261. {
  262.   LineTo(DC, X, Y);
  263. };
  264.  
  265. void TPenTool::DrawEnd()
  266. {
  267.   SelectObject(DC, OrigBrushPen);
  268.   DeleteObject(BrushPen);
  269. };
  270.  
  271. // --------------- TFillTool ------------------------
  272.  
  273. void TFillTool::DrawBegin( int X, int Y )
  274. {
  275.   DWORD SurfaceColor;
  276.   SurfaceColor = GetPixel(DC, X, Y);
  277.   ExtFloodFill(DC, X, Y, SurfaceColor, FLOODFILLSURFACE);
  278. };
  279.  
  280.  
  281. // --------------- TBoxTool ------------------------
  282.  
  283. void TBoxTool::DrawBegin( int X, int Y )
  284. {
  285.   X1 = X;
  286.   Y1 = Y;
  287.   X2 = X;
  288.   Y2 = Y;
  289.   SelectObject(DC, GetStockObject(BLACK_PEN));
  290.   SelectObject(DC, GetStockObject(NULL_BRUSH));
  291.   SetROP2(DC, R2_NOT);
  292.   DrawObject();
  293. };
  294.  
  295. void TBoxTool::DrawTo( int X, int Y )
  296. {
  297.   DrawObject();
  298.   X2 = X;
  299.   Y2 = Y;
  300.   DrawObject();
  301. };
  302.  
  303. void TBoxTool::DrawEnd()
  304. {
  305.   DrawObject();
  306.   SetROP2(DC, R2_COPYPEN);
  307.   SelectObject(DC, Pen);
  308.   if (!Filled) DrawObject();
  309.   SelectObject(DC, Brush);
  310.   if (Filled) DrawObject();
  311. };
  312.  
  313. // --------------- TRectTool ------------------------
  314.  
  315. void TRectTool::DrawObject()
  316. {
  317.   Rectangle(DC, X1, Y1, X2, Y2);
  318. };
  319.  
  320. // --------------- TEllipseTool ------------------------
  321.  
  322. void TEllipseTool::DrawObject()
  323. {
  324.   Ellipse(DC, X1, Y1, X2, Y2);
  325. };
  326.  
  327. // --------------- TPalette ------------------------
  328.  
  329. TPalette::TPalette( PTWindowsObject AParent, PTState AState) :
  330.                   TWindow(AParent, NULL)
  331. {
  332.   Attr.Style = WS_CHILD | WS_VISIBLE;
  333.   State = AState;
  334. };
  335.  
  336. void TPalette::Paint( HDC PaintDC, PAINTSTRUCT& )
  337. {
  338.   int X, Y, S;
  339.   HPEN OldPen;
  340.   HBRUSH OldBrush;
  341.   RECT R;
  342.  
  343.   GetClientRect(HWindow, &R);
  344.   S = R.bottom / 17;
  345.   for( Y = 0; Y < 16; Y++ )
  346.     for( X = 0; X < 3; X++ ) {
  347.       OldBrush = (HBRUSH)SelectObject(PaintDC, CreateSolidBrush(Colors[X][Y]));
  348.       Rectangle(PaintDC, X * S, Y * S, (X + 1) * S + 1, (Y + 1) * S + 1);
  349.       DeleteObject(SelectObject(PaintDC, OldBrush));
  350.     };
  351.  
  352.   SelectObject(PaintDC, GetStockObject(NULL_BRUSH));
  353.   Rectangle(PaintDC, 0, S * 16, R.right, R.bottom);
  354.  
  355.   OldPen = (HPEN)SelectObject(PaintDC, CreatePen(PS_SOLID, 5, State->PenColor));
  356.   OldBrush = (HBRUSH)SelectObject(PaintDC, CreateSolidBrush(State->BrushColor));
  357.   Rectangle(PaintDC, 3, S * 16 + 3, R.right - 3, R.bottom - 3);
  358.   DeleteObject(SelectObject(PaintDC, OldBrush));
  359.   DeleteObject(SelectObject(PaintDC, OldPen));
  360. };
  361.  
  362. void TPalette::SelectColor( TMessage& Message, COLORREF& Color )
  363. {
  364.   int X, Y, S;
  365.   RECT R;
  366.  
  367.   GetClientRect(HWindow, &R);
  368.   S = R.bottom / 17;
  369.   X = Message.LP.Lo / S;
  370.   Y = Message.LP.Hi / S;
  371.   if ((X < 3) && (Y < 16)) {
  372.     Color = Colors[X][Y];
  373.     InvalidateRect(HWindow, NULL, FALSE);
  374.   }
  375. };
  376.  
  377. void TPalette::WMLButtonDown( TMessage& Message )
  378. {
  379.   SelectColor(Message, State->BrushColor);
  380. };
  381.  
  382. void TPalette::WMRButtonDown( TMessage& Message )
  383. {
  384.   SelectColor(Message, State->PenColor);
  385. };
  386.  
  387.  
  388. // --------------- TToolBar ------------------------
  389.  
  390. TToolBar::TToolBar( PTWindowsObject AParent, PTState AState) :
  391.                    TWindow(AParent, NULL)
  392. {
  393.   Attr.Style = WS_CHILD | WS_VISIBLE;
  394.   State = AState;
  395.   Tools[0] = new TPenTool("Pen");
  396.   Tools[1] = new TFillTool("Fill");
  397.   Tools[2] = new TRectTool("Rect", FALSE);
  398.   Tools[3] = new TRectTool("FillRect", TRUE);
  399.   Tools[4] = new TEllipseTool("Ellipse", FALSE);
  400.   Tools[5] = new TEllipseTool("FillEllipse", TRUE);
  401.   State->DrawTool = Tools[0];
  402. };
  403.  
  404. TToolBar::~TToolBar()
  405. {
  406.   for( int i = 0; i < ToolCount; i++)
  407.     delete Tools[i];
  408. };
  409.  
  410. void TToolBar::Paint( HDC PaintDC, PAINTSTRUCT& )
  411. {
  412.   int I;
  413.   RECT R;
  414.  
  415.   for ( I = 0; I < ToolCount; I++) {
  416.     DrawIcon(PaintDC, I * 31, 0, Tools[I]->GetIcon());
  417.     if (Tools[I] == State->DrawTool) {
  418.       R.top = 1;
  419.       R.left = I * 31 + 1;
  420.       R.bottom = R.top + 30;
  421.       R.right = R.left + 30;
  422.       InvertRect(PaintDC, &R);
  423.     }
  424.   }
  425. };
  426.  
  427. void TToolBar::WMLButtonDown( TMessage& Message )
  428. {
  429.   int I;
  430.  
  431.   I = Message.LP.Lo / 31;
  432.   if ( I < ToolCount ) {
  433.     State->DrawTool = Tools[I];
  434.     InvalidateRect(HWindow, NULL, FALSE);
  435.   }
  436. };
  437.  
  438.  
  439. // --------------- TLineBar ------------------------
  440.  
  441. TLineBar::TLineBar( PTWindowsObject AParent, PTState AState) :
  442.                    TWindow(AParent, NULL)
  443. {
  444.   Attr.Style = WS_BORDER | WS_CHILD | WS_VISIBLE;
  445.   State = AState;
  446. };
  447.  
  448. void TLineBar::Notch( HDC PaintDC, int X, int W, int Y, int DY )
  449. {
  450.   for( int L = 3; L >= 0; L-- ) {
  451.     MoveTo(PaintDC, X + W / 2 - L, Y);
  452.     LineTo(PaintDC, X + W / 2 + L + 1, Y);
  453.     Y += DY;
  454.   }
  455. };
  456.  
  457. void TLineBar::Paint( HDC PaintDC, PAINTSTRUCT& )
  458. {
  459.   int I, X, W;
  460.   RECT R;
  461.  
  462.   X = 4;
  463.   for ( I = 0; I < LineCount; I++) {
  464.     W = LineWidth[I];
  465.     SetRect(&R, X, 5, X + W, 25);
  466.     FillRect(PaintDC, &R, (HBRUSH)GetStockObject(BLACK_BRUSH));
  467.     if (W == State->PenSize) {
  468.       Notch(PaintDC, X, W, 0, 1);
  469.       Notch(PaintDC, X, W, 29, -1);
  470.     };
  471.     X += W + 4;
  472.   }
  473. };
  474.  
  475. void TLineBar::WMLButtonDown( TMessage& Message )
  476. {
  477.   int I, X, W;
  478.  
  479.   X = 2;
  480.   for( I = 0; I < LineCount; I++) {
  481.     W = LineWidth[I];
  482.     if ((Message.LP.Lo >= X) && (Message.LP.Lo < (X + W + 4))) {
  483.       State->PenSize = W;
  484.       InvalidateRect(HWindow, NULL, TRUE);
  485.       return;
  486.     }
  487.     X += W + 4;
  488.   }
  489. };
  490.  
  491.  
  492. // --------------- TCanvas ------------------------
  493.  
  494. TCanvas::TCanvas( PTWindowsObject AParent, PTState AState) :
  495.                    TWindow(AParent, NULL)
  496. {
  497.   HDC DC, MemDC;
  498.  
  499.   Attr.Style = WS_BORDER | WS_CHILD | WS_VISIBLE;
  500.   State = AState;
  501.   Drawing = FALSE;
  502.   DC = GetDC(0);
  503.   State->BitMap = CreateCompatibleBitmap(DC, BitMapWidth, BitMapHeight);
  504.   MemDC = CreateCompatibleDC(DC);
  505.   SelectObject(MemDC, State->BitMap);
  506.   PatBlt(MemDC, 0, 0, BitMapWidth, BitMapHeight, WHITENESS);
  507.   DeleteDC(MemDC);
  508.   ReleaseDC(0, DC);
  509. };
  510.  
  511. TCanvas::~TCanvas()
  512. {
  513.   DeleteObject(State->BitMap);
  514. };
  515.  
  516. void TCanvas::Paint( HDC PaintDC, PAINTSTRUCT& )
  517. {
  518.   HDC MemDC;
  519.   RECT R;
  520.  
  521.   MemDC = CreateCompatibleDC(PaintDC);
  522.   SelectObject(MemDC, State->BitMap);
  523.   GetClientRect(HWindow, &R);
  524.   BitBlt(PaintDC, 0, 0, R.right, R.bottom, MemDC, 0, 0, SRCCOPY);
  525.   DeleteDC(MemDC);
  526. };
  527.  
  528. void TCanvas::WMLButtonDown( TMessage& Message )
  529. {
  530.   if (!Drawing) {
  531.     Drawing = TRUE;
  532.     State->DrawTool->MouseDown(HWindow, Message.LP.Lo, Message.LP.Hi, State);
  533.   }
  534. };
  535.  
  536. void TCanvas::WMMouseMove( TMessage& Message )
  537. {
  538.   if (Drawing)
  539.     State->DrawTool->MouseMove(Message.LP.Lo, Message.LP.Hi);
  540. };
  541.  
  542. void TCanvas::WMLButtonUp( TMessage& )
  543. {
  544.   HDC DC, MemDC;
  545.   RECT R;
  546.  
  547.   if (Drawing) {
  548.     State->DrawTool->MouseUp();
  549.     Drawing = FALSE;
  550.     DC = GetDC(HWindow);
  551.     MemDC = CreateCompatibleDC(DC);
  552.     SelectObject(MemDC, State->BitMap);
  553.     GetClientRect(HWindow, &R);
  554.     BitBlt(MemDC, 0, 0, R.right, R.bottom, DC, 0, 0, SRCCOPY);
  555.     DeleteDC(MemDC);
  556.     ReleaseDC(HWindow, DC);
  557.   }
  558. };
  559.  
  560. void TCanvas::WMSetCursor( TMessage& )
  561. {
  562.   SetCursor(State->DrawTool->GetCursor());
  563. };
  564.  
  565.  
  566. // --------------- TPaintWin ------------------------
  567.  
  568. TPaintWin::TPaintWin( PTWindowsObject AParent, LPSTR ATitle) :
  569.               TWindow(AParent, ATitle)
  570. {
  571.   State.DrawTool = NULL;
  572.   State.BitMap = 0;
  573.   State.PenSize = 3;
  574.   State.PenColor = 0x00FFFFFFl;
  575.   State.BrushColor = 0l;
  576.   Palette = new TPalette(this, &State);
  577.   ToolBar = new TToolBar(this, &State);
  578.   LineBar = new TLineBar(this, &State);
  579.   Canvas =  new TCanvas(this, &State);
  580. };
  581.  
  582. void TPaintWin::GetWindowClass( WNDCLASS& WndClass )
  583. {
  584.   TWindow::GetWindowClass(WndClass);
  585.   WndClass.hbrBackground = (HBRUSH)COLOR_APPWORKSPACE + 1;
  586.   WndClass.hIcon = LoadIcon(GetApplication()->hInstance, "PaintIcon");
  587. };
  588.  
  589. void TPaintWin::WMSize( TMessage& )
  590. {
  591.   int S;
  592.   RECT R;
  593.  
  594.   GetClientRect(HWindow, &R);
  595.   S = ((R.bottom - 8) / 17) * 3 + 1;
  596.   MoveWindow(Palette->HWindow, 4, 4, S, R.bottom - 8, TRUE);
  597.   MoveWindow(ToolBar->HWindow, S + 8, 4, ToolCount * 31 + 1, 32, TRUE);
  598.   MoveWindow(LineBar->HWindow, S + ToolCount * 31 + 13, 4, LineBarWidth, 32, TRUE);
  599.   MoveWindow(Canvas->HWindow, S + 8, 40, R.right - S - 12, R.bottom - 44, TRUE);
  600. };
  601.  
  602.  
  603. // --------------- TPaintApp ------------------------
  604.  
  605. void TPaintApp::InitMainWindow()
  606. {
  607.     MainWindow = new TPaintWin(NULL, "OWL Paint");
  608. }
  609.  
  610. // -------------Main Program--------------------
  611.  
  612. int PASCAL WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
  613.            LPSTR lpCmd, int nCmdShow)
  614. {
  615.     TPaintApp App( "OwlPaint", hInstance, hPrevInstance,
  616.         lpCmd, nCmdShow);
  617.     App.Run();
  618.     return ( App.Status );
  619. }
  620.