mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-09 09:16:13 +02:00
win32: formatting
git-svn-id: trunk@28590 -
This commit is contained in:
parent
d55955bd63
commit
b5d35d3037
@ -77,14 +77,14 @@ Type
|
|||||||
function WM_To_String(WM_Message: Integer): string;
|
function WM_To_String(WM_Message: Integer): string;
|
||||||
function WindowPosFlagsToString(Flags: UINT): string;
|
function WindowPosFlagsToString(Flags: UINT): string;
|
||||||
procedure EventTrace(Message: String; Data: TObject);
|
procedure EventTrace(Message: String; Data: TObject);
|
||||||
procedure AssertEx(Const Message: String; Const PassErr: Boolean;
|
procedure AssertEx(const Message: String; const PassErr: Boolean;
|
||||||
Const Severity: Byte);
|
const Severity: Byte);
|
||||||
procedure AssertEx(Const PassErr: Boolean; Const Message: String);
|
procedure AssertEx(const PassErr: Boolean; const Message: String);
|
||||||
procedure AssertEx(Const Message: String);
|
procedure AssertEx(const Message: String);
|
||||||
function GetShiftState: TShiftState;
|
function GetShiftState: TShiftState;
|
||||||
procedure CallEvent(Const Target: TObject; Event: TNotifyEvent;
|
procedure CallEvent(const Target: TObject; Event: TNotifyEvent;
|
||||||
Const Data: Pointer; Const EventType: TEventType);
|
const Data: Pointer; const EventType: TEventType);
|
||||||
function ObjectToHWND(Const AObject: TObject): HWND;
|
function ObjectToHWND(const AObject: TObject): HWND;
|
||||||
function LCLControlSizeNeedsUpdate(Sender: TWinControl;
|
function LCLControlSizeNeedsUpdate(Sender: TWinControl;
|
||||||
SendSizeMsgOnDiff: boolean): boolean;
|
SendSizeMsgOnDiff: boolean): boolean;
|
||||||
function GetLCLClientBoundsOffset(Sender: TObject; var ORect: TRect): boolean;
|
function GetLCLClientBoundsOffset(Sender: TObject; var ORect: TRect): boolean;
|
||||||
@ -535,9 +535,9 @@ end;
|
|||||||
------------------------------------------------------------------------------}
|
------------------------------------------------------------------------------}
|
||||||
procedure EventTrace(Message: String; Data: TObject);
|
procedure EventTrace(Message: String; Data: TObject);
|
||||||
begin
|
begin
|
||||||
If Data = Nil Then
|
if Data = nil then
|
||||||
Assert(False, Format('Trace:Event [%S] fired', [Message]))
|
Assert(False, Format('Trace:Event [%S] fired', [Message]))
|
||||||
Else
|
else
|
||||||
Assert(False, Format('Trace:Event [%S] fired for %S',[Message, Data.Classname]));
|
Assert(False, Format('Trace:Event [%S] fired for %S',[Message, Data.Classname]));
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -551,7 +551,7 @@ end;
|
|||||||
|
|
||||||
An expanded, better version of Assert
|
An expanded, better version of Assert
|
||||||
------------------------------------------------------------------------------}
|
------------------------------------------------------------------------------}
|
||||||
procedure AssertEx(Const Message: String; Const PassErr: Boolean; Const Severity: Byte);
|
procedure AssertEx(const Message: String; const PassErr: Boolean; const Severity: Byte);
|
||||||
begin
|
begin
|
||||||
Case Severity Of
|
Case Severity Of
|
||||||
0:
|
0:
|
||||||
@ -584,19 +584,19 @@ begin
|
|||||||
end;
|
end;
|
||||||
False:
|
False:
|
||||||
begin
|
begin
|
||||||
MessageBox(0, PChar(Message), Nil, MB_OK);
|
MessageBox(0, PChar(Message), nil, MB_OK);
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure AssertEx(Const PassErr: Boolean; Const Message: String);
|
procedure AssertEx(const PassErr: Boolean; const Message: String);
|
||||||
begin
|
begin
|
||||||
AssertEx(Message, PassErr, 0);
|
AssertEx(Message, PassErr, 0);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure AssertEx(Const Message: String);
|
procedure AssertEx(const Message: String);
|
||||||
begin
|
begin
|
||||||
AssertEx(Message, False, 0);
|
AssertEx(Message, False, 0);
|
||||||
end;
|
end;
|
||||||
@ -614,26 +614,26 @@ begin
|
|||||||
// NOTE: it may be better to use GetAsyncKeyState
|
// NOTE: it may be better to use GetAsyncKeyState
|
||||||
// if GetKeyState AND $8000 <> 0 then down (e.g. shift)
|
// if GetKeyState AND $8000 <> 0 then down (e.g. shift)
|
||||||
// if GetKeyState AND 1 <> 0, then toggled on (e.g. num lock)
|
// if GetKeyState AND 1 <> 0, then toggled on (e.g. num lock)
|
||||||
If (GetKeyState(VK_SHIFT) and $8000) <> 0 then
|
if (GetKeyState(VK_SHIFT) and $8000) <> 0 then
|
||||||
Result := Result + [ssShift];
|
Result := Result + [ssShift];
|
||||||
If (GetKeyState(VK_CAPITAL) and 1) <> 0 then
|
if (GetKeyState(VK_CAPITAL) and 1) <> 0 then
|
||||||
Result := Result + [ssCaps];
|
Result := Result + [ssCaps];
|
||||||
If (GetKeyState(VK_CONTROL) and $8000) <> 0 then
|
if (GetKeyState(VK_CONTROL) and $8000) <> 0 then
|
||||||
Result := Result + [ssCtrl];
|
Result := Result + [ssCtrl];
|
||||||
If (GetKeyState(VK_MENU) and $8000) <> 0 then
|
if (GetKeyState(VK_MENU) and $8000) <> 0 then
|
||||||
Result := Result + [ssAlt];
|
Result := Result + [ssAlt];
|
||||||
If (GetKeyState(VK_NUMLOCK) and 1) <> 0 then
|
if (GetKeyState(VK_NUMLOCK) and 1) <> 0 then
|
||||||
Result := Result + [ssNum];
|
Result := Result + [ssNum];
|
||||||
//TODO: ssSuper
|
//TODO: ssSuper
|
||||||
If (GetKeyState(VK_SCROLL) and 1) <> 0 then
|
if (GetKeyState(VK_SCROLL) and 1) <> 0 then
|
||||||
Result := Result + [ssScroll];
|
Result := Result + [ssScroll];
|
||||||
// GetKeyState takes mouse button swap into account (GetAsyncKeyState doesn't),
|
// GetKeyState takes mouse button swap into account (GetAsyncKeyState doesn't),
|
||||||
// so no need to test GetSystemMetrics(SM_SWAPBUTTON)
|
// so no need to test GetSystemMetrics(SM_SWAPBUTTON)
|
||||||
If (GetKeyState(VK_LBUTTON) and $8000) <> 0 then
|
if (GetKeyState(VK_LBUTTON) and $8000) <> 0 then
|
||||||
Result := Result + [ssLeft];
|
Result := Result + [ssLeft];
|
||||||
If (GetKeyState(VK_MBUTTON) and $8000) <> 0 then
|
if (GetKeyState(VK_MBUTTON) and $8000) <> 0 then
|
||||||
Result := Result + [ssMiddle];
|
Result := Result + [ssMiddle];
|
||||||
If (GetKeyState(VK_RBUTTON) and $8000) <> 0 then
|
if (GetKeyState(VK_RBUTTON) and $8000) <> 0 then
|
||||||
Result := Result + [ssRight];
|
Result := Result + [ssRight];
|
||||||
//TODO: ssAltGr
|
//TODO: ssAltGr
|
||||||
end;
|
end;
|
||||||
@ -643,16 +643,16 @@ end;
|
|||||||
Params: Event - Requested info
|
Params: Event - Requested info
|
||||||
KeyCode - the ASCII key code of the eventkey
|
KeyCode - the ASCII key code of the eventkey
|
||||||
VirtualKey - the virtual key code of the eventkey
|
VirtualKey - the virtual key code of the eventkey
|
||||||
SysKey - True If the key is a syskey
|
SysKey - True if the key is a syskey
|
||||||
ExtEnded - True If the key is an extended key
|
ExtEnded - True if the key is an extended key
|
||||||
Toggle - True If the key is a toggle key and its value is on
|
Toggle - True if the key is a toggle key and its value is on
|
||||||
Returns: Nothing
|
Returns: Nothing
|
||||||
|
|
||||||
GetWin32KeyInfo returns information about the given key event
|
GetWin32KeyInfo returns information about the given key event
|
||||||
------------------------------------------------------------------------------}
|
------------------------------------------------------------------------------}
|
||||||
{
|
{
|
||||||
procedure GetWin32KeyInfo(const Event: Integer; var KeyCode, VirtualKey: Integer; var SysKey, Extended, Toggle: Boolean);
|
procedure GetWin32KeyInfo(const Event: Integer; var KeyCode, VirtualKey: Integer; var SysKey, Extended, Toggle: Boolean);
|
||||||
Const
|
const
|
||||||
MVK_UNIFY_SIDES = 1;
|
MVK_UNIFY_SIDES = 1;
|
||||||
begin
|
begin
|
||||||
Assert(False, 'TRACE:Using function GetWin32KeyInfo which isn''t implemented yet');
|
Assert(False, 'TRACE:Using function GetWin32KeyInfo which isn''t implemented yet');
|
||||||
@ -674,9 +674,9 @@ end;
|
|||||||
|
|
||||||
Calls an event
|
Calls an event
|
||||||
-------------------------------------------------------------------------------}
|
-------------------------------------------------------------------------------}
|
||||||
procedure CallEvent(Const Target: TObject; Event: TNotifyEvent; Const Data: Pointer; Const EventType: TEventType);
|
procedure CallEvent(const Target: TObject; Event: TNotifyEvent; const Data: Pointer; const EventType: TEventType);
|
||||||
begin
|
begin
|
||||||
If Assigned(Target) And Assigned(Event) Then
|
if Assigned(Target) And Assigned(Event) then
|
||||||
begin
|
begin
|
||||||
Case EventType Of
|
Case EventType Of
|
||||||
etNotify:
|
etNotify:
|
||||||
@ -694,42 +694,43 @@ end;
|
|||||||
|
|
||||||
Returns the Window handle of the given object, 0 if no object available
|
Returns the Window handle of the given object, 0 if no object available
|
||||||
------------------------------------------------------------------------------}
|
------------------------------------------------------------------------------}
|
||||||
function ObjectToHWND(Const AObject: TObject): HWND;
|
function ObjectToHWND(const AObject: TObject): HWND;
|
||||||
Var
|
var
|
||||||
Handle: HWND;
|
Handle: HWND;
|
||||||
begin
|
begin
|
||||||
Handle:=0;
|
Handle := 0;
|
||||||
If not assigned(AObject) Then
|
if not assigned(AObject) then
|
||||||
|
Assert (False, 'TRACE:[ObjectToHWND] Object not assigned')
|
||||||
|
else
|
||||||
|
if (AObject is TWinControl) then
|
||||||
begin
|
begin
|
||||||
Assert (False, 'TRACE:[ObjectToHWND] Object not assigned');
|
if TWinControl(AObject).HandleAllocated then
|
||||||
End
|
|
||||||
Else If (AObject Is TWinControl) Then
|
|
||||||
begin
|
|
||||||
If TWinControl(AObject).HandleAllocated Then
|
|
||||||
Handle := TWinControl(AObject).Handle
|
Handle := TWinControl(AObject).Handle
|
||||||
End
|
end
|
||||||
Else If (AObject Is TMenuItem) Then
|
else
|
||||||
|
if (AObject is TMenuItem) then
|
||||||
begin
|
begin
|
||||||
If TMenuItem(AObject).HandleAllocated Then
|
if TMenuItem(AObject).HandleAllocated then
|
||||||
Handle := TMenuItem(AObject).Handle
|
Handle := TMenuItem(AObject).Handle
|
||||||
End
|
end
|
||||||
Else If (AObject Is TMenu) Then
|
else
|
||||||
|
if (AObject is TMenu) then
|
||||||
begin
|
begin
|
||||||
If TMenu(AObject).HandleAllocated Then
|
if TMenu(AObject).HandleAllocated then
|
||||||
Handle := TMenu(AObject).Items.Handle
|
Handle := TMenu(AObject).Items.Handle
|
||||||
End
|
end
|
||||||
Else If (AObject Is TCommonDialog) Then
|
else
|
||||||
|
if (AObject is TCommonDialog) then
|
||||||
begin
|
begin
|
||||||
{If TCommonDialog(AObject).HandleAllocated Then }
|
{if TCommonDialog(AObject).HandleAllocated then }
|
||||||
Handle := TCommonDialog(AObject).Handle
|
Handle := TCommonDialog(AObject).Handle
|
||||||
End
|
end
|
||||||
Else
|
else
|
||||||
begin
|
|
||||||
Assert(False, Format('Trace:[ObjectToHWND] Message received With unhandled class-type <%s>', [AObject.ClassName]));
|
Assert(False, Format('Trace:[ObjectToHWND] Message received With unhandled class-type <%s>', [AObject.ClassName]));
|
||||||
end;
|
|
||||||
Result := Handle;
|
Result := Handle;
|
||||||
If Handle = 0 Then
|
if Handle = 0 then
|
||||||
Assert (False, 'Trace:[ObjectToHWND]****** Warning: handle = 0 *******');
|
Assert(False, 'Trace:[ObjectToHWND]****** Warning: handle = 0 *******');
|
||||||
end;
|
end;
|
||||||
|
|
||||||
(***********************************************************************
|
(***********************************************************************
|
||||||
@ -890,7 +891,7 @@ end;
|
|||||||
The new style is the Style parameter.
|
The new style is the Style parameter.
|
||||||
Only the bits set in the StyleMask are changed,
|
Only the bits set in the StyleMask are changed,
|
||||||
the other bits remain untouched.
|
the other bits remain untouched.
|
||||||
If the bits in the StyleMask are not used in the Style,
|
if the bits in the StyleMask are not used in the Style,
|
||||||
there are cleared.
|
there are cleared.
|
||||||
}
|
}
|
||||||
procedure UpdateWindowStyle(Handle: HWnd; Style: integer; StyleMask: integer);
|
procedure UpdateWindowStyle(Handle: HWnd; Style: integer; StyleMask: integer);
|
||||||
@ -1113,8 +1114,8 @@ begin
|
|||||||
begin
|
begin
|
||||||
TextLen := Windows.GetWindowTextLengthW(AHandle);
|
TextLen := Windows.GetWindowTextLengthW(AHandle);
|
||||||
SetLength(WideBuffer, TextLen);
|
SetLength(WideBuffer, TextLen);
|
||||||
If TextLen > 0 // Never give Windows the chance to write to System.emptychar
|
if TextLen > 0 // Never give Windows the chance to write to System.emptychar
|
||||||
Then TextLen := Windows.GetWindowTextW(AHandle, PWideChar(WideBuffer), TextLen + 1);
|
then TextLen := Windows.GetWindowTextW(AHandle, PWideChar(WideBuffer), TextLen + 1);
|
||||||
SetLength(WideBuffer, TextLen);
|
SetLength(WideBuffer, TextLen);
|
||||||
Result := UTF16ToUTF8(WideBuffer);
|
Result := UTF16ToUTF8(WideBuffer);
|
||||||
end
|
end
|
||||||
@ -1122,8 +1123,8 @@ begin
|
|||||||
begin
|
begin
|
||||||
TextLen := Windows.GetWindowTextLength(AHandle);
|
TextLen := Windows.GetWindowTextLength(AHandle);
|
||||||
SetLength(AnsiBuffer, TextLen);
|
SetLength(AnsiBuffer, TextLen);
|
||||||
If TextLen > 0 // Never give Windows the chance to write to System.emptychar
|
if TextLen > 0 // Never give Windows the chance to write to System.emptychar
|
||||||
Then TextLen := Windows.GetWindowText(AHandle, PChar(AnsiBuffer), TextLen + 1);
|
then TextLen := Windows.GetWindowText(AHandle, PChar(AnsiBuffer), TextLen + 1);
|
||||||
SetLength(AnsiBuffer, TextLen);
|
SetLength(AnsiBuffer, TextLen);
|
||||||
Result := AnsiToUtf8(AnsiBuffer);
|
Result := AnsiToUtf8(AnsiBuffer);
|
||||||
end;
|
end;
|
||||||
|
Loading…
Reference in New Issue
Block a user