diff options
author | graemeg <graemeg@ae50a9b5-8222-0410-bf8d-8a13f76226bf> | 2008-06-28 22:45:34 +0000 |
---|---|---|
committer | graemeg <graemeg@ae50a9b5-8222-0410-bf8d-8a13f76226bf> | 2008-06-28 22:45:34 +0000 |
commit | 4f159b5e41a57663f20fb25aa6352ec7b60df3ca (patch) | |
tree | 15c0621193086b949a9696cd10377620e3506278 /src/corelib/gdi/gfx_gdi.pas | |
parent | 0ab570aaaaf6abb6cb2392c7852af1981eed14a4 (diff) | |
download | fpGUI-4f159b5e41a57663f20fb25aa6352ec7b60df3ca.tar.xz |
* Committed Vladimir's Splitter component patch.
Diffstat (limited to 'src/corelib/gdi/gfx_gdi.pas')
-rw-r--r-- | src/corelib/gdi/gfx_gdi.pas | 100 |
1 files changed, 43 insertions, 57 deletions
diff --git a/src/corelib/gdi/gfx_gdi.pas b/src/corelib/gdi/gfx_gdi.pas index 67d04de1..497f66b0 100644 --- a/src/corelib/gdi/gfx_gdi.pas +++ b/src/corelib/gdi/gfx_gdi.pas @@ -708,7 +708,7 @@ begin msgp.mouse.shiftstate := GetKeyboardShiftState; - if uMsg = WM_MouseMove then + if uMsg = WM_MOUSEMOVE then w.DoMouseEnterLeaveCheck(w, uMsg, wParam, lParam); if mcode <> 0 then @@ -1030,74 +1030,60 @@ end; { TfpgWindowImpl } var - // these are required for Windows MouseEnter & MouseExit detection. + // this are required for Windows MouseEnter & MouseExit detection. uLastWindowHndl: TfpgWinHandle; - uLastWindow: TfpgWindowImpl; function TfpgWindowImpl.DoMouseEnterLeaveCheck(AWindow: TfpgWindowImpl; uMsg, wParam, lParam: Cardinal): Boolean; - - //---------------------- - function CursorInDifferentWindow: Boolean; - var - pt: Windows.POINT; - begin - pt.x := LoWord(lParam); - pt.y := HiWord(lParam); - - // only WM_MOUSEWHEEL uses screen coordinates!!! - if uMsg <> WM_MOUSEWHEEL then - Windows.ClientToScreen(FWinHandle, @pt); - - Result := WindowFromPoint(pt) <> uLastWindowHndl; - end; - var - pt: Windows.POINT; + pt, spt: Windows.POINT; msgp: TfpgMessageParams; - b: boolean; -begin - b := CursorInDifferentWindow; - FillChar(msgp, sizeof(msgp), 0); + CursorInDifferentWindow: boolean; + CurrentWindowHndl: TfpgWinHandle; + LastWindow: TfpgWindowImpl; + +begin + // vvzh: this method currently cannot receive mouse events when mouse pointer + // is outside of the application window. We could try to play with + // TrackMouseEvent to catch such events and then + // - send FPGM_MOUSEEXIT/FPGM_MOUSEENTER + // - set uLastWindowHndl to 0 + // An example: + // var tme: TTrackMouseEvent; + // tme.cbSize := SizeOf(tme); + // tme.hwndTrack := m_hWnd; + // tme.dwFlags := TME_LEAVE or TME_HOVER; + // tme.dwHoverTime := 1; + // TrackMouseEvent(tme); + pt.x := LoWord(lParam); pt.y := HiWord(lParam); - if (not b) and (not FMouseInWindow) then - begin - if not CursorInDifferentWindow then - begin - FMouseInWindow := True; -// writeln('GFX: MouseEnter detected'); - fpgSendMessage(nil, AWindow, FPGM_MOUSEENTER, msgp); - end; - Result := uMsg <> WM_MOUSEMOVE; - end + spt := pt; + // only WM_MOUSEWHEEL uses screen coordinates!!! + if uMsg = WM_MOUSEWHEEL then + Windows.ScreenToClient(FWinHandle, @pt) else + Windows.ClientToScreen(FWinHandle, @spt); + + CurrentWindowHndl := WindowFromPoint(spt); + CursorInDifferentWindow := (CurrentWindowHndl <> uLastWindowHndl); + + if CursorInDifferentWindow then begin -// writeln('... in else part... (', pt.x, ',', pt.y, ')'); - if uMsg = WM_MOUSEWHEEL then - Windows.ScreenToClient(FWinHandle, @pt); - // we should change the Width and Height to ClientWidth, ClientHeight - if (pt.x <= 0) or (pt.y <= 0) or (pt.x >= Width) or - (pt.y >= Height) or CursorInDifferentWindow then - FMouseInWindow := False; - - if not FMouseInWindow then + FillChar(msgp, sizeof(msgp), 0); + msgp.mouse.x := pt.x; + msgp.mouse.y := pt.y; + LastWindow := GetMyWidgetFromHandle(uLastWindowHndl); + // check if last window still exits. eg: Dialog window could be closed. + if LastWindow <> nil then begin - msgp.mouse.x := LoWord(lParam); - msgp.mouse.y := HiWord(lParam); // writeln('GFX: MouseExit detected'); - if uLastWindow <> nil then - begin - // check if last window still exits. eg: Dialog window could be closed. - if GetMyWidgetFromHandle(uLastWindowHndl) <> nil then - fpgSendMessage(nil, uLastWindow, FPGM_MOUSEEXIT, msgp); - end; - Result := False; - end - else - Result := True; + fpgSendMessage(nil, LastWindow, FPGM_MOUSEEXIT, msgp); + end; +// writeln('GFX: MouseEnter detected'); + fpgSendMessage(nil, AWindow, FPGM_MOUSEENTER, msgp); end; - uLastWindowHndl := FWinHandle; - uLastWindow := AWindow; + + uLastWindowHndl := CurrentWindowHndl; end; procedure TfpgWindowImpl.DoAllocateWindowHandle(AParent: TfpgWindowBase); |