디버깅용 콘솔창 띄우기
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls;
type
TForm1 = class(TForm) procedure FormCreate(Sender: TObject);
procedure FormDestroy(Sender: TObject);
procedure FormMouseMove(Sender: TObject; Shift: TShiftState; X, Y: Integer);
private
{ Private declarations }
ConHwnd: THANDLE;
public
{ Public declarations }
procedure ConsoleLoad();
procedure ConsoleWriteLn(Str: string);
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.ConsoleLoad();
var
Chars : DWORD;
SBSize : _COORD;
begin
ConHwnd := CreateConsoleScreenBuffer(GENERIC_WRITE, FILE_SHARE_WRITE, nil,
CONSOLE_TEXTMODE_BUFFER, nil );
SBSize.X := 80; SBSize.Y := 1000; SetConsoleScreenBufferSize(ConHwnd, SBSize);
SetConsoleActiveScreenBuffer(ConHwnd);
end;
procedure TForm1.ConsoleWriteLn(Str: string);
var
Chars : DWORD;
begin
SetConsoleTextAttribute(ConHwnd , 10);
Str := Str + #13#10;
WriteConsole(ConHwnd, @Str[1], Length(Str), Chars, nil);
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
AllocConsole();
ConsoleLoad();
end;
procedure TForm1.FormDestroy(Sender: TObject);
begin
FreeConsole();
end;
procedure TForm1.FormMouseMove(Sender: TObject; Shift: TShiftState; X, Y: Integer);
var
Str : string;
begin
Str := 'X:' + IntToStr(X) + ' Y:' + IntToStr(Y); ConsoleWriteLn(Str);
end;
end.
'Delphi Tip > +Tip' 카테고리의 다른 글
하위폼 종료 감지 (0) | 2024.03.04 |
---|---|
폼 Border 없이 사이즈 변경 (0) | 2024.02.01 |
마우스커서가 폼(Form)안에 있는지 여부 (0) | 2024.01.08 |
프로그램에서 DOS 명령어 처리 (0) | 2023.12.29 |
델파이 디버깅용 콘솔창 만들기 (0) | 2023.12.11 |
댓글