ImgButton - Change Image in ImgButton When Pressed II

Category: Controls - .Techniques

Date: 02-16-2022

Return to Index


 
'Compilable Example:  (Jose Includes)
#Compiler PBWin 9, PBWin 10
#Compile EXE
#Dim All
%Unicode=1
#Resource "gbsnippets.pbr"
%IDC_Button = 500
Global hDlg As Dword, bStatus As Long
 
Function PBMain() As Long
   Dialog New Pixels, 0, "ImgButton Test",300,300,200,200, %WS_SysMenu, 0 To hDlg
   Control Add ImgButton, hDlg, %IDC_Button,"cowgirl", 50,50,100,100
   Dialog Show Modal hDlg Call DlgProc
End Function
 
CallBack Function DlgProc() As Long
   Select Case Cb.Msg
      Case %WM_Command
         Select Case Cb.Ctl
            Case %IDC_Button
               bStatus = bStatus Xor 1
               If bStatus Then
                  Control Set ImgButton Cb.Hndl, Cb.Ctl, "smallface"
               Else
                  Control Set ImgButton Cb.Hndl, Cb.Ctl, "cowgirl"
               End If
               Control ReDraw Cb.Hndl, Cb.Ctl
         End Select
   End Select
End Function
 
'gbs_01144
'Date: 03-10-2012


created by gbSnippets
http://www.garybeene.com/sw/gbsnippets.htm