zak
16-04-2011, 13:04
while trying to find a solution to martin question i stuck on a label click problem, here is the code which i try to click on a label to respond by a msgbox, it does not work, while the click on the button works.
Uses "UI"
Global hDlg As Long '---Dialog handle
Begin ControlID
%ID_Button
%ID_Label
End ControlID
Function TBMain()
Dialog New 0,"click on Label",200,100,300,200,%WS_SYSMENU Or %WS_MINIMIZEBOX Or %WS_CAPTION To hDlg
Control Add Button, hDlg, %ID_Button, "Cancel" , 90, 10, 70, 25, %WS_TABSTOP
Control Add Label , hDlg, %ID_Label, "want to click it" , 10, 10, 70, 25, %WS_CHILD Or %WS_VISIBLE Or %WS_BORDER Or %SS_CENTERIMAGE Or %SS_CENTER Or %SS_NOTIFY
'---Show dialog
Dialog Show Modal hDlg, Call dlgProc
End Function
'------------------------------------------------------------------------
CallBack Function dlgProc()
Select Case CBMSG
Case %WM_COMMAND
Select Case CBCTL
Case %ID_Label
MsgBox 0,"clicked"
Case %ID_Button
Dialog End CBHNDL
End Select
End Select
End Function
EDIT: i have updated the code as Mike suggested
Uses "UI"
Global hDlg As Long '---Dialog handle
Begin ControlID
%ID_Button
%ID_Label
End ControlID
Function TBMain()
Dialog New 0,"click on Label",200,100,300,200,%WS_SYSMENU Or %WS_MINIMIZEBOX Or %WS_CAPTION To hDlg
Control Add Button, hDlg, %ID_Button, "Cancel" , 90, 10, 70, 25, %WS_TABSTOP
Control Add Label , hDlg, %ID_Label, "want to click it" , 10, 10, 70, 25, %WS_CHILD Or %WS_VISIBLE Or %WS_BORDER Or %SS_CENTERIMAGE Or %SS_CENTER Or %SS_NOTIFY
'---Show dialog
Dialog Show Modal hDlg, Call dlgProc
End Function
'------------------------------------------------------------------------
CallBack Function dlgProc()
Select Case CBMSG
Case %WM_COMMAND
Select Case CBCTL
Case %ID_Label
MsgBox 0,"clicked"
Case %ID_Button
Dialog End CBHNDL
End Select
End Select
End Function
EDIT: i have updated the code as Mike suggested