/usr/src/castle-game-engine-4.1.1/base/windows/castleutils_os_specific_windows.inc is in castle-game-engine-src 4.1.1-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 | {
Copyright 2000-2013 Michalis Kamburelis.
This file is part of "Castle Game Engine".
"Castle Game Engine" is free software; see the file COPYING.txt,
included in this distribution, for details about the copyright.
"Castle Game Engine" is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
----------------------------------------------------------------------------
}
{ Some WinAPI helpers }
{$ifdef read_interface}
const
KernelDLL = 'kernel32.dll';
UserDLL = 'user32.dll';
GdiDLL = 'gdi32.dll';
ShellDLL = 'shell32.dll';
{ Simple standard Windows message boxes.
If Parent is 0 (default), the box will be a modal box for the whole process
(all our windows), since we use MB_TASKMODAL.
@deprecated Deprecated. Instead of these it's much better to use:
- TCastleWindowBase.MessageOK, TCastleWindowBase.MessageYesNo if you use
CastleWindow.
- or LCL dialog routines (like ShowMessage and everything in Dialogs unit)
if you use LCL.
@groupBegin }
procedure ErrorBox (const Text:string; const caption:string ='Error' ; parent:HWND =0); deprecated;
procedure InfoBox (const Text:string; const caption:string ='Information'; parent:HWND =0); deprecated;
procedure WarningBox(const Text:string; const caption:string ='Warning' ; parent:HWND =0); deprecated;
{ @groupEnd }
type
{ Handling WMSizing message is a way to force minimum/maximum form
sizes under WinAPI. }
TWMSizing=record
Msg: Cardinal; {< wm_SIZING }
fwSide: Longint; {< const WMSZ_xxx }
lprc: PRect; {< rectangle with window sizes }
Result: LongBool; {< should return longbool(true) }
end;
function WMSizingHandler(lParm:LPARAM; wParm:WPARAM; minWidth,minHeight, maxWidth,maxHeight:integer):LRESULT; overload;
procedure WMSizingHandler(var Msg:TWMSizing; minWidth,minHeight, maxWidth,maxHeight:integer); overload;
procedure WMSizingHandler(var Msg:TWMSizing; minWidth,minHeight:integer); overload;
{ WinAPI ChangeDisplaySettings declaration. (Was wrong/missing in old
FPC versions? TODO: check and probably remove this.) }
function ChangeDisplaySettings(lpDevMode:PDEVMODE; dwFlags:DWORD):longint;
stdcall; external userDLL name 'ChangeDisplaySettingsA';
{ Describe ChangeDisplaySettings result. }
function DispChangeToStr(L: LongInt): string;
{$endif read_interface}
{$ifdef read_implementation}
procedure ErrorBox(const Text:string; const caption:string; parent:HWND);
begin
MessageBox(parent,PChar(Text),PChar(caption),MB_OK or MB_ICONERROR or MB_TASKMODAL);
end;
procedure InfoBox(const Text:string; const caption:string;parent:HWND);
begin
MessageBox(parent,PChar(Text),PChar(caption),MB_OK or MB_ICONINFORMATION or MB_TASKMODAL);
end;
procedure WarningBox(const Text:string; const caption:string;parent:HWND);
begin
MessageBox(parent,PChar(Text),PChar(caption),MB_OK or MB_ICONWARNING or MB_TASKMODAL);
end;
{ minX / minY / maxX / maxY : WM_SIZING handler -----------------------------
Dodaj do formularza proc.
procedure WMSizing(var Msg:TWMSizing); message wm_Sizing;
i zapisz ja jako
procedure TForm1.WMSizing(var Msg:TWMSizing);
begin
WMSizingHandler(msg,100,200, 400,400);
end;
gdzie liczby 100 i 200 sa przykladowe. Otrzymasz formularz ktory nie moze byc resizowany
do rozmiartu mniejszego od 100 x 200 ani wiekszego niz 400x400.
Uwaga 1 : to nie ma wplywu na rozmiar formularza po "maximize" przez usera -
- user moze tym maximizem przekroczyc maxy lub miny (jesli ustawiles miny
na wieksze niz rozmiar ekranu...); jesli chcesz miec pewnosc, wylacz userowi
mozliwosc maximize'a
2 : to nie ma wplywu na rozmiar formularza jaki sam nadajesz (programowo).
Ustaw wiec dobre wartosci poczatkowe i nie ustawiaj sam zlych rozmiarow
formularzowi.
}
function WMSizingHandler(lParm:LPARAM; wParm:WPARAM; minWidth,minHeight, maxWidth,maxHeight:integer):LRESULT;
var msg:TWMSizing;
begin
msg.Msg:=WM_SIZING;
msg.fwSide:=wParm;
msg.lprc:=PRect(lParm);
WMSizingHandler(msg, minWidth,minHeight, maxWidth,maxHeight);
result:=LRESULT(msg.Result);
end;
procedure WMSizingHandler(var Msg:TWMSizing; minWidth,minHeight, maxWidth,maxHeight:integer); overload;
var w,h:integer;
begin
assert(minWidth<=maxWidth);
assert(minHeight<=maxHeight);
with msg.lprc^ do
begin
w:=right-left;
if w<minWidth then right:=left+minWidth else
if w>maxWidth then right:=left+maxWidth;
h:=bottom-top;
if h<minHeight then bottom:=top+minHeight else
if h>maxHeight then bottom:=top+maxHeight;
end;
msg.result:=true;
end;
procedure WMSizingHandler(var Msg:TWMSizing; minWidth,minHeight :integer);
begin
with msg.lprc^ do
begin
if right-left<minWidth then right:=left+minWidth;
if bottom-top<minHeight then bottom:=top+minHeight;
end;
msg.result:=true;
end;
function DispChangeToStr(L: LongInt): string;
begin
case L of
DISP_CHANGE_SUCCESSFUL: Result := 'DISP_CHANGE_SUCCESSFUL';
DISP_CHANGE_RESTART: Result := 'DISP_CHANGE_RESTART';
DISP_CHANGE_BADFLAGS: Result := 'DISP_CHANGE_BADFLAGS';
DISP_CHANGE_FAILED: Result := 'DISP_CHANGE_FAILED';
DISP_CHANGE_BADMODE: Result := 'DISP_CHANGE_BADMODE';
DISP_CHANGE_NOTUPDATED: Result := 'DISP_CHANGE_NOTUPDATED';
else Result := IntToStr(L);
end;
end;
procedure InitializationOSSpecific;
begin
end;
procedure FinalizationOSSpecific;
begin
end;
{$endif read_implementation}
|