- replace few places where combo edit window has been accessed through GetTopWindow instead of GetComboboxInfo (for csSimple style GetTopWindow assumption is not correct)
- simplify window class name extraction

git-svn-id: trunk@14293 -
This commit is contained in:
paul 2008-02-28 04:41:35 +00:00
parent 929eef8853
commit c0c5d656fc
2 changed files with 34 additions and 14 deletions

View File

@ -57,6 +57,14 @@ begin
Assert(False, 'Trace:PropEnumProc - Exit'); Assert(False, 'Trace:PropEnumProc - Exit');
end; end;
function WndClassName(Wnd: HWND): String; inline;
var
winClassName: array[0..19] of char;
begin
GetClassName(Wnd, @winClassName, 20);
Result := winClassName;
end;
{------------------------------------------------------------------------------ {------------------------------------------------------------------------------
Function: CallDefaultWindowProc Function: CallDefaultWindowProc
Params: Window - The window that receives a message Params: Window - The window that receives a message
@ -70,6 +78,18 @@ end;
------------------------------------------------------------------------------} ------------------------------------------------------------------------------}
function CallDefaultWindowProc(Window: HWnd; Msg: UInt; WParam: Windows.WParam; function CallDefaultWindowProc(Window: HWnd; Msg: UInt; WParam: Windows.WParam;
LParam: Windows.LParam): LResult; LParam: Windows.LParam): LResult;
function IsComboboxAndHasEdit(Window: HWnd): Boolean;
var
Info: TComboboxInfo;
begin
Result := WndClassName(Window) = ComboboxClsName;
if not Result then
Exit;
Info.cbSize := SizeOf(Info);
Win32Extra.GetComboBoxInfo(Window, @Info);
Result := (Info.hwndItem <> 0) and GetWindowInfo(Info.hwndItem)^.isComboEdit;
end;
var var
PrevWndProc: Windows.WNDPROC; PrevWndProc: Windows.WNDPROC;
{$ifdef MSG_DEBUG} {$ifdef MSG_DEBUG}
@ -94,8 +114,10 @@ begin
// to list of strings, and if appears in there, will set the text, and select it // to list of strings, and if appears in there, will set the text, and select it
// WM_GETTEXTLENGTH, WM_GETTEXT, WM_SETTEXT, EM_SETSEL // WM_GETTEXTLENGTH, WM_GETTEXT, WM_SETTEXT, EM_SETSEL
// combobox sends WM_SIZE to itself indirectly, check recursion // combobox sends WM_SIZE to itself indirectly, check recursion
setComboWindow := (Msg = WM_SIZE) and (ComboBoxHandleSizeWindow = 0) setComboWindow :=
and GetWindowInfo(Windows.GetTopWindow(Window))^.isComboEdit; (Msg = WM_SIZE) and
(ComboBoxHandleSizeWindow = 0) and
IsComboboxAndHasEdit(Window);
if setComboWindow then if setComboWindow then
ComboBoxHandleSizeWindow := Window; ComboBoxHandleSizeWindow := Window;
Result := Windows.CallWindowProc(PrevWndProc, Window, Msg, WParam, LParam); Result := Windows.CallWindowProc(PrevWndProc, Window, Msg, WParam, LParam);
@ -219,7 +241,6 @@ var
OverlayWindow: HWND; OverlayWindow: HWND;
TargetWindow: HWND; TargetWindow: HWND;
eraseBkgndCommand: TEraseBkgndCommand; eraseBkgndCommand: TEraseBkgndCommand;
winClassName: array[0..19] of char;
WindowInfo: PWindowInfo; WindowInfo: PWindowInfo;
Flags: dword; Flags: dword;
WindowDC: HDC; WindowDC: HDC;
@ -325,8 +346,7 @@ var
function GetIsNativeControl(AWindow: HWND): Boolean; function GetIsNativeControl(AWindow: HWND): Boolean;
begin begin
GetClassName(AWindow, winClassName, 20); Result := WndClassName(AWindow) <> ClsName;
Result := not CompareMem(@winClassName, @ClsName, High(ClsName) + 1);
end; end;
procedure SendPaintMessage(ControlDC: HDC); procedure SendPaintMessage(ControlDC: HDC);
@ -360,9 +380,7 @@ var
end; end;
// create a paint message // create a paint message
GetClassName(Window, winClassName, 20); isNotebook := ThemeServices.ThemesEnabled and (WndClassName(Window) = TabControlClsName);
isNotebook := ThemeServices.ThemesEnabled and
CompareMem(@winClassName, @TabControlClsName, High(TabControlClsName)+1);
isNativeControl := GetIsNativeControl(Window); isNativeControl := GetIsNativeControl(Window);
ParentPaintWindow := 0; ParentPaintWindow := 0;
needParentPaint := GetNeedParentPaint(WindowInfo, lWinControl); needParentPaint := GetNeedParentPaint(WindowInfo, lWinControl);
@ -643,9 +661,12 @@ var
procedure DisposeComboEditWindowInfo(ComboBox: TCustomComboBox); procedure DisposeComboEditWindowInfo(ComboBox: TCustomComboBox);
var var
Buddy: HWND; Buddy: HWND;
Info: TComboboxInfo;
begin begin
Buddy := Windows.GetTopWindow(ComboBox.Handle); Info.cbSize := SizeOf(Info);
if Buddy<>HWND(nil) then Win32Extra.GetComboBoxInfo(Combobox.Handle, @Info);
Buddy := Info.hwndItem;
if Buddy <> HWND(nil) then
DisposeWindowInfo(Buddy); DisposeWindowInfo(Buddy);
end; end;
@ -1118,7 +1139,7 @@ begin
begin begin
// if focus jumps inside combo then no need to notify LCL // if focus jumps inside combo then no need to notify LCL
Info.cbSize := SizeOf(Info); Info.cbSize := SizeOf(Info);
GetComboBoxInfo(lWinControl.Handle, @Info); Win32Extra.GetComboBoxInfo(lWinControl.Handle, @Info);
if (HWND(WParam) = Info.hwndList) or if (HWND(WParam) = Info.hwndList) or
(HWND(WParam) = Info.hwndItem) or (HWND(WParam) = Info.hwndItem) or
(HWND(WParam) = Info.hwndCombo) then (HWND(WParam) = Info.hwndCombo) then
@ -2432,8 +2453,7 @@ begin
if (PLMsg^.Result = 0) and (Msg = WM_KEYDOWN) and (WParam = Ord('A')) if (PLMsg^.Result = 0) and (Msg = WM_KEYDOWN) and (WParam = Ord('A'))
and (GetKeyState(VK_CONTROL) < 0) and (GetKeyState(VK_MENU) >= 0) then and (GetKeyState(VK_CONTROL) < 0) and (GetKeyState(VK_MENU) >= 0) then
begin begin
GetClassName(Window, winClassName, 20); if WndClassName(Window) = EditClsName then
if CompareMem(@winClassName, @EditClsName, High(EditClsName)+1) then
begin begin
// select all // select all
Windows.SendMessage(Window, EM_SETSEL, 0, -1); Windows.SendMessage(Window, EM_SETSEL, 0, -1);

View File

@ -223,7 +223,7 @@ var
const const
BOOL_RESULT: Array[Boolean] Of String = ('False', 'True'); BOOL_RESULT: array[Boolean] of String = ('False', 'True');
ClsName: array[0..6] of char = 'Window'#0; ClsName: array[0..6] of char = 'Window'#0;
EditClsName: array[0..4] of char = 'Edit'#0; EditClsName: array[0..4] of char = 'Edit'#0;
ButtonClsName: array[0..6] of char = 'Button'#0; ButtonClsName: array[0..6] of char = 'Button'#0;