Sign in to follow this  
Followers 0
incepator

Button png with Hover

3 posts in this topic

Hi guys,
I am looking for a good and stable method to put a button png in a form, which have a beautiful interface, and to look like a button.

Eventually, I managed to do that, just after I click on it ... Button clarity is lost.

If you have a simple idea to solve this problem, I would be very happy.

Thank you!

#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include "GUICtrlOnHover.au3"
#include <GDIPlus.au3>
_GDIPlus_Startup()

#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 615, 438, 192, 124)
$Button1 = GUICtrlCreatePic("", 5, 40, 40, 40)
_GUICtrl_OnHoverRegister(-1, "_Hover_Proc", "_Leave_Hover_Proc", "PrimaryDown_Proc", "PrimaryUp_Proc")
SendImageToPicControl("back1.png", $Button1)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit

    EndSwitch
WEnd
Func SendImageToPicControl($sImage, $iCtrlID)
    Local Const $hImage = _GDIPlus_ImageLoadFromFile($sImage)
    Local Const $hHBitmap = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hImage)
    _WinAPI_DeleteObject(GUICtrlSendMsg($iCtrlID, 0x0172, $IMAGE_BITMAP, $hHBitmap))
    _WinAPI_DeleteObject($hHBitmap)
    _GDIPlus_ImageDispose($hImage)
EndFunc   ;==>SendImageToPicControl

Func _Hover_Proc($iCtrlID)
    Switch $iCtrlID
        Case $Button1
            SendImageToPicControl("back2.png", $Button1)
    EndSwitch
EndFunc   ;==>_Hover_Proc

Func _Leave_Hover_Proc($iCtrlID)
    Switch $iCtrlID
        Case $Button1
            SendImageToPicControl("back1.png", $Button1)
    EndSwitch
EndFunc   ;==>_Leave_Hover_Proc

Func PrimaryDown_Proc($iCtrlID)
    Switch $iCtrlID
        Case $Button1
            SendImageToPicControl("back3.png", $Button1)
    EndSwitch
EndFunc   ;==>PrimaryDown_Proc

Func PrimaryUp_Proc($iCtrlID)
    Switch $iCtrlID
        Case $Button1
            SendImageToPicControl("back2.png", $Button1)
    EndSwitch
EndFunc   ;==>PrimaryUp_Proc

post-75717-0-09155400-1414285751.png

post-75717-0-24666300-1414285751.png

post-75717-0-40517700-1414285751.png

GUICtrlOnHover.au3

Share this post


Link to post
Share on other sites



Before you put the cursor on the arrow, it is clear image, but after you put the cursor on the arrow, the arrow clearly is low.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0