Jeff
06.04.2005, 21:52
Hallo!
Ich und noch ein Freund machen derzeit ein Projekt in der Schule (ein Spiel) dort brauchen wir einige WinAPI-Funktionen zum Zeichnen, weil das dort eingesetzte System (Oberon V4) selbst ziemlich wenig kann.
Bis jetzt ging alles gut, aber bei dieser Funktion verzweifle ich langsam:
PROCEDURE DrawText*(Auf: LONGINT; x,y : LONGINT; s: ARRAY OF CHAR;
length: LONGINT; TextColour: LONGINT);
(* Schreibt einen String auf ein Bitmap *)
VAR result : LONGINT;
bres: BOOLEAN;
hdc, hdcMemAuf : LONGINT;
hfnt, OldColour: LONGINT;
BEGIN
(* Verweis auf Display *)
hdc := Win32.hdcDisp;
(* erstellt ein kompartibles Gerätekontext *)
hdcMemAuf := CreateCompatibleDC(hdc);
(* Bindet die Bitmaps in Gerätekontexte *)
result := SelectObject(hdcMemAuf,Auf);
SetBkMode(hdcMemAuf, TRANSPARENT);
hfnt := CreateFont(
20, (*Height *)
8, (* average Char Width *)
0, (* angle of escapement *)
0, (* base-line orientation angle *)
700, (* FW_NORMAL, 400=normal, 700=bold *) (* font weight *)
0, (* italic attribute option *)
0, (* underline attribute option *)
0, (* strikeout attribute option *)
0, (* ANSI_CHARSET, character set identifier *)
0, (* OUT_DEFAULT_PRECIS, output precision *)
0, (* CLIP_DEFAULT_PRECIS, clipping precision *)
0, (* DEFAULT_QUALITY, output quality *)
0, (* DEFAULT_PITCH | FF_ROMAN, *) (* pitch and family *)
"Times New Roman"); (* typeface name *)
result := SelectObject(hdcMemAuf, hfnt);
OldColour := SetTextColor( hdcMemAuf, TextColour);
bres := TextOut(hdcMemAuf, x, y, s, length);
result := SetTextColor( hdc, OldColour);
bres:=DeleteObject(hfnt);
DeleteDC(hdcMemAuf);
END DrawText;
Die Funktion habe ich natürlich selbst geschrieben. Problem: es funktioniert zwar alles soweit... nur es wird immer der gesamte Inhalt des STRINGs ausgegeben, inklusive dem letzten abschließenden Zeichen (wird als Rechteck angezeigt)
Der letzte Parameter der TextOut() wird einfach ignoriert...
Was mache ich falsch? Kann mir jemand helfen?
Danke schon mal im Voraus!
Ich und noch ein Freund machen derzeit ein Projekt in der Schule (ein Spiel) dort brauchen wir einige WinAPI-Funktionen zum Zeichnen, weil das dort eingesetzte System (Oberon V4) selbst ziemlich wenig kann.
Bis jetzt ging alles gut, aber bei dieser Funktion verzweifle ich langsam:
PROCEDURE DrawText*(Auf: LONGINT; x,y : LONGINT; s: ARRAY OF CHAR;
length: LONGINT; TextColour: LONGINT);
(* Schreibt einen String auf ein Bitmap *)
VAR result : LONGINT;
bres: BOOLEAN;
hdc, hdcMemAuf : LONGINT;
hfnt, OldColour: LONGINT;
BEGIN
(* Verweis auf Display *)
hdc := Win32.hdcDisp;
(* erstellt ein kompartibles Gerätekontext *)
hdcMemAuf := CreateCompatibleDC(hdc);
(* Bindet die Bitmaps in Gerätekontexte *)
result := SelectObject(hdcMemAuf,Auf);
SetBkMode(hdcMemAuf, TRANSPARENT);
hfnt := CreateFont(
20, (*Height *)
8, (* average Char Width *)
0, (* angle of escapement *)
0, (* base-line orientation angle *)
700, (* FW_NORMAL, 400=normal, 700=bold *) (* font weight *)
0, (* italic attribute option *)
0, (* underline attribute option *)
0, (* strikeout attribute option *)
0, (* ANSI_CHARSET, character set identifier *)
0, (* OUT_DEFAULT_PRECIS, output precision *)
0, (* CLIP_DEFAULT_PRECIS, clipping precision *)
0, (* DEFAULT_QUALITY, output quality *)
0, (* DEFAULT_PITCH | FF_ROMAN, *) (* pitch and family *)
"Times New Roman"); (* typeface name *)
result := SelectObject(hdcMemAuf, hfnt);
OldColour := SetTextColor( hdcMemAuf, TextColour);
bres := TextOut(hdcMemAuf, x, y, s, length);
result := SetTextColor( hdc, OldColour);
bres:=DeleteObject(hfnt);
DeleteDC(hdcMemAuf);
END DrawText;
Die Funktion habe ich natürlich selbst geschrieben. Problem: es funktioniert zwar alles soweit... nur es wird immer der gesamte Inhalt des STRINGs ausgegeben, inklusive dem letzten abschließenden Zeichen (wird als Rechteck angezeigt)
Der letzte Parameter der TextOut() wird einfach ignoriert...
Was mache ich falsch? Kann mir jemand helfen?
Danke schon mal im Voraus!