10-19-2024, 12:00 AM
Hi friends
here a simple demo to get a picturebutton with rollover effect
please download the attached image or use another of your choice. In this second case, please change the name and path of the image to load with _LOADIMAGE.
then
copy and paste this code into QB64IDE and save it in the same folder of the image downloaded or choosen by you.
At the end press F5 and see the result.
here a simple demo to get a picturebutton with rollover effect
Code: (Select All)
Rem demo of a pictureButton with rollover effect
Rem here we use one image to load and we create the rollover image on fly
DefLng L
Lscreen = _NewImage(800, 600, 32)
Screen Lscreen
_Title "Rollover PictureButton example"
Cls , _RGBA(127, 28, 211, 255)
If _FileExists("QB64bee.jpeg") Then LBee1 = _LoadImage("QB64bee.jpeg") Else _PrintString (10, 200), "Not found QB64bee"
' here we create the second image used for rollover effect
Lbee2 = _NewImage(50, 50, 32)
_Dest Lbee2
Line (0, 0)-(50, 50), _RGBA(227, 72, 17, 255), BF
_PutImage (3, 3)-(45, 45), LBee1, Lbee2
_Dest 0
_PrintString (10, 140), " move mouse over and out of button, press leftclick on the button, press rightclick to quit"
_PutImage (30, 50)-(80, 100), LBee1, Lscreen ' show picturebutton
Do
If _MouseInput Then
If InTheMiddle(30, 80, _MouseX) Then
If InTheMiddle(50, 100, _MouseY) Then
lbee = Lbee2
Else
lbee = LBee1
End If
Else
lbee = LBee1
End If
_PutImage (30, 50)-(80, 100), lbee, Lscreen
End If
If _MouseButton(1) And lbee = Lbee2 Then Msg$ = " You have clicked on the button" Else Msg$ = Space$(40)
_PrintString (10, 200), Msg$
Loop Until _MouseButton(2) = -1
End
Function InTheMiddle (min As Integer, max As Integer, value As Integer)
If min > max Then Swap min, max
If min < value And value < max Then
InTheMiddle = -1
Else
InTheMiddle = 0
End If
End Function
please download the attached image or use another of your choice. In this second case, please change the name and path of the image to load with _LOADIMAGE.
then
copy and paste this code into QB64IDE and save it in the same folder of the image downloaded or choosen by you.
At the end press F5 and see the result.