4ggr35510n Posted February 16, 2011 Posted February 16, 2011 (edited) Greetings! I'd like to create button with .png image on it. Yet I cannot make the thing to work properly I've started from GuiCtrlSendMsg function which works perfect to set .png images in GuiCtrlPic controls... Yet it can't create transparent background with button controls Below it's the code I've got so far: (it might ask u for dling one small png image, so u could see the problem)expandcollapse popup#include <GdiPlus.au3> $hGui = GUICreate('') $hButton = GUICtrlCreateButton('', 10, 10, 128, 128, 0x0080) ; BS_BITMAP style $hStaticLabel = GUICtrlCreatePic('', 10, 150, 128, 128) ; no style needed ; I will Download PNG Image for you... I hope it's okay... If Not FileExists('plus.png') Then ; I will Download PNG Image for you... I hope it's okay... If MsgBox(4, 'Question for you my dear...', 'Is it OKAY to download small png image from google images?') = 6 Then InetGet('http://www.smyku.pl/img/plus.png', 'plus.png') Else Exit MsgBox(0, '', 'Bye bye then <img src='http://www.autoitscript.com/forum/public/style_emoticons/<#EMO_DIR#>/sad.png' class='bbc_emoticon' alt=':(' />') EndIf EndIf _GDIPlus_Startup() $hPngImage = _GDIPlus_ImageLoadFromFile('plus.png') Global $iARGB = 0xFF000000 ; you can manipulate with that, making it white, yellow, blue, etc. etc. backgrounded... But not transparent <img src='http://www.autoitscript.com/forum/public/style_emoticons/<#EMO_DIR#>/sad.png' class='bbc_emoticon' alt=':(' /> $hBitmapHandle = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hPngImage, $iARGB) ; Setting image to a Static / Label - works FINE, background is fully transparent GUICtrlSendMsg($hStaticLabel, 0x0172, 0, $hBitmapHandle) ; 0x0172 == STM_SETIMAGE msg ; Setting image to a Button - works _NOT_AT_ALL_ GUICtrlSendMsg($hButton, 0x0F7, 0, $hBitmapHandle) ; 0x0F7 == BM_SETIMAGE msg GUISetState() Do $msg = GUIGetMsg() Switch $msg Case -3 _WinAPI_DeleteObject($hBitmapHandle) ; cleaning resources _GDIPlus_ImageDispose($hPngImage) ; x2 Exit Case $hButton MsgBox(0, "I'm a button", _ "It's _NOT_ a racist thing... I just don't want to be black any more <img src='http://www.autoitscript.com/forum/public/style_emoticons/<#EMO_DIR#>/sad.png' class='bbc_emoticon' alt=':(' />" & _ @CRLF & _ @CRLF & _ "NOT white neither... I just want to be _TRANSPARENT_! Can you help me...? <img src='http://www.autoitscript.com/forum/public/style_emoticons/<#EMO_DIR#>/sad.png' class='bbc_emoticon' alt=':(' />" ) EndSwitch Until FalseMaybe you will know how to make this code work...? It's the same method _GuiCtrlButton_SetImage() function is using... For Buttons works only with .bmp / .icoFor Pics works with everything. How come?Best regards, hoping for your help, 4ggr35510n Edited February 16, 2011 by 4ggr35510n
Gideon Posted February 17, 2011 Posted February 17, 2011 (edited) I already had that solution in the example forum, I will search for it.EDIT: This was only for gui.But you can make a little gui where you can click on.It was somewhere on the forum, You saw a heart and a windows gray logo, when you clicked it stopped blinking.I will search furtherTake a look at this.And here And here is your solution I think: Edited February 17, 2011 by Gideon Many times you need to think like hobby-bob:')
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