Date: 02-16-2022
Return to Index
created by gbSnippets
'Compiler Comments:
'This code was written to compilete in PBWin10. To compile with PBWin9, split pt
'into pt.x and pt.y as arguments wherever the PtInRect() API is used (one place).
'Compilable Example: (Jose Includes)
#Compiler PBWin 10
#Compile EXE
#Dim All
%Unicode=1
#Include "WIN32API.INC"
Global hDlg As Dword
Function PBMain
Local Result As Long
Dialog New 0, "", , , 200, 60, %WS_OverlappedWindow To hDlg
Dialog Show Modal hDlg Call DlgProc
End Function
CallBack Function DlgProc()
Local trc As Rect, tpt As PointAPI
Select Case Cb.Msg
Case %WM_LButtonDown
SetFocus hDlg 'why?
SetCapture hDlg 'start capturing, so can detect LButtonUp when it occurs
Case %WM_MouseMove
If GetCapture() = hDlg Then 'app has capture 'why?
' Drawing and dragging operations
End If
Case %WM_LButtonUp
ReleaseCapture 'generates a WM_CAPTURECHANGED message 'why not do my mouse up stuff here?
Case %WM_CaptureChanged
'sent to window losing the mouse capture
'window receives this message if it calls ReleaseCapture itself
GetClientRect hDlg, trc 'relative coordinates of hDlg client area
MapWindowPoints hDlg, %NULL, ByVal VarPtr(trc), 2 'screen coordinate of hDlg client area
GetCursorPos tpt 'screen coordinates of cursor
If PtInRect(trc, tpt) Then
Dialog Set Text hDlg, "Inside"
Else
Dialog Set Text hDlg, "Outside"
End If
Case %WM_CancelMode
'msg received when system windows (Task Mgr, Task Switch, ...) pop up
End Select
End Function
'gbs_01032
'Date: 03-10-2012
http://www.garybeene.com/sw/gbsnippets.htm