GetDlgCtrlID

Category: API Functions

Date: 07-23-2010

Return to Index


 
'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:
'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.
 
#Compile Exe
#Dim All
#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
 
 


created by gbSnippets: http://www.garybeene.com