Lope Posted April 18, 2011 Share Posted April 18, 2011 (edited) This function which creates a nice looking button even if windows has a 'classic' visual appearance. The button is composed of an image and a label (with transparent background) on top. I'm having issues where depending where I put the button. I'm unable to get the click GUI msg from it. If I set the image state to ($GUI_ONTOP + $GUI_SHOW) Then it works wherever I put the button, but then the image is not visible and I only see the label I've got some buttons lower down ontop of a window background image. I set the state of the window s background image to $GUI_DISABLE, then they work fine, But I've still got another button in the middle of the form that doesn't give its GUI event ID. Any Ideas? Func CreateNiceButton($caption,$x,$y,Byref $h_btnlbl) ;returns handle for 'button' which is actually an image ;Requires _GDIPlus_Startup (), #include <ButtonConstants.au3>, #include <StaticConstants.au3> Local $h_btnimg=GUICtrlCreatePic($depfile_ButtonImage,$x,$y,$width_nicebtnimg,$height_nicebtnimg) $h_btnlbl = GUICtrlCreateLabel($caption, $x, $y, $width_nicebtnimg,$height_nicebtnimg,BitOR($SS_CENTER,$BS_CENTER)) ;GUICtrlSetState(-1,$GUI_ONTOP) GUICtrlSetBkColor($h_btnlbl, $GUI_BKCOLOR_TRANSPARENT) Return $h_btnimg EndFunc Edited April 20, 2011 by Lope Link to comment Share on other sites More sharing options...
taietel Posted April 19, 2011 Share Posted April 19, 2011 Maybe this is what you're looking for: #include <GUIConstantsEx.au3> #include <StaticConstants.au3> $Form1 = GUICreate("Form1", 278, 153) $Pic1 = GUICtrlCreatePic("C:\Program Files\AutoIt3\Examples\GUI\msoobe.jpg", 0, 2, 276, 148) GUICtrlSetState(-1, $GUI_DISABLE) $Pic2 = GUICtrlCreatePic("C:\Program Files\AutoIt3\Examples\GUI\Advanced\Images\Green.bmp", 80, 48, 132, 44) GUICtrlSetCursor(-1,0) GUICtrlSetState(-1, $GUI_DISABLE) $Label1 = GUICtrlCreateLabel("Click me!", 80, 48, 132, 44, BitOR($SS_CENTER,$SS_CENTERIMAGE)) GUICtrlSetBkColor(-1,$GUI_BKCOLOR_TRANSPARENT) GUICtrlSetCursor(-1,0) GUISetState(@SW_SHOW) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Pic2, $Label1 MsgBox(0,"Yep!","There it is!") EndSwitch WEnd Things you should know first...In the beginning there was only ONE! And zero... Progs: Create PDF(TXT2PDF,IMG2PDF) 3D Bar Graph DeskGadget Menu INI Photo Mosaic 3D Text Link to comment Share on other sites More sharing options...
Lope Posted April 20, 2011 Author Share Posted April 20, 2011 Thank you... helped me solve it. Another problem is I was drawing a label AFTER the button, which I should have drawn before. Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now