home *** CD-ROM | disk | FTP | other *** search
/ Turbo Toolbox / Turbo_Toolbox.iso / 1991 / 09_10 / tpw / littgdi3.pas < prev    next >
Encoding:
Pascal/Delphi Source File  |  1991-06-12  |  2.3 KB  |  82 lines

  1. (* ------------------------------------------------------ *)
  2. (*                     LITTGDI3.PAS                       *)
  3. (*               kleine GDI-Demonstration                 *)
  4. (*         (c) 1991 Andreas Schallmeier & TOOLBOX         *)
  5. (* ------------------------------------------------------ *)
  6. PROGRAM LittleGDI;
  7.  
  8. {$X+}
  9.  
  10. USES WinTypes, WinProcs, Strings, WObjects;
  11.  
  12. TYPE
  13.   pGDIFenster = ^tGDIFenster;
  14.   tGDIFenster = OBJECT(tWindow)
  15.     PROCEDURE WMLButtonDown(VAR Msg : tMessage);
  16.       VIRTUAL wm_First+wm_LButtonDown;
  17.     PROCEDURE WMRButtonDown(VAR Msg : tMessage);
  18.       VIRTUAL wm_First+wm_RButtonDown;
  19.   END;
  20.  
  21.   tMyApp = OBJECT(tApplication)
  22.     PROCEDURE InitMainWindow;  VIRTUAL;
  23.   END;
  24.  
  25. VAR
  26.   MyApp : tMyApp;
  27.  
  28.   PROCEDURE tMyApp.InitMainWindow;
  29.   BEGIN
  30.     MainWindow := New(pGDIFenster, Init(NIL,'GDI Fenster'));
  31.   END;
  32.  
  33. (* ------------------------------------------------------ *)
  34. (*                     Listing 3                          *)
  35. (* ------------------------------------------------------ *)
  36.  
  37.   PROCEDURE tGDIFenster.WMLButtonDown(VAR Msg : tMessage);
  38.   VAR
  39.     EinDC              : hDC;
  40.     R                  : tRect;
  41.     x, y               : INTEGER;
  42.     i                  : WORD;
  43.     OldBrush, NewBrush : hBrush;
  44.     aLogBrush          : tLogBrush;
  45.   BEGIN
  46.     FOR i := 0 TO 199 DO BEGIN
  47.       EinDC := GetDC(hWindow);
  48.       GetClientRect(hWindow, R);
  49.       aLogBrush.lbStyle := bs_Solid;
  50.       aLogBrush.lbColor := RGB(Random(256), Random(256),
  51.                                Random(256));
  52.       NewBrush := CreateBrushIndirect(aLogBrush);
  53.       OldBrush := SelectObject(EinDC, NewBrush);
  54.       x := RANDOM(R.Right);
  55.       y := RANDOM(R.Bottom);
  56.       Rectangle(EinDC, x, y, x+30, y+Random(50));
  57.       SelectObject(EinDC, OldBrush);
  58.       ReleaseDC(hWindow, EinDC);
  59.       DeleteObject(NewBrush);
  60.     END;
  61.   END;
  62.  
  63. (* ------------------------------------------------------ *)
  64. (*                   Ende von Listing 3                   *)
  65.  
  66.   PROCEDURE tGDIFenster.WMRButtonDown(VAR Msg : tMessage);
  67.   BEGIN
  68.     InvalidateRect(hWindow, NIL, TRUE);
  69.   END;
  70.  
  71. BEGIN
  72.   MyApp.Init('MyApp');
  73.   MyApp.Run;
  74.   MyApp.Done;
  75. END.
  76. (* ------------------------------------------------------ *)
  77. (*                Ende von LITTGDI3.PAS                   *)
  78.  
  79.  
  80.  
  81.  
  82.