From 7fc273c94186d7296e195471f513baed4a673576 Mon Sep 17 00:00:00 2001 From: micha Date: Thu, 10 Feb 2005 21:07:29 +0000 Subject: [PATCH] let general WindowProc also handle childedit of combobox, reduces code duplication, implements doubleclick for combobox git-svn-id: trunk@6777 - --- lcl/interfaces/win32/win32callback.inc | 102 ++++-------------------- lcl/interfaces/win32/win32int.pp | 5 +- lcl/interfaces/win32/win32proc.pp | 1 + lcl/interfaces/win32/win32wsspin.pp | 3 +- lcl/interfaces/win32/win32wsstdctrls.pp | 3 +- 5 files changed, 25 insertions(+), 89 deletions(-) diff --git a/lcl/interfaces/win32/win32callback.inc b/lcl/interfaces/win32/win32callback.inc index f6fa55999b..8efdd1a30f 100644 --- a/lcl/interfaces/win32/win32callback.inc +++ b/lcl/interfaces/win32/win32callback.inc @@ -495,7 +495,20 @@ Begin Assert(False, 'Trace:WindowProc - Getting Object With Callback Procedure'); WindowInfo := GetWindowInfo(Window); - lWinControl := WindowInfo^.WinControl; + if WindowInfo^.isChildEdit then + begin + lWinControl := WindowInfo^.AWinControl; + // filter messages we want to pass on to LCL + if (Msg <> WM_KILLFOCUS) and (Msg <> WM_SETFOCUS) + and ((Msg < WM_KEYFIRST) or (Msg > WM_KEYLAST)) + and ((Msg < WM_MOUSEFIRST) or (Msg > WM_MOUSELAST)) then + begin + Result := CallDefaultWindowProc(Window, Msg, WParam, LParam); + exit; + end; + end else begin + lWinControl := WindowInfo^.WinControl; + end; Assert(False, 'Trace:WindowProc - Getting Callback Object'); Assert(False, 'Trace:WindowProc - Checking Proc'); @@ -1478,90 +1491,6 @@ begin end; end; -{------------------------------------------------------------------------------ - Function: ChildEditWindowProc - Params: Window - The window that receives a message - Msg - The message received - WParam - Word parameter - LParam - Long-integer parameter - Returns: 0 if Msg is handled; non-zero long-integer result otherwise - - Handles the messages sent to the edit child of a (combobox, spinedit) control - by Windows or other applications - ------------------------------------------------------------------------------} -function ChildEditWindowProc(Window: HWnd; Msg: UInt; WParam: Windows.WParam; - LParam: Windows.LParam): LResult; stdcall; -var - LMessage: TLMessage; - LMKey: TLMKey; - PLMsg: PLMessage; - NotifyUserInput: boolean; - WinProcess: boolean; - lWinControl: TWinControl; -begin - // filter messages we want to send to LCL - WinProcess := true; - if (Msg = WM_KILLFOCUS) or (Msg = WM_SETFOCUS) or - ((Msg >= WM_KEYFIRST) and (Msg <= WM_KEYLAST)) then - begin - // TODO: code copied from WindowProc - PLMsg := @LMessage; - case Msg of - WM_KILLFOCUS, WM_SETFOCUS: - begin - LMessage.Msg := Msg; - end; - WM_KEYDOWN: - begin - NotifyUserInput := True; - PLMsg:=@LMKey; - with LMKey Do - begin - Msg := CN_KEYDOWN; - KeyData := LParam; - CharCode := Word(WParam); - Assert(False,Format('WM_KEYDOWN KeyData= %d CharCode= %d ',[KeyData,CharCode])); - end; - end; - WM_KEYUP: - begin - NotifyUserInput := True; - PLMsg:=@LMKey; - with LMKey do - begin - Msg := CN_KEYUP; - KeyData := LParam; - CharCode := Word(WParam); - Assert(False,Format('WM_KEYUP KeyData= %d CharCode= %d ',[KeyData,CharCode])); - end; - end; - end; - // application processing - if NotifyUserInput then - NotifyApplicationUserInput(PLMsg^.Msg); - - lWinControl := GetWindowInfo(Window)^.AWinControl; - DeliverMessage(lWinControl, PLMsg^); - - case Msg of - WM_KEYDOWN, WM_KEYUP: - begin - // if not yet processed, resend normally - if LMKey.CharCode <> VK_UNKNOWN then - begin - LMKey.Msg := Msg; - DeliverMessage(lWinControl, LMKey); - // still not handled? then do default processing - WinProcess := LMKey.CharCode <> VK_UNKNOWN; - end; - end; - end; - end; - - if WinProcess then - Result := CallDefaultWindowProc(Window, Msg, WParam, LParam); -end; - {------------------------------------------------------------------------------ Procedure: TimerCallBackProc Params: window_hnd - handle of window for timer message, not set in this implementation @@ -1594,6 +1523,9 @@ end; { $Log$ + Revision 1.193 2005/02/10 21:07:29 micha + let general WindowProc also handle childedit of combobox, reduces code duplication, implements doubleclick for combobox + Revision 1.192 2005/02/07 19:10:31 micha revert unwanted commit diff --git a/lcl/interfaces/win32/win32int.pp b/lcl/interfaces/win32/win32int.pp index e1003b73b5..190d583faf 100644 --- a/lcl/interfaces/win32/win32int.pp +++ b/lcl/interfaces/win32/win32int.pp @@ -197,8 +197,6 @@ function WindowProc(Window: HWnd; Msg: UInt; WParam: Windows.WParam; LParam: Windows.LParam): LResult; stdcall; function ComboBoxWindowProc(Window: HWnd; Msg: UInt; WParam: Windows.WParam; LParam: Windows.LParam): LResult; stdcall; -function ChildEditWindowProc(Window: HWnd; Msg: UInt; WParam: Windows.WParam; - LParam: Windows.LParam): LResult; stdcall; function CallDefaultWindowProc(Window: HWnd; Msg: UInt; WParam: Windows.WParam; LParam: Windows.LParam): LResult; @@ -286,6 +284,9 @@ End. { ============================================================================= $Log$ + Revision 1.133 2005/02/10 21:07:29 micha + let general WindowProc also handle childedit of combobox, reduces code duplication, implements doubleclick for combobox + Revision 1.132 2005/02/07 16:19:14 micha force default width and height for calendar control diff --git a/lcl/interfaces/win32/win32proc.pp b/lcl/interfaces/win32/win32proc.pp index f3805f7d08..a4967f2893 100644 --- a/lcl/interfaces/win32/win32proc.pp +++ b/lcl/interfaces/win32/win32proc.pp @@ -48,6 +48,7 @@ Type hasTabParent: boolean; // has a tabpage as parent, and is winxp themed isTabPage: boolean; // is window of tabpage isComboEdit: boolean; // is buddy of combobox, the edit control + isChildEdit: boolean; // is buddy of combobox, the edit control isGroupBox: boolean; // is groupbox, and does not have themed tabpage as parent MaxLength: dword; MouseX, MouseY: word; // noticing spurious WM_MOUSEMOVE messages diff --git a/lcl/interfaces/win32/win32wsspin.pp b/lcl/interfaces/win32/win32wsspin.pp index 0a8e556cd6..b42ee98d1d 100644 --- a/lcl/interfaces/win32/win32wsspin.pp +++ b/lcl/interfaces/win32/win32wsspin.pp @@ -94,8 +94,9 @@ begin // create window FinishCreateWindow(AWinControl, Params, true); // init buddy - Params.SubClassWndProc := @ChildEditWindowProc; + Params.SubClassWndProc := @WindowProc; WindowCreateInitBuddy(AWinControl, Params); + Params.BuddyWindowInfo^.isChildEdit := true; Result := Params.Window; end; diff --git a/lcl/interfaces/win32/win32wsstdctrls.pp b/lcl/interfaces/win32/win32wsstdctrls.pp index 3929fc4a0f..26c690c49b 100644 --- a/lcl/interfaces/win32/win32wsstdctrls.pp +++ b/lcl/interfaces/win32/win32wsstdctrls.pp @@ -564,8 +564,9 @@ begin // If the style is CBS_DROPDOWNLIST, GetTopWindow returns null, // because the combobox has no edit in that case. if Buddy<>HWND(nil) then begin - SubClassWndProc := @ChildEditWindowProc; + SubClassWndProc := @WindowProc; WindowCreateInitBuddy(AWinControl, Params); + BuddyWindowInfo^.isChildEdit := true; BuddyWindowInfo^.isComboEdit := true; end else BuddyWindowInfo:=nil; end;