mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-08-14 06:29:16 +02:00
* check console window size changes
This commit is contained in:
parent
d31e59b824
commit
e3eafe7a22
@ -34,7 +34,10 @@ procedure SystemEventHandler(var ir:INPUT_RECORD);
|
|||||||
e : TSystemEvent;
|
e : TSystemEvent;
|
||||||
|
|
||||||
begin
|
begin
|
||||||
if (ir.EventType in [FOCUS_EVENT,WINDOW_BUFFER_SIZE_EVENT]) then
|
{ WINDOW_BUFFER_SIZE_EVENT is triggered by buffer size changes
|
||||||
|
but we are interested in console size changes, thus its handled below
|
||||||
|
in PollSystemEvent }
|
||||||
|
if (ir.EventType in [FOCUS_EVENT{,WINDOW_BUFFER_SIZE_EVENT}]) then
|
||||||
begin
|
begin
|
||||||
EnterCriticalSection(ChangeSystemEvents);
|
EnterCriticalSection(ChangeSystemEvents);
|
||||||
if (ir.EventType=FOCUS_EVENT) then
|
if (ir.EventType=FOCUS_EVENT) then
|
||||||
@ -55,10 +58,15 @@ procedure SystemEventHandler(var ir:INPUT_RECORD);
|
|||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
|
var
|
||||||
|
Xsize, YSize : longint;
|
||||||
|
|
||||||
procedure InitSystemMsg;
|
procedure InitSystemMsg;
|
||||||
|
|
||||||
var
|
var
|
||||||
mode : dword;
|
mode : dword;
|
||||||
|
ConsoleScreenBufferInfo : Console_screen_buffer_info;
|
||||||
|
|
||||||
begin
|
begin
|
||||||
if SystemEventActive then
|
if SystemEventActive then
|
||||||
@ -67,7 +75,10 @@ begin
|
|||||||
GetConsoleMode(TextRec(Input).Handle,@mode);
|
GetConsoleMode(TextRec(Input).Handle,@mode);
|
||||||
mode:=mode or ENABLE_WINDOW_INPUT;
|
mode:=mode or ENABLE_WINDOW_INPUT;
|
||||||
SetConsoleMode(TextRec(Input).Handle,mode);
|
SetConsoleMode(TextRec(Input).Handle,mode);
|
||||||
|
GetConsoleScreenBufferInfo(GetStdHandle(STD_OUTPUT_HANDLE),
|
||||||
|
@ConsoleScreenBufferInfo);
|
||||||
|
XSize:=ConsoleScreenBufferInfo.srWindow.right-ConsoleScreenBufferInfo.srWindow.left+1;
|
||||||
|
YSize:=ConsoleScreenBufferInfo.srWindow.bottom-ConsoleScreenBufferInfo.srWindow.top+1;
|
||||||
PendingSystemHead:=@PendingSystemEvent;
|
PendingSystemHead:=@PendingSystemEvent;
|
||||||
PendingSystemTail:=@PendingSystemEvent;
|
PendingSystemTail:=@PendingSystemEvent;
|
||||||
PendingSystemEvents:=0;
|
PendingSystemEvents:=0;
|
||||||
@ -125,6 +136,9 @@ end;
|
|||||||
|
|
||||||
|
|
||||||
function PollSystemEvent(var SystemEvent: TSystemEvent):boolean;
|
function PollSystemEvent(var SystemEvent: TSystemEvent):boolean;
|
||||||
|
var
|
||||||
|
ConsoleScreenBufferInfo : Console_screen_buffer_info;
|
||||||
|
NewXSize, NewYSize : longint;
|
||||||
begin
|
begin
|
||||||
EnterCriticalSection(ChangeSystemEvents);
|
EnterCriticalSection(ChangeSystemEvents);
|
||||||
if PendingSystemEvents>0 then
|
if PendingSystemEvents>0 then
|
||||||
@ -132,14 +146,34 @@ begin
|
|||||||
SystemEvent:=PendingSystemHead^;
|
SystemEvent:=PendingSystemHead^;
|
||||||
PollSystemEvent:=true;
|
PollSystemEvent:=true;
|
||||||
end
|
end
|
||||||
|
else
|
||||||
|
begin
|
||||||
|
GetConsoleScreenBufferInfo(GetStdHandle(STD_OUTPUT_HANDLE),
|
||||||
|
@ConsoleScreenBufferInfo);
|
||||||
|
NewXSize:=ConsoleScreenBufferInfo.srWindow.right-ConsoleScreenBufferInfo.srWindow.left+1;
|
||||||
|
NewYSize:=ConsoleScreenBufferInfo.srWindow.bottom-ConsoleScreenBufferInfo.srWindow.top+1;
|
||||||
|
if (XSize<>NewXSize) or (YSize<>NewYSize) then
|
||||||
|
begin
|
||||||
|
SystemEvent.typ:=SysResize;
|
||||||
|
SystemEvent.x:=NewXSize;
|
||||||
|
SystemEvent.y:=NewYSize;
|
||||||
|
PutSystemEvent(SystemEvent);
|
||||||
|
XSize:=NewXSize;
|
||||||
|
YSize:=NewYSize;
|
||||||
|
PollSystemEvent:=true;
|
||||||
|
end
|
||||||
else
|
else
|
||||||
PollSystemEvent:=false;
|
PollSystemEvent:=false;
|
||||||
|
end;
|
||||||
LeaveCriticalSection(ChangeSystemEvents);
|
LeaveCriticalSection(ChangeSystemEvents);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
{
|
{
|
||||||
$Log$
|
$Log$
|
||||||
Revision 1.1 2002-05-21 11:59:57 pierre
|
Revision 1.2 2002-06-06 20:32:34 pierre
|
||||||
|
* check console window size changes
|
||||||
|
|
||||||
|
Revision 1.1 2002/05/21 11:59:57 pierre
|
||||||
+ system messages unit added
|
+ system messages unit added
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -34,7 +34,10 @@ procedure SystemEventHandler(var ir:INPUT_RECORD);
|
|||||||
e : TSystemEvent;
|
e : TSystemEvent;
|
||||||
|
|
||||||
begin
|
begin
|
||||||
if (ir.EventType in [FOCUS_EVENT,WINDOW_BUFFER_SIZE_EVENT]) then
|
{ WINDOW_BUFFER_SIZE_EVENT is triggered by buffer size changes
|
||||||
|
but we are interested in console size changes, thus its handled below
|
||||||
|
in PollSystemEvent }
|
||||||
|
if (ir.EventType in [FOCUS_EVENT{,WINDOW_BUFFER_SIZE_EVENT}]) then
|
||||||
begin
|
begin
|
||||||
EnterCriticalSection(ChangeSystemEvents);
|
EnterCriticalSection(ChangeSystemEvents);
|
||||||
if (ir.EventType=FOCUS_EVENT) then
|
if (ir.EventType=FOCUS_EVENT) then
|
||||||
@ -55,10 +58,15 @@ procedure SystemEventHandler(var ir:INPUT_RECORD);
|
|||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
|
var
|
||||||
|
Xsize, YSize : longint;
|
||||||
|
|
||||||
procedure InitSystemMsg;
|
procedure InitSystemMsg;
|
||||||
|
|
||||||
var
|
var
|
||||||
mode : dword;
|
mode : dword;
|
||||||
|
ConsoleScreenBufferInfo : Console_screen_buffer_info;
|
||||||
|
|
||||||
begin
|
begin
|
||||||
if SystemEventActive then
|
if SystemEventActive then
|
||||||
@ -67,7 +75,10 @@ begin
|
|||||||
GetConsoleMode(TextRec(Input).Handle,@mode);
|
GetConsoleMode(TextRec(Input).Handle,@mode);
|
||||||
mode:=mode or ENABLE_WINDOW_INPUT;
|
mode:=mode or ENABLE_WINDOW_INPUT;
|
||||||
SetConsoleMode(TextRec(Input).Handle,mode);
|
SetConsoleMode(TextRec(Input).Handle,mode);
|
||||||
|
GetConsoleScreenBufferInfo(GetStdHandle(STD_OUTPUT_HANDLE),
|
||||||
|
@ConsoleScreenBufferInfo);
|
||||||
|
XSize:=ConsoleScreenBufferInfo.srWindow.right-ConsoleScreenBufferInfo.srWindow.left+1;
|
||||||
|
YSize:=ConsoleScreenBufferInfo.srWindow.bottom-ConsoleScreenBufferInfo.srWindow.top+1;
|
||||||
PendingSystemHead:=@PendingSystemEvent;
|
PendingSystemHead:=@PendingSystemEvent;
|
||||||
PendingSystemTail:=@PendingSystemEvent;
|
PendingSystemTail:=@PendingSystemEvent;
|
||||||
PendingSystemEvents:=0;
|
PendingSystemEvents:=0;
|
||||||
@ -125,6 +136,9 @@ end;
|
|||||||
|
|
||||||
|
|
||||||
function PollSystemEvent(var SystemEvent: TSystemEvent):boolean;
|
function PollSystemEvent(var SystemEvent: TSystemEvent):boolean;
|
||||||
|
var
|
||||||
|
ConsoleScreenBufferInfo : Console_screen_buffer_info;
|
||||||
|
NewXSize, NewYSize : longint;
|
||||||
begin
|
begin
|
||||||
EnterCriticalSection(ChangeSystemEvents);
|
EnterCriticalSection(ChangeSystemEvents);
|
||||||
if PendingSystemEvents>0 then
|
if PendingSystemEvents>0 then
|
||||||
@ -132,14 +146,34 @@ begin
|
|||||||
SystemEvent:=PendingSystemHead^;
|
SystemEvent:=PendingSystemHead^;
|
||||||
PollSystemEvent:=true;
|
PollSystemEvent:=true;
|
||||||
end
|
end
|
||||||
|
else
|
||||||
|
begin
|
||||||
|
GetConsoleScreenBufferInfo(GetStdHandle(STD_OUTPUT_HANDLE),
|
||||||
|
@ConsoleScreenBufferInfo);
|
||||||
|
NewXSize:=ConsoleScreenBufferInfo.srWindow.right-ConsoleScreenBufferInfo.srWindow.left+1;
|
||||||
|
NewYSize:=ConsoleScreenBufferInfo.srWindow.bottom-ConsoleScreenBufferInfo.srWindow.top+1;
|
||||||
|
if (XSize<>NewXSize) or (YSize<>NewYSize) then
|
||||||
|
begin
|
||||||
|
SystemEvent.typ:=SysResize;
|
||||||
|
SystemEvent.x:=NewXSize;
|
||||||
|
SystemEvent.y:=NewYSize;
|
||||||
|
PutSystemEvent(SystemEvent);
|
||||||
|
XSize:=NewXSize;
|
||||||
|
YSize:=NewYSize;
|
||||||
|
PollSystemEvent:=true;
|
||||||
|
end
|
||||||
else
|
else
|
||||||
PollSystemEvent:=false;
|
PollSystemEvent:=false;
|
||||||
|
end;
|
||||||
LeaveCriticalSection(ChangeSystemEvents);
|
LeaveCriticalSection(ChangeSystemEvents);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
{
|
{
|
||||||
$Log$
|
$Log$
|
||||||
Revision 1.1 2002-05-21 11:59:57 pierre
|
Revision 1.2 2002-06-06 20:32:34 pierre
|
||||||
|
* check console window size changes
|
||||||
|
|
||||||
|
Revision 1.1 2002/05/21 11:59:57 pierre
|
||||||
+ system messages unit added
|
+ system messages unit added
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user