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 -
This commit is contained in:
paul 2008-02-26 03:32:38 +00:00
parent a5b4f9d12f
commit 85e93e8f14
2 changed files with 20 additions and 1 deletions

View File

@ -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;

View File

@ -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);