From 85e93e8f14d94770d336601c7f7486137e32f78f Mon Sep 17 00:00:00 2001 From: paul Date: Tue, 26 Feb 2008 03:32:38 +0000 Subject: [PATCH] win32: dont send messages to LCL about internal combobox focus changes (fixes firing OnEnter, OnExit more than once, issue #0007241) git-svn-id: trunk@14250 - --- lcl/interfaces/win32/win32callback.inc | 15 +++++++++++++++ lcl/interfaces/win32/win32wsstdctrls.pp | 6 +++++- 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/lcl/interfaces/win32/win32callback.inc b/lcl/interfaces/win32/win32callback.inc index 8ae9634e01..35ecf96306 100644 --- a/lcl/interfaces/win32/win32callback.inc +++ b/lcl/interfaces/win32/win32callback.inc @@ -238,6 +238,7 @@ var NMHdr: PNMHdr absolute LParam; // used by WM_NOTIFY TmpSize: TSize; // used by WM_MEASUREITEM + Info: TComboboxInfo; function ShowHideTabPage(NotebookHandle: HWnd; Showing: boolean): integer; var @@ -1111,6 +1112,20 @@ begin begin Result := CallDefaultWindowProc(Window, Msg, WParam, LParam); exit; + end + else + if (Msg = WM_KILLFOCUS) or (Msg = WM_SETFOCUS) then + begin + // if focus jumps inside combo then no need to notify LCL + Info.cbSize := SizeOf(Info); + GetComboBoxInfo(lWinControl.Handle, @Info); + if (HWND(WParam) = Info.hwndList) or + (HWND(WParam) = Info.hwndItem) or + (HWND(WParam) = Info.hwndCombo) then + begin + Result := CallDefaultWindowProc(Window, Msg, WParam, LParam); + exit; + end; end; end else begin lWinControl := WindowInfo^.WinControl; diff --git a/lcl/interfaces/win32/win32wsstdctrls.pp b/lcl/interfaces/win32/win32wsstdctrls.pp index abd0130bbf..c1c150e920 100644 --- a/lcl/interfaces/win32/win32wsstdctrls.pp +++ b/lcl/interfaces/win32/win32wsstdctrls.pp @@ -351,14 +351,18 @@ const ------------------------------------------------------------------------------} function ComboBoxWindowProc(Window: HWnd; Msg: UInt; WParam: Windows.WParam; LParam: Windows.LParam): LResult; stdcall; +var + Info: TComboboxInfo; begin // darn MS: if combobox has edit control, and combobox receives focus, it // passes it on to the edit, so it will send a WM_KILLFOCUS; inhibit // also don't pass WM_SETFOCUS to the lcl, // it will get one from the edit control + Info.cbSize := SizeOf(Info); + GetComboBoxInfo(Window, @Info); if ((Msg = WM_KILLFOCUS) or (Msg = WM_SETFOCUS)) and - (Windows.GetTopWindow(Window) <> HWND(nil)) then + ((HWND(WParam) = Info.hwndItem) or (HWND(WParam) = Info.hwndList)) then begin // continue normal processing, don't send to lcl Result := CallDefaultWindowProc(Window, Msg, WParam, LParam);