ImgButton - Change Image in ImgButton When Pressed I

Category: Controls - .Techniques

Date: 03-28-2012

Return to Index


 
'Compilable Example:
#Compiler PBWin 10
#Compile EXE
#Dim All
#Resource Bitmap, cowgirl, "cowgirl.bmp"
#Resource Bitmap, cowboy, "cowboy.bmp"
%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.HndlCb.Ctl, "cowboy"
               Else
                  Control Set ImgButton Cb.HndlCb.Ctl, "cowgirl"
               End If
               Control ReDraw Cb.HndlCb.Ctl
         End Select
   End Select
End Function
 
'gbs_00788
'Date: 03-10-2012


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