Date: 07-23-2010
Return to Index
'Converts the screen coordinates of a specified point on the screen to client coordinates.
'If coordinates outside the client
'Primary Code:
Dim P as Point
GetCursorPos P 'p.x and p.y are in screen coordinates
ScreenToClient hDlg, P 'p.x and p.y are now dialog client coordinates
'Compilable Example:
'This examples uses a timer to put dialog client coordinates in a label control
'The cursor can be anywhere on the screen.
#Compile Exe
#Dim All
#Include "Win32API.inc"
Global hDlg As DWord
Function PBMain() As Long
Dialog New Pixels, 0, "Test Code",300,300,200,200, %WS_OverlappedWindow To hDlg
Control Add Label, hDlg, 100,"", 50,10,100,20
SetTimer(hDlg, 200, 50, 0) 'creates the timer 200ms
Dialog Show Modal hDlg Call DlgProc
End Function
CallBack Function DlgProc() As Long
Select Case CB.Msg
Case %WM_Timer
Dim P as Point
GetCursorPos P 'p.x and p.y are in screen coordinates
ScreenToClient hDlg, P 'p.x and p.y are now dialog client coordinates
Control Set Text hDlg, 100, "X:Y " + Str$(p.x) + ":" + Str$(p.y)
End Select
End Function
'gbs_00029
created by gbSnippets: http://www.garybeene.com