![]() |
Konsolenanwendung, Schriftgröße ändern
Merkwürdig das Ganze ... ich kann auf einmal nicht mehr die Schriftgröße meiner eigenen Konsolenanwendung per API ändern. Die Anwendung selbst ist eine 32bit-Anwendung, das Windows ist ein 64bit-System - dennoch sollte dies möglich sein.
Ich habe mir folgende Dinge definiert ( ![]()
Delphi-Quellcode:
COORD = record
X, Y: smallint; end; TCONSOLE_FONT_INFOEX = record cbSize : cardinal; nFont : longword; dwFontSize : coord; FontFamily : cardinal; FontWeight : cardinal; FaceName : array[0..LF_FACESIZE-1] of WideChar; end; PCONSOLE_FONT_INFOEX = ^TCONSOLE_FONT_INFOEX; function SetCurrentConsoleFontEx( ConsoleOutput : THandle; MaximumWindow : BOOL; ConsoleInfo: PCONSOLE_FONT_INFOEX ) : BOOL; external kernel32 name 'SetCurrentConsoleFontEx'; function GetCurrentConsoleFontEx( ConsoleOutput : THandle; MaximumWindow : BOOL; ConsoleInfo: PCONSOLE_FONT_INFOEX ) : BOOL; external kernel32 name 'GetCurrentConsoleFontEx'; Und nun versuche ich Folgendes:
Delphi-Quellcode:
Mein Aufruf lautet dann
procedure SetConsoleFont( const AFontSize : word );
var ci : TCONSOLE_FONT_INFOEX; ch : THandle; begin if NOT CheckWin32Version( 6, 0 ) then EXIT; FillChar( ci, SizeOf(TCONSOLE_FONT_INFOEX), 0 ); ci.cbSize:= SizeOf(TCONSOLE_FONT_INFOEX); ch:= GetStdHandle( STD_OUTPUT_HANDLE ); if GetCurrentConsoleFontEx( ch, FALSE, @ci ) then begin ci.FontFamily:= FF_DONTCARE; //ci.FaceName:= 'Lucida Console'; ci.FaceName:= 'Consolas'; ci.dwFontSize.X:= 0; ci.dwFontSize.Y:= AFontSize; ci.FontWeight:= FW_BOLD; SetCurrentConsoleFontEx( ch, FALSE, @ci ); end else WriteLn( SysErrorMessage(GetLastError) ); end;
Delphi-Quellcode:
. In der Zeile, in der "GetCurrentConsoleFontEx" aufgerufen wird, knallt es mit einer Schutzverletzung. Jemand 'ne Idee, was das sein könnte?
SetConsoleFont( 32 );
|
AW: Konsolenanwendung, Schriftgröße ändern
Müssen WinAPI Funktionen nicht mit stdcall-Aufrufkonvention sein?
|
AW: Konsolenanwendung, Schriftgröße ändern
Ja müssen sie. :wall:
Das ist so deprimierend: Da müht man sich selbst eine gefühlte Ewigkeit ab - dann kommt wer anders vorbei, zuckt mit den Schultern, zeigt kurz mit dem Finger und sagt "Da hast Du die Aufrufkonvention vergessen" und schon klappt es. *gaaaa* Tausend Dank. :-) |
AW: Konsolenanwendung, Schriftgröße ändern
Und für einen leichten Delphitouch ginge es auch so:
Delphi-Quellcode:
type
TCONSOLE_FONT_INFOEX = record cbSize : Cardinal; nFont : LongWord; dwFontSize : TSmallPoint; FontFamily : Cardinal; FontWeight : Cardinal; FaceName : array[1..LF_FACESIZE] of WideChar; end; function SetCurrentConsoleFontEx( ConsoleOutput : THandle; MaximumWindow : BOOL; const ConsoleInfo: TCONSOLE_FONT_INFOEX ) : BOOL; stdcall; external kernel32; function GetCurrentConsoleFontEx( ConsoleOutput : THandle; MaximumWindow : BOOL; var ConsoleInfo: TCONSOLE_FONT_INFOEX ) : BOOL; stdcall; external kernel32; |
AW: Konsolenanwendung, Schriftgröße ändern
Cool. "TSmallPoint" kannte ich noch gar nicht, danke.
|
Alle Zeitangaben in WEZ +1. Es ist jetzt 21:58 Uhr. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024-2025 by Thomas Breitkreuz