Date: 02-16-2022
Return to Index
created by gbSnippets
'Compilable Example: (Jose Includes)
#Compiler PBWin 10
#Compile Exe
#Dim All
%Unicode=1
#Include "Win32API.inc"
Global hDlg As Dword
%IDC_Graphic = 500
%IDC_Textbox = 501
Function PBMain() As Long
Dialog New Pixels, 0, "Parent",300,300,300,200, %WS_OverlappedWindow To hDlg
Control Add TextBox, hDlg, %IDC_TextBox, "Test", 10,10,100,20
Control Add Graphic, hDlg, %IDC_Graphic, "",10,40,280,150, %WS_Border Or %SS_Notify
Graphic Attach hDlg, %IDC_Graphic, ReDraw
Graphic Set Virtual 800,1000
Dialog Show Modal hDlg Call DlgProc
End Function
CallBack Function DlgProc() As Long
Local pt As Point
Select Case Cb.Msg
Case %WM_Command
Select Case Cb.Ctl
Case %IDC_Graphic
Select Case Cb.CtlMsg
Case %STN_Clicked
'Control Set Focus hDlg, %IDC_Graphic '<--- Approach #1
End Select
End Select
Case %WM_SetCursor
GetCursorPos pt
ScreenToClient hDlg, pt
If ChildWindowFromPoint(hDlg,pt) = GetDlgItem(hDlg,%IDC_Graphic) Then '<--- Approach #2
Control Set Focus hDlg, %IDC_Graphic
End If
End Select
End Function
'gbs_01390
'Date: 10-17-2014
http://www.garybeene.com/sw/gbsnippets.htm