Date: 02-16-2022
Return to Index
created by gbSnippets
'Gets control ID from control handle. Useful where API require the control ID
'or where the control ID needs to be checked in a message.
'Primary Code:
CtrlID& = GetDlgCtrlID ( hControl )
'Compilable Example: (Jose Includes)
'This example demonstrates an active URL in a label
'Note the use of GetDlgCtrlID() with CB.wParam (contains the control handle) to
'get the control ID.
#Compiler PBWin 9, PBWin 10
#Compile EXE
#Dim All
%Unicode=1
#Include "Win32API.inc"
Global hDlg As Dword
%ID_Label = 300
Function PBMain() As Long
Dialog New Pixels, 0, "Test Code",300,300,200,100, %WS_OverlappedWindow To hDlg
Control Add Label, hDlg, %ID_Label, "http://www.garybeene.com", 10, 40, 200, 20, _
%SS_Center Or %SS_Notify
Dialog Show Modal hDlg Call DlgProc
End Function
CallBack Function DlgProc() As Long
Local URL As Asciiz * %Max_Path, iReturn As Long
Select Case CB.Msg
Case %WM_Command
If CB.Ctl = %ID_Label AND CB.Ctlmsg = %STN_Clicked Then
URL$ = "http://www.garybeene.com/"
iReturn = ShellExecute(hDlg, "Open", URL, $Nul, $Nul, %SW_ShowNormal)
End If
Case %WM_SetCursor
Select Case GetDlgCtrlID (CB.wParam)
Case %ID_Label
Control Set Color hDlg, %ID_Label, %Red, -1 'when over the label, use RED
Dialog Redraw hDlg
Case Else
Control Set Color hDlg, %ID_Label, %Black, -1 'everywhere else, use Black
Dialog Redraw hDlg
End Select
End Select
End Function
'gbs_00022
'Date: 03-10-2012
http://www.garybeene.com/sw/gbsnippets.htm