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

  1. (* ------------------------------------------------------ *)
  2. (*                     LITTGDI2.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 2                          *)
  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.       NewBrush := CreateSolidBrush
  50.                 (RGB(RANDOM(256),RANDOM(256), RANDOM(256)));
  51.       OldBrush := SelectObject(EinDC, NewBrush);
  52.       x := Random(R.Right);
  53.       y := Random(R.Bottom);
  54.       Ellipse(EinDC, x, y, x+30, y+Random(50));
  55.       SelectObject(EinDC, OldBrush);
  56.       ReleaseDC(hWindow, EinDC);
  57.       DeleteObject(NewBrush);
  58.     END;
  59.   END;
  60.  
  61. (* ------------------------------------------------------ *)
  62. (*                   Ende von Listing 2                   *)
  63.  
  64.   PROCEDURE tGDIFenster.WMRButtonDown(VAR Msg : tMessage);
  65.   BEGIN
  66.     InvalidateRect(hWindow, NIL, TRUE);
  67.   END;
  68.  
  69. BEGIN
  70.   MyApp.Init('MyApp');
  71.   MyApp.Run;
  72.   MyApp.Done;
  73. END.
  74. (* ------------------------------------------------------ *)
  75. (*                Ende von LITTGDI2.PAS                    *)
  76.  
  77.  
  78.  
  79.