mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-09-17 04:20:41 +02:00
LCL, Win32: Refactor SetLMCharData and SetLMKeyData out of WindowProc methods and use them.
git-svn-id: trunk@47467 -
This commit is contained in:
parent
aba5217ea1
commit
7471283862
@ -426,6 +426,8 @@ type
|
|||||||
procedure DoSysCmdRestore;
|
procedure DoSysCmdRestore;
|
||||||
function GetPopMenuItemObject: TObject;
|
function GetPopMenuItemObject: TObject;
|
||||||
function GetMenuItemObject(ByPosition: Boolean): TObject;
|
function GetMenuItemObject(ByPosition: Boolean): TObject;
|
||||||
|
procedure SetLMCharData(aMsg: Cardinal; UpdateKeyData: Boolean = False);
|
||||||
|
procedure SetLMKeyData(aMsg: Cardinal; UpdateKeyData: Boolean = False);
|
||||||
procedure SetLMessageAndParams(aMsg: Cardinal; ResetWinProcess: Boolean = False);
|
procedure SetLMessageAndParams(aMsg: Cardinal; ResetWinProcess: Boolean = False);
|
||||||
procedure SendPaintMessage(ControlDC: HDC);
|
procedure SendPaintMessage(ControlDC: HDC);
|
||||||
procedure HandleScrollMessage(LMsg: integer);
|
procedure HandleScrollMessage(LMsg: integer);
|
||||||
@ -454,6 +456,22 @@ begin
|
|||||||
inherited Destroy;
|
inherited Destroy;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure TWindowProcHelper.SetLMCharData(aMsg: Cardinal; UpdateKeyData: Boolean);
|
||||||
|
begin
|
||||||
|
LMChar.Msg := aMsg;
|
||||||
|
LMChar.CharCode := Word(WParam);
|
||||||
|
if UpdateKeyData then
|
||||||
|
LMChar.KeyData := LParam;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TWindowProcHelper.SetLMKeyData(aMsg: Cardinal; UpdateKeyData: Boolean);
|
||||||
|
begin
|
||||||
|
LMKey.Msg := aMsg;
|
||||||
|
LMKey.CharCode := Word(WParam);
|
||||||
|
if UpdateKeyData then
|
||||||
|
LMKey.KeyData := LParam;
|
||||||
|
end;
|
||||||
|
|
||||||
procedure TWindowProcHelper.SetLMessageAndParams(aMsg: Cardinal; ResetWinProcess: Boolean);
|
procedure TWindowProcHelper.SetLMessageAndParams(aMsg: Cardinal; ResetWinProcess: Boolean);
|
||||||
begin
|
begin
|
||||||
LMessage.Msg := aMsg;
|
LMessage.Msg := aMsg;
|
||||||
@ -1248,7 +1266,7 @@ begin
|
|||||||
else
|
else
|
||||||
WParam := OrgCharCode;
|
WParam := OrgCharCode;
|
||||||
{$else}
|
{$else}
|
||||||
PLMsg:=@LMChar;
|
PLMsg := @LMChar;
|
||||||
with LMChar do
|
with LMChar do
|
||||||
begin
|
begin
|
||||||
Msg := CN_CHAR;
|
Msg := CN_CHAR;
|
||||||
@ -1541,13 +1559,8 @@ begin
|
|||||||
NotifyUserInput := True;
|
NotifyUserInput := True;
|
||||||
PLMsg := @LMKey;
|
PLMsg := @LMKey;
|
||||||
UpdateUIState(Word(WParam));
|
UpdateUIState(Word(WParam));
|
||||||
with LMKey Do
|
SetLMKeyData(aMsg, True);
|
||||||
begin
|
WinResult := 0;
|
||||||
Msg := aMsg;
|
|
||||||
KeyData := LParam;
|
|
||||||
CharCode := Word(WParam);
|
|
||||||
WinResult := 0;
|
|
||||||
end;
|
|
||||||
WinProcess := false;
|
WinProcess := false;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -1794,12 +1807,7 @@ procedure TWindowProcHelper.DoMsgSysKey(aMsg: Cardinal);
|
|||||||
begin
|
begin
|
||||||
NotifyUserInput := True;
|
NotifyUserInput := True;
|
||||||
PLMsg := @LMKey;
|
PLMsg := @LMKey;
|
||||||
with LMKey Do
|
SetLMKeyData(aMsg, True);
|
||||||
begin
|
|
||||||
Msg := aMsg;
|
|
||||||
KeyData := LParam;
|
|
||||||
CharCode := Word(WParam);
|
|
||||||
end;
|
|
||||||
WinProcess := false;
|
WinProcess := false;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -2280,12 +2288,7 @@ begin
|
|||||||
WM_SYSCHAR:
|
WM_SYSCHAR:
|
||||||
begin
|
begin
|
||||||
PLMsg := @LMChar;
|
PLMsg := @LMChar;
|
||||||
with LMChar Do
|
SetLMCharData(CN_SYSCHAR, True);
|
||||||
begin
|
|
||||||
Msg := CN_SYSCHAR;
|
|
||||||
KeyData := LParam;
|
|
||||||
CharCode := Word(WParam);
|
|
||||||
end;
|
|
||||||
Result := 0;
|
Result := 0;
|
||||||
WinProcess := false;
|
WinProcess := false;
|
||||||
end;
|
end;
|
||||||
@ -2426,7 +2429,7 @@ begin
|
|||||||
LMessage.Result := 0;
|
LMessage.Result := 0;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
end;
|
end; // case Msg of
|
||||||
|
|
||||||
// convert from win32 client to lcl client pos.
|
// convert from win32 client to lcl client pos.
|
||||||
//
|
//
|
||||||
@ -2467,14 +2470,11 @@ begin
|
|||||||
// respond to result of LCL handling the message
|
// respond to result of LCL handling the message
|
||||||
case PLMsg^.Msg of
|
case PLMsg^.Msg of
|
||||||
LM_ERASEBKGND, LM_SETCURSOR, LM_RBUTTONUP, LM_CONTEXTMENU, LM_MOUSEWHEEL:
|
LM_ERASEBKGND, LM_SETCURSOR, LM_RBUTTONUP, LM_CONTEXTMENU, LM_MOUSEWHEEL:
|
||||||
begin
|
|
||||||
if PLMsg^.Result = 0 then
|
if PLMsg^.Result = 0 then
|
||||||
WinProcess := True;
|
WinProcess := True;
|
||||||
end;
|
|
||||||
WM_SYSCOMMAND:
|
WM_SYSCOMMAND:
|
||||||
begin
|
|
||||||
WinProcess := WmSysCommandProcess;
|
WinProcess := WmSysCommandProcess;
|
||||||
end;
|
|
||||||
|
|
||||||
CN_CHAR, CN_SYSCHAR:
|
CN_CHAR, CN_SYSCHAR:
|
||||||
begin
|
begin
|
||||||
@ -2548,34 +2548,13 @@ begin
|
|||||||
begin
|
begin
|
||||||
// if want chars, then handled already
|
// if want chars, then handled already
|
||||||
PLMsg^.Result := CallDefaultWindowProc(Window, WM_GETDLGCODE, 0, 0) and DLGC_WANTCHARS;
|
PLMsg^.Result := CallDefaultWindowProc(Window, WM_GETDLGCODE, 0, 0) and DLGC_WANTCHARS;
|
||||||
LMChar.CharCode := Word(WParam);
|
SetLMCharData(LM_CHAR);
|
||||||
LMChar.Msg := LM_CHAR;
|
|
||||||
end;
|
|
||||||
WM_SYSCHAR:
|
|
||||||
begin
|
|
||||||
LMChar.CharCode := Word(WParam);
|
|
||||||
LMChar.Msg := LM_SYSCHAR;
|
|
||||||
end;
|
|
||||||
WM_KEYDOWN:
|
|
||||||
begin
|
|
||||||
LMKey.CharCode := Word(WParam);
|
|
||||||
LMKey.Msg := LM_KEYDOWN;
|
|
||||||
end;
|
|
||||||
WM_KEYUP:
|
|
||||||
begin
|
|
||||||
LMKey.CharCode := Word(WParam);
|
|
||||||
LMKey.Msg := LM_KEYUP;
|
|
||||||
end;
|
|
||||||
WM_SYSKEYDOWN:
|
|
||||||
begin
|
|
||||||
LMKey.CharCode := Word(WParam);
|
|
||||||
LMKey.Msg := LM_SYSKEYDOWN;
|
|
||||||
end;
|
|
||||||
WM_SYSKEYUP:
|
|
||||||
begin
|
|
||||||
LMKey.CharCode := Word(WParam);
|
|
||||||
LMKey.Msg := LM_SYSKEYUP;
|
|
||||||
end;
|
end;
|
||||||
|
WM_SYSCHAR: SetLMCharData(LM_SYSCHAR);
|
||||||
|
WM_KEYDOWN: SetLMKeyData(LM_KEYDOWN);
|
||||||
|
WM_KEYUP: SetLMKeyData(LM_KEYUP);
|
||||||
|
WM_SYSKEYDOWN: SetLMKeyData(LM_SYSKEYDOWN);
|
||||||
|
WM_SYSKEYUP: SetLMKeyData(LM_SYSKEYUP);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
case Msg of
|
case Msg of
|
||||||
@ -2595,10 +2574,7 @@ begin
|
|||||||
and (GetKeyState(VK_CONTROL) < 0) and (GetKeyState(VK_MENU) >= 0) then
|
and (GetKeyState(VK_CONTROL) < 0) and (GetKeyState(VK_MENU) >= 0) then
|
||||||
begin
|
begin
|
||||||
if WndClassName(Window) = EditClsName then
|
if WndClassName(Window) = EditClsName then
|
||||||
begin
|
Windows.SendMessage(Window, EM_SETSEL, 0, -1); // select all
|
||||||
// select all
|
|
||||||
Windows.SendMessage(Window, EM_SETSEL, 0, -1);
|
|
||||||
end;
|
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
Loading…
Reference in New Issue
Block a user