samm Posted September 17, 2012 Posted September 17, 2012 (edited) Currently I'm using the following code:$run = GUICtrlCreateButton("Run", 640, 90, 164, 55, $BS_BITMAP)GUICtrlSetImage(-1, @Tempdir&"run.bmp", 1)to create an image button from a BMP image file, in the fact, it doesn't support transparency I would like to use PNG image instead, but I think there is no support by default for PNG image files?How can I then display PNG image and use it as a button? Edited September 17, 2012 by samm
FireFox Posted September 17, 2012 Posted September 17, 2012 (edited) Hi, It's possible with GDIPlus, there are many examples if you search on the forum (section Example Scripts). Br, FireFox. Edited September 17, 2012 by FireFox
samm Posted September 17, 2012 Author Posted September 17, 2012 (edited) Yep I was searching alot before creating this thread and didnt found anything interesting for my keywords:GoogleNothing really interesting found. Edited September 17, 2012 by samm
Kyan Posted September 17, 2012 Posted September 17, 2012 just set it to your button handle: Heroes, there is no such thing One day I'll discover what IE.au3 has of special for so many users using it.C'mon there's InetRead and WinHTTP, way better
UEZ Posted September 17, 2012 Posted September 17, 2012 Try this: expandcollapse popup;coded by UEZ 2012 #include <WindowsConstants.au3> #include <ButtonConstants.au3> #include <GUIConstantsEx.au3> #include <GDIPlus.au3> _GDIPlus_Startup() Global Const $IMAGE_BITMAP = 0 Global Const $STM_SETIMAGE = 0x0172 Global $msg Global Const $hGUI = GUICreate("Test", 600, 250) Global Const $idLogo = GUICtrlCreatePic("", 215, 20, 169, 68) Global Const $idButton = GUICtrlCreateButton("", 266, 150, 78 , 81, $BS_BITMAP) Global Const $hButton = GUICtrlGetHandle($idButton) Global $hBmp, $hBmp_Logo, $hBmp_Button If @OSBuild < 6000 Then $hBmp = _GDIPlus_ImageLoadFromFile(StringReplace(@AutoItExe, "autoit3.exe", "ExamplesGUIlogo4.gif")) $hBmp_Logo = ConvertBitmap($hBmp) _GDIPlus_BitmapDispose($hBmp) Else $hBmp = _GDIPlus_ImageLoadFromFile(StringReplace(@AutoItExe, "autoit3.exe", "ExamplesGUIlogo4.gif")) $hBmp_Logo = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hBmp) _GDIPlus_BitmapDispose($hBmp) EndIf _WinAPI_DeleteObject(GUICtrlSendMsg($idLogo, $STM_SETIMAGE, $IMAGE_BITMAP, $hBmp_Logo)) If @OSBuild < 6000 Then $hBmp = _GDIPlus_ImageLoadFromFile(StringReplace(@AutoItExe, "autoit3.exe", "ExamplesGUIMerlin.gif")) $hBmp_Button = ConvertBitmap($hBmp) _GDIPlus_BitmapDispose($hBmp) Else $hBmp = _GDIPlus_ImageLoadFromFile(StringReplace(@AutoItExe, "autoit3.exe", "ExamplesGUIMerlin.gif")) $hBmp_Button = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hBmp) EndIf _WinAPI_DeleteObject(_SendMessage($hButton, $BM_SETIMAGE, $IMAGE_BITMAP, $hBmp_Button)) ;~ _WinAPI_UpdateWindow($hButton) GUISetState() While True Switch GUIGetMsg() Case $idLogo MsgBox(0, "Information", "Image was clicked!") Case $idButton MsgBox(0, "Information", "Button was clicked!") Case $GUI_EVENT_CLOSE _WinAPI_DeleteObject($hBmp_Logo) _WinAPI_DeleteObject($hBmp_Button) GUIDelete($hGUI) _GDIPlus_Shutdown() Exit EndSwitch WEnd Func ConvertBitmap($hBitmap) Local $iButtonColor = _WinAPI_GetSysColor($COLOR_BTNFACE) $iButtonColor = 0x10000 * BitAND($iButtonColor, 0xFF) + BitAND($iButtonColor, 0x00FF00) + BitShift($iButtonColor, 16) Local $iWidth = _GDIPlus_ImageGetWidth($hBitmap), $iHeight = _GDIPlus_ImageGetHeight($hBitmap) Local $aResult = DllCall($ghGDIPDll, "uint", "GdipCreateBitmapFromScan0", "int", $iWidth, "int", $iHeight, "int", 0, "int", 0x0026200A, "ptr", 0, "int*", 0) Local $hBitmap_New = $aResult[6] Local $hCtx_new = _GDIPlus_ImageGetGraphicsContext($hBitmap_New) Local $hBrush = _GDIPlus_BrushCreateSolid(0xFF000000 + $iButtonColor) _GDIPlus_GraphicsFillRect($hCtx_new, 0, 0, $iWidth, $iHeight, $hBrush) _GDIPlus_GraphicsDrawImageRect($hCtx_new, $hBitmap, 0, 0, $iWidth, $iHeight) Local $hHBitmap = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hBitmap_New) _GDIPlus_BrushDispose($hBrush) _GDIPlus_BitmapDispose($hBitmap_New) _GDIPlus_GraphicsDispose($hCtx_new) Return $hHBitmap EndFunc Br, UEZ Please don't send me any personal message and ask for support! I will not reply! Selection of finest graphical examples at Codepen.io The own fart smells best! ✌Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!¯\_(ツ)_/¯ ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ
FireFox Posted September 17, 2012 Posted September 17, 2012 Of course, you just needed to ask to the god of GDIPlus...
samm Posted September 17, 2012 Author Posted September 17, 2012 (edited) @UEZ I have changed: $run = GUICtrlCreateButton("Run", 640, 90, 164, 55, $BS_BITMAP) GUICtrlSetImage(-1, @Tempdir&"run.bmp", 1) Into the: Global Const $run= GUICtrlCreateButton("", 640, 90, 164, 55, $BS_BITMAP) Global Const $hButton = GUICtrlGetHandle($start) Global $hBmp, $hBmp_Button If @OSBuild < 6000 Then $hBmp = _GDIPlus_ImageLoadFromFile(StringReplace(@AutoItExe, "autoit3.exe", @Tempdir&"run.png")) $hBmp_Button = ConvertBitmap($hBmp) _GDIPlus_BitmapDispose($hBmp) Else $hBmp = _GDIPlus_ImageLoadFromFile(StringReplace(@AutoItExe, "autoit3.exe", @Tempdir&"run.png")) $hBmp_Button = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hBmp) EndIf _WinAPI_DeleteObject(_SendMessage($hButton, $BM_SETIMAGE, $IMAGE_BITMAP, $hBmp_Button)) But the image not appear. Edited September 17, 2012 by samm
UEZ Posted September 17, 2012 Posted September 17, 2012 The line _GDIPlus_ImageLoadFromFile(StringReplace(@AutoItExe, "autoit3.exe", @Tempdir&"run.png")) is probably your problem. Try instead _GDIPlus_ImageLoadFromFile(@Tempdir&"run.png") Br, UEZ Please don't send me any personal message and ask for support! I will not reply! Selection of finest graphical examples at Codepen.io The own fart smells best! ✌Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!¯\_(ツ)_/¯ ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ
samm Posted September 17, 2012 Author Posted September 17, 2012 Its me, samm I've just exceeded that anoying limit which is 3 posts per day...Anyway, @UEZ I have already tried that, and it still doesn't show the image. :/
UEZ Posted September 17, 2012 Posted September 17, 2012 (edited) Show your full code and I will check what's wrong. Of course, you just needed to ask to the god of GDIPlus... I would never say god - I have only some basic skills, that's all...Br,UEZ Edited September 17, 2012 by UEZ Please don't send me any personal message and ask for support! I will not reply! Selection of finest graphical examples at Codepen.io The own fart smells best! ✌Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!¯\_(ツ)_/¯ ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ
samm Posted September 17, 2012 Author Posted September 17, 2012 (edited) Could I send PM to you? (I think you can not receive PM's because there is no option to contact you in a private) Or is there any other place we can hangout because I don't want this code to be public, I hope you understand. Edited September 17, 2012 by pompex
UEZ Posted September 17, 2012 Posted September 17, 2012 If it is not against our forum rules you can send me a pm this time exceptionallyBr,UEZ Please don't send me any personal message and ask for support! I will not reply! Selection of finest graphical examples at Codepen.io The own fart smells best! ✌Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!¯\_(ツ)_/¯ ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ
bogQ Posted September 17, 2012 Posted September 17, 2012 The line _GDIPlus_ImageLoadFromFile(StringReplace(@AutoItExe, "autoit3.exe", @Tempdir&"\run.png")) is probably your problem. he totally ripped it off from my sig TCP server and client - Learning about TCP servers and clients connectionAu3 oIrrlicht - Irrlicht projectAu3impact - Another 3D DLL game engine for autoit. (3impact 3Drad related) There are those that believe that the perfect heist lies in the preparation.Some say that it’s all in the timing, seizing the right opportunity. Others even say it’s the ability to leave no trace behind, be a ghost.
samm Posted September 17, 2012 Author Posted September 17, 2012 @bogQYea, funny as hell.@UEZI still can not send you a PM . Its the last post I can post from this account... again, I cant understand such rules but nevermind. I will really appreciate if you could contact me via Skype - cycl0ne_ I'm waiting for your help.Regards.
samm Posted September 18, 2012 Author Posted September 18, 2012 Uh, yea, I can make another two posts today. First of all , UEZ could you still try to help me in any other way, because I can not send a PM to you so do you prefer something?
Administrators Jon Posted September 18, 2012 Administrators Posted September 18, 2012 You have to wait 24 hours before your PMs are unlocked. This helps prevents the vast amounts of troublemakers and spammers we get. Multiple accounts are not allowed. Please state which account you wish to keep and I will delete the others. Deployment Blog: https://www.autoitconsulting.com/site/blog/ SCCM SDK Programming: https://www.autoitconsulting.com/site/sccm-sdk/
samm Posted September 18, 2012 Author Posted September 18, 2012 You have to wait 24 hours before your PMs are unlocked. This helps prevents the vast amounts of troublemakers and spammers we get. Multiple accounts are not allowed. Please state which account you wish to keep and I will delete the others.Okay, thank you for explanation. I would like to keep this account I'm writing from - samm, sorry for difficulties.
samm Posted September 19, 2012 Author Posted September 19, 2012 Could someone help me? I still need help with my problem.
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