home *** CD-ROM | disk | FTP | other *** search
- (* ------------------------------------------------------ *)
- (* LITTGDI4.PAS *)
- (* kleine GDI-Demonstration *)
- (* (c) 1991 Andreas Schallmeier & TOOLBOX *)
- (* ------------------------------------------------------ *)
- PROGRAM LittleGDI;
-
- {$X+}
-
- USES WinTypes, WinProcs, Strings, WObjects;
-
- TYPE
- pGDIFenster = ^tGDIFenster;
- tGDIFenster = OBJECT(tWindow)
- PROCEDURE WMLButtonDown(VAR Msg : tMessage);
- VIRTUAL wm_First+wm_LButtonDown;
- PROCEDURE WMRButtonDown(VAR Msg : tMessage);
- VIRTUAL wm_First+wm_RButtonDown;
- END;
-
- tMyApp = OBJECT(tApplication)
- PROCEDURE InitMainWindow; VIRTUAL;
- END;
-
- VAR
- MyApp : tMyApp;
-
- PROCEDURE tMyApp.InitMainWindow;
- BEGIN
- MainWindow := New(pGDIFenster, Init(NIL,'GDI Fenster'));
- END;
-
- (* ------------------------------------------------------ *)
- (* Listing 4 *)
- (* ------------------------------------------------------ *)
-
- PROCEDURE TGDIFenster.WMLButtonDown(VAR Msg : tMessage);
- VAR
- EinDC : hDC ;
- R : tRect ;
- x, y : INTEGER ;
- i : WORD ;
- MyString : ARRAY [0..20] OF CHAR;
- OldFont, NewFont : hFont ;
- aLogFont : tLogFont ;
- BEGIN
- FOR i := 0 TO 199 DO BEGIN
- EinDC := GetDC(hWindow);
- GetClientRect(hWindow, R);
- WITH aLogFont DO BEGIN
- lfHeight := Random(30);
- lfWidth := Random(30);
- lfEscapement := 0;
- lfOrientation := 0;
- lfWeight := fw_Bold;
- lfItalic := 0;
- lfUnderline := 0;
- lfStrikeOut := 0;
- lfCharSet := ANSI_CharSet;
- lfOutPrecision := Out_Default_Precis;
- lfClipPrecision := Clip_Default_Precis;
- lfQuality := Default_Quality;
- lfPitchAndFamily := Variable_Pitch OR ff_Swiss;
- StrCopy(@lfFaceName, 'Helv');
- END;
- NewFont := CreateFontIndirect(ALogFont);
- OldFont := SelectObject(EinDC, NewFont);
- x := Random(R.Right);
- y := Random(R.Bottom);
- StrCopy(MyString, 'Windows, saustark !');
- SetTextColor(EinDC,
- RGB(Random(256), Random(256), Random(256)));
- SetBkColor(EinDC,
- RGB(Random(256), Random(256), Random(256)));
- TextOut(EinDC, x, y, MyString, StrLen(MyString));
- SelectObject(EinDC, OldFont) ;
- ReleaseDC(hWindow, EinDC);
- DeleteObject(NewFont);
- END;
- END;
-
- (* ------------------------------------------------------ *)
- (* Ende von Listing 4 *)
-
- PROCEDURE tGDIFenster.WMRButtonDown(VAR Msg : tMessage);
- BEGIN
- InvalidateRect(hWindow, NIL, TRUE);
- END;
-
- BEGIN
- MyApp.Init('MyApp');
- MyApp.Run;
- MyApp.Done;
- END.
- (* ------------------------------------------------------ *)
- (* Ende von LITTGDI4.PAS *)
-
-
-