fix scroll message handling for comboboxes

git-svn-id: trunk@5576 -
This commit is contained in:
micha 2004-06-17 21:33:01 +00:00
parent 220f368496
commit 336d0c8c30
2 changed files with 41 additions and 24 deletions

View File

@ -24,6 +24,11 @@
{ callback routines } { callback routines }
{*************************************************************} {*************************************************************}
{ forward declarations }
function ComboBoxEditWindowProc(Window: HWnd; Msg: UInt; WParam: Windows.WParam;
LParam: Windows.LParam): LResult; stdcall; forward;
{----------------------------------------------------------------------------- {-----------------------------------------------------------------------------
Function: DisableWindowsProc Function: DisableWindowsProc
Params: Window - handle of toplevel windows to be disabled Params: Window - handle of toplevel windows to be disabled
@ -131,6 +136,7 @@ Var
WinProcess: Boolean; WinProcess: Boolean;
NotifyUserInput: Boolean; NotifyUserInput: Boolean;
OverlayWindow: HWND; OverlayWindow: HWND;
TargetWindow: HWND;
LMInsertText: TLMInsertText; // used by CB_INSERTSTRING, LB_INSERTSTRING LMInsertText: TLMInsertText; // used by CB_INSERTSTRING, LB_INSERTSTRING
LMScroll: TLMScroll; // used by WM_HSCROLL LMScroll: TLMScroll; // used by WM_HSCROLL
@ -686,29 +692,34 @@ Begin
X := SmallInt(Lo(LParam)); X := SmallInt(Lo(LParam));
Y := SmallInt(Hi(LParam)); Y := SmallInt(Hi(LParam));
// check if mouse cursor within this window, otherwise send message to window the mouse is hovering over // check if mouse cursor within this window, otherwise send message to window the mouse is hovering over
if GetWindowRect(Window, R) <> 0 then P.X := X;
begin P.Y := Y;
if (X < R.Left) or (R.Right < X) TargetWindow := TWin32WidgetSet(InterfaceObject).WindowFromPoint(P);
or (Y < R.Top) or (R.Bottom < Y) then if TargetWindow = HWND(nil) then
begin exit;
P.X := X;
P.Y := Y;
Window := TWin32WidgetSet(InterfaceObject).WindowFromPoint(P);
if Window = HWND(nil) then
exit;
PostMessage(Window, WM_MOUSEWHEEL, WParam, LParam); // check if the window is an edit control of a combobox, if so,
exit; // redirect it to the combobox, not the edit control
end; if Windows.GetWindowLong(TargetWindow, GWL_WNDPROC) = longint(@ComboBoxEditWindowProc) then
TargetWindow := Windows.GetParent(TargetWindow);
if TargetWindow <> Window then
begin
Result := SendMessage(TargetWindow, WM_MOUSEWHEEL, WParam, LParam);
exit;
end; end;
Msg := LM_MOUSEWHEEL; // the mousewheel message is for us
WheelDelta := SmallInt(Hi(WParam)); // windows handles combobox's mousewheel messages
State := GetShiftState; if TWinControl(OwnerObject).FCompStyle <> csComboBox then
UserData := Pointer(GetWindowLong(Window, GWL_USERDATA)); begin
End; Msg := LM_MOUSEWHEEL;
WinProcess := false; WheelDelta := SmallInt(Hi(WParam));
End; State := GetShiftState;
UserData := Pointer(GetWindowLong(Window, GWL_USERDATA));
WinProcess := false;
end;
end;
end;
//TODO:LM_MOVEPAGE,LM_MOVETOROW,LM_MOVETOCOLUMN //TODO:LM_MOVEPAGE,LM_MOVETOROW,LM_MOVETOCOLUMN
WM_NCHITTEST: WM_NCHITTEST:
begin begin
@ -1231,6 +1242,9 @@ end;
{ {
$Log$ $Log$
Revision 1.115 2004/06/17 21:33:01 micha
fix scroll message handling for comboboxes
Revision 1.114 2004/06/15 15:37:29 micha Revision 1.114 2004/06/15 15:37:29 micha
fix groupbox background erasing fix groupbox background erasing

View File

@ -173,11 +173,12 @@ var
begin begin
if not TWinControl(Sender).HandleAllocated then if not TWinControl(Sender).HandleAllocated then
exit; exit;
// send scroll message
FillChar(ScrollInfo, sizeof(ScrollInfo), #0); FillChar(ScrollInfo, sizeof(ScrollInfo), #0);
ScrollInfo.cbSize := sizeof(ScrollInfo); ScrollInfo.cbSize := sizeof(ScrollInfo);
ScrollInfo.fMask := SIF_PAGE or SIF_POS or SIF_RANGE; ScrollInfo.fMask := SIF_PAGE or SIF_POS or SIF_RANGE;
if Windows.GetScrollInfo(TWinControl(Sender).Handle, SB_VERT, ScrollInfo) then if Windows.GetScrollInfo(Handle, SB_VERT, ScrollInfo) then
begin begin
with TLMMouseEvent(Message) do with TLMMouseEvent(Message) do
begin begin
@ -188,7 +189,7 @@ var
WParam := ScrollInfo.nMin; WParam := ScrollInfo.nMin;
WParam := SB_THUMBPOSITION or (WParam shl 16); WParam := SB_THUMBPOSITION or (WParam shl 16);
end; end;
Windows.PostMessage(TWinControl(Sender).Handle, WM_VSCROLL, WParam, HWND(nil)); Windows.PostMessage(Handle, WM_VSCROLL, WParam, HWND(nil));
end; end;
end; end;
@ -539,7 +540,6 @@ Function TWin32WidgetSet.ClipboardGetOwnerShip(ClipboardType: TClipboardType;
Formats: PClipboardFormat): Boolean; Formats: PClipboardFormat): Boolean;
Var Var
I: Integer; I: Integer;
P: PChar;
procedure PutTextOnClipBoard; procedure PutTextOnClipBoard;
var var
@ -3065,6 +3065,9 @@ end;
{ ============================================================================= { =============================================================================
$Log$ $Log$
Revision 1.118 2004/06/17 21:33:01 micha
fix scroll message handling for comboboxes
Revision 1.117 2004/06/10 18:14:10 vincents Revision 1.117 2004/06/10 18:14:10 vincents
converted win32proc.inc to unit converted win32proc.inc to unit