mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-07 09:55:54 +02:00
fix combobox selection of text when resizing (fixes #1180)
improve message debugging (display # in front of message when sent by win32 default handler) git-svn-id: trunk@7821 -
This commit is contained in:
parent
418c53918e
commit
86a7e13da6
@ -70,12 +70,36 @@ function CallDefaultWindowProc(Window: HWnd; Msg: UInt; WParam: Windows.WParam;
|
|||||||
LParam: Windows.LParam): LResult;
|
LParam: Windows.LParam): LResult;
|
||||||
var
|
var
|
||||||
PrevWndProc: Windows.WNDPROC;
|
PrevWndProc: Windows.WNDPROC;
|
||||||
|
{$ifdef MSG_DEBUG}
|
||||||
|
depthLen: integer;
|
||||||
|
{$endif}
|
||||||
|
setComboWindow: boolean;
|
||||||
begin
|
begin
|
||||||
|
{$ifdef MSG_DEBUG}
|
||||||
|
depthLen := Length(MessageStackDepth);
|
||||||
|
if depthLen > 0 then
|
||||||
|
MessageStackDepth[depthLen] := '#';
|
||||||
|
{$endif}
|
||||||
PrevWndProc := GetWindowInfo(Window)^.DefWndProc;
|
PrevWndProc := GetWindowInfo(Window)^.DefWndProc;
|
||||||
if PrevWndProc = nil then
|
if PrevWndProc = nil then
|
||||||
Result := Windows.DefWindowProc(Window, Msg, WParam, LParam)
|
Result := Windows.DefWindowProc(Window, Msg, WParam, LParam)
|
||||||
else
|
else begin
|
||||||
|
// combobox child edit weirdness: combobox handling WM_SIZE will compare text
|
||||||
|
// to list of strings, and if appears in there, will set the text, and select it
|
||||||
|
// WM_GETTEXTLENGTH, WM_GETTEXT, WM_SETTEXT, EM_SETSEL
|
||||||
|
// combobox sends WM_SIZE to itself indirectly, check recursion
|
||||||
|
setComboWindow := (Msg = WM_SIZE) and (ComboBoxHandleSizeWindow = 0)
|
||||||
|
and GetWindowInfo(Windows.GetTopWindow(Window))^.isComboEdit;
|
||||||
|
if setComboWindow then
|
||||||
|
ComboBoxHandleSizeWindow := Window;
|
||||||
Result := Windows.CallWindowProc(PrevWndProc, Window, Msg, WParam, LParam);
|
Result := Windows.CallWindowProc(PrevWndProc, Window, Msg, WParam, LParam);
|
||||||
|
if setComboWindow then
|
||||||
|
ComboBoxHandleSizeWindow := 0;
|
||||||
|
end;
|
||||||
|
{$ifdef MSG_DEBUG}
|
||||||
|
if depthLen > 0 then
|
||||||
|
MessageStackDepth[depthLen] := ' ';
|
||||||
|
{$endif}
|
||||||
end;
|
end;
|
||||||
|
|
||||||
type
|
type
|
||||||
@ -84,10 +108,7 @@ const
|
|||||||
EraseBkgndStackMask = $3;
|
EraseBkgndStackMask = $3;
|
||||||
EraseBkgndStackShift = 2;
|
EraseBkgndStackShift = 2;
|
||||||
var
|
var
|
||||||
EraseBkgndStack: dword;
|
EraseBkgndStack: dword = 0;
|
||||||
{$ifdef MSG_DEBUG}
|
|
||||||
MessageStackDepth: string;
|
|
||||||
{$endif}
|
|
||||||
|
|
||||||
procedure PushEraseBkgndCommand(Command: TEraseBkgndCommand);
|
procedure PushEraseBkgndCommand(Command: TEraseBkgndCommand);
|
||||||
begin
|
begin
|
||||||
@ -561,6 +582,11 @@ Var
|
|||||||
end
|
end
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
function IsComboEditSelection: boolean;
|
||||||
|
begin
|
||||||
|
Result := WindowInfo^.isComboEdit and (ComboBoxHandleSizeWindow = Windows.GetParent(Window));
|
||||||
|
end;
|
||||||
|
|
||||||
Begin
|
Begin
|
||||||
Assert(False, 'Trace:WindowProc - Start');
|
Assert(False, 'Trace:WindowProc - Start');
|
||||||
|
|
||||||
@ -574,6 +600,25 @@ Begin
|
|||||||
WindowInfo := GetWindowInfo(Window);
|
WindowInfo := GetWindowInfo(Window);
|
||||||
if WindowInfo^.isChildEdit then
|
if WindowInfo^.isChildEdit then
|
||||||
begin
|
begin
|
||||||
|
// combobox child edit weirdness
|
||||||
|
// prevent combobox WM_SIZE message to get/set/compare text to list, to select text
|
||||||
|
if IsComboEditSelection then
|
||||||
|
begin
|
||||||
|
case Msg of
|
||||||
|
WM_GETTEXTLENGTH, EM_SETSEL:
|
||||||
|
begin
|
||||||
|
Result := 0;
|
||||||
|
exit;
|
||||||
|
end;
|
||||||
|
WM_GETTEXT:
|
||||||
|
begin
|
||||||
|
if WParam > 0 then
|
||||||
|
PChar(LParam)^ := #0;
|
||||||
|
Result := 0;
|
||||||
|
exit;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
lWinControl := WindowInfo^.AWinControl;
|
lWinControl := WindowInfo^.AWinControl;
|
||||||
// filter messages we want to pass on to LCL
|
// filter messages we want to pass on to LCL
|
||||||
if (Msg <> WM_KILLFOCUS) and (Msg <> WM_SETFOCUS) and (Msg <> WM_NCDESTROY)
|
if (Msg <> WM_KILLFOCUS) and (Msg <> WM_SETFOCUS) and (Msg <> WM_NCDESTROY)
|
||||||
|
@ -246,10 +246,14 @@ type
|
|||||||
var
|
var
|
||||||
MouseDownTime: dword;
|
MouseDownTime: dword;
|
||||||
MouseDownPos: TPoint;
|
MouseDownPos: TPoint;
|
||||||
MouseDownWindow: HWND;
|
MouseDownWindow: HWND = 0;
|
||||||
MouseDownFocusWindow: HWND;
|
MouseDownFocusWindow: HWND;
|
||||||
MouseDownFocusStatus: TMouseDownFocusStatus;
|
MouseDownFocusStatus: TMouseDownFocusStatus = mfNone;
|
||||||
|
ComboBoxHandleSizeWindow: HWND = 0;
|
||||||
OnClipBoardRequest: TClipboardRequestEvent;
|
OnClipBoardRequest: TClipboardRequestEvent;
|
||||||
|
{$ifdef MSG_DEBUG}
|
||||||
|
MessageStackDepth: string = '';
|
||||||
|
{$endif}
|
||||||
|
|
||||||
{$I win32listsl.inc}
|
{$I win32listsl.inc}
|
||||||
{$I win32callback.inc}
|
{$I win32callback.inc}
|
||||||
@ -260,15 +264,8 @@ var
|
|||||||
Initialization
|
Initialization
|
||||||
|
|
||||||
Assert(False, 'Trace:win32int.pp - Initialization');
|
Assert(False, 'Trace:win32int.pp - Initialization');
|
||||||
{$ifdef MSG_DEBUG}
|
|
||||||
MessageStackDepth := '';
|
|
||||||
{$endif}
|
|
||||||
EraseBkgndStack := 0;
|
|
||||||
{ initialize mousedownclick to far before double click time }
|
{ initialize mousedownclick to far before double click time }
|
||||||
MouseDownFocusStatus := mfNone;
|
|
||||||
MouseDownTime := GetTickCount - 5000;
|
MouseDownTime := GetTickCount - 5000;
|
||||||
MouseDownWindow := 0;
|
|
||||||
|
|
||||||
|
|
||||||
finalization
|
finalization
|
||||||
|
|
||||||
|
@ -672,21 +672,15 @@ end;
|
|||||||
function TWin32WSCustomComboBox.GetText(const AWinControl: TWinControl; var AText: string): boolean;
|
function TWin32WSCustomComboBox.GetText(const AWinControl: TWinControl; var AText: string): boolean;
|
||||||
var
|
var
|
||||||
Handle: HWND;
|
Handle: HWND;
|
||||||
CapLen: dword;
|
TextLen: dword;
|
||||||
Caption: PChar;
|
|
||||||
begin
|
begin
|
||||||
Result := AWinControl.HandleAllocated;
|
Result := AWinControl.HandleAllocated;
|
||||||
if not Result then
|
if not Result then
|
||||||
exit;
|
exit;
|
||||||
AText := '';
|
|
||||||
Handle := AWinControl.Handle;
|
Handle := AWinControl.Handle;
|
||||||
// TODO: this can be made shorter probably, using SetLength(AText, ...)
|
TextLen := GetWindowTextLength(Handle);
|
||||||
// + 1 = terminating null character
|
SetLength(AText, TextLen);
|
||||||
CapLen := Windows.SendMessage(Handle, WM_GETTEXTLENGTH, 0, 0) + 1;
|
GetWindowText(Handle, PChar(AText), TextLen + 1);
|
||||||
Caption := StrAlloc(CapLen);
|
|
||||||
Windows.SendMessage(Handle, WM_GETTEXT, CapLen, LPARAM(Caption));
|
|
||||||
AText := StrPas(Caption);
|
|
||||||
StrDispose(Caption);
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TWin32WSCustomComboBox.SetArrowKeysTraverseList(const ACustomComboBox: TCustomComboBox;
|
procedure TWin32WSCustomComboBox.SetArrowKeysTraverseList(const ACustomComboBox: TCustomComboBox;
|
||||||
@ -825,21 +819,16 @@ end;
|
|||||||
|
|
||||||
function TWin32WSCustomEdit.GetText(const AWinControl: TWinControl; var AText: string): boolean;
|
function TWin32WSCustomEdit.GetText(const AWinControl: TWinControl; var AText: string): boolean;
|
||||||
var
|
var
|
||||||
CapLen: dword;
|
TextLen: dword;
|
||||||
Caption: PChar;
|
|
||||||
Handle: HWND;
|
Handle: HWND;
|
||||||
begin
|
begin
|
||||||
Result := AWinControl.HandleAllocated;
|
Result := AWinControl.HandleAllocated;
|
||||||
if not Result then
|
if not Result then
|
||||||
exit;
|
exit;
|
||||||
AText := '';
|
|
||||||
Handle := AWinControl.Handle;
|
Handle := AWinControl.Handle;
|
||||||
// TODO: this can be made shorter probably, using SetLength(AText, ...)
|
TextLen := GetWindowTextLength(Handle);
|
||||||
CapLen := GetWindowTextLength(Handle);
|
SetLength(AText, TextLen);
|
||||||
Caption := StrAlloc(CapLen + 1);
|
GetWindowText(Handle, PChar(AText), TextLen + 1);
|
||||||
GetWindowText(Handle, Caption, CapLen + 1);
|
|
||||||
AText := StrPas(Caption);
|
|
||||||
StrDispose(Caption);
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TWin32WSCustomEdit.SetCharCase(const ACustomEdit: TCustomEdit; NewCase: TEditCharCase);
|
procedure TWin32WSCustomEdit.SetCharCase(const ACustomEdit: TCustomEdit; NewCase: TEditCharCase);
|
||||||
|
Loading…
Reference in New Issue
Block a user