motionman95 Posted April 15, 2009 Share Posted April 15, 2009 Is it possible to do this (put images in buttons?):I've searched, but I haven't found anything.Thanks in advance! Link to comment Share on other sites More sharing options...
ProgAndy Posted April 15, 2009 Share Posted April 15, 2009 Here is an example: http://www.autoitscript.com/forum/index.ph...st&p=572734You can add bitmaps and Icons to the imagelist. *GERMAN* [note: you are not allowed to remove author / modified info from my UDFs]My UDFs:[_SetImageBinaryToCtrl] [_TaskDialog] [AutoItObject] [Animated GIF (GDI+)] [ClipPut for Image] [FreeImage] [GDI32 UDFs] [GDIPlus Progressbar] [Hotkey-Selector] [Multiline Inputbox] [MySQL without ODBC] [RichEdit UDFs] [SpeechAPI Example] [WinHTTP]UDFs included in AutoIt: FTP_Ex (as FTPEx), _WinAPI_SetLayeredWindowAttributes Link to comment Share on other sites More sharing options...
motionman95 Posted April 15, 2009 Author Share Posted April 15, 2009 Is there a Vista compatible solution? Link to comment Share on other sites More sharing options...
ProgAndy Posted April 15, 2009 Share Posted April 15, 2009 This should work with Vista, too i think. Just the images used in the example aren't there. *GERMAN* [note: you are not allowed to remove author / modified info from my UDFs]My UDFs:[_SetImageBinaryToCtrl] [_TaskDialog] [AutoItObject] [Animated GIF (GDI+)] [ClipPut for Image] [FreeImage] [GDI32 UDFs] [GDIPlus Progressbar] [Hotkey-Selector] [Multiline Inputbox] [MySQL without ODBC] [RichEdit UDFs] [SpeechAPI Example] [WinHTTP]UDFs included in AutoIt: FTP_Ex (as FTPEx), _WinAPI_SetLayeredWindowAttributes Link to comment Share on other sites More sharing options...
motionman95 Posted April 20, 2009 Author Share Posted April 20, 2009 Thanks, ProgAndy. Is there a way to make the background of the bitmap transparent? Link to comment Share on other sites More sharing options...
motionman95 Posted April 21, 2009 Author Share Posted April 21, 2009 Bump Link to comment Share on other sites More sharing options...
youknowwho4eva Posted April 21, 2009 Share Posted April 21, 2009 @motionman95, don't bump unless there is no reply for 24 hours. The only way I know of to have transparencies would be to use gdi+ to use a png Giggity Link to comment Share on other sites More sharing options...
ProgAndy Posted April 21, 2009 Share Posted April 21, 2009 (edited) You can add the Bitmap masked _GUIImageList_AddBitmap if you have the mask as bitmap or_GUIImageList_AddMasked if you want to specify the transcolor-> I wrote an extra func, so you can specify the path:; #FUNCTION# ==================================================================================================================== ; Name...........: _GUIImageList_AddBitmapMasked ; Description ...: Adds a bitmap to an image list, generating a mask from the specified color ; Syntax.........: _GUIImageList_AddBitmapMasked($hWnd, $sImage, $iMask) ; Parameters ....: $hWnd - Handle to the control ; $sImage - Path to the bitmap that contains the image ; $iMask - Color used to generate the mask. Each pixel of this color in the specified bitmap is changed to ; +black, and the corresponding bit in the mask is set to 1. ; Return values .: Success - The index of the image ; Failrue - -1 ; Author ........: Paul Campbell (PaulIA), Prog@ndy ; Modified.......: ; Remarks .......: ; Related .......: _GUIImageList_AddMasked ; Link ..........; ; Example .......; Yes ; =============================================================================================================================== Func _GUIImageList_AddBitmapMasked($hWnd, $sImage, $iMask = 0) Local $hImage, $hMask = 0, $aSize, $iResult $aSize = _GUIImageList_GetIconSize($hWnd) $hImage = _WinAPI_LoadImage(0, $sImage, $__IMAGELISTCONSTANT_IMAGE_BITMAP, $aSize[0], $aSize[1], $__IMAGELISTCONSTANT_LR_LOADFROMFILE) If $hImage = 0 Then Return SetError(_WinAPI_GetLastError(), 1, -1) $iResult = _GUIImageList_AddMasked($hWnd, $hImage, $iMask) _WinAPI_DeleteObject($hImage) Return $iResult EndFunc ;==>_GUIImageList_AddBitmapMaskedWith this function, you can specif the color wich will become transparent. (only if you add Option 1 to your imagelist, e.g. _GUIImageList_Create(24, 24,5, 1))//Edit: i think, the $iMask should be COLORREF (BGR not RGB) Edited April 21, 2009 by ProgAndy *GERMAN* [note: you are not allowed to remove author / modified info from my UDFs]My UDFs:[_SetImageBinaryToCtrl] [_TaskDialog] [AutoItObject] [Animated GIF (GDI+)] [ClipPut for Image] [FreeImage] [GDI32 UDFs] [GDIPlus Progressbar] [Hotkey-Selector] [Multiline Inputbox] [MySQL without ODBC] [RichEdit UDFs] [SpeechAPI Example] [WinHTTP]UDFs included in AutoIt: FTP_Ex (as FTPEx), _WinAPI_SetLayeredWindowAttributes Link to comment Share on other sites More sharing options...
trancexx Posted April 22, 2009 Share Posted April 22, 2009 @motionman95, don't bump unless there is no reply for 24 hours....Only 21 h 14 min passed. I don't know, that's close. ...Ahhh, shot him!@ProgAndy, yes BGR. ♡♡♡ . eMyvnE Link to comment Share on other sites More sharing options...
motionman95 Posted April 29, 2009 Author Share Posted April 29, 2009 $Remove_Button = GUICtrlCreateButton("Delete Item", 8, 192, 73, 25) $hImagebtn3 = _GUIImageList_Create(16, 16, 5, 1) _GUIImageList_AddBitmapMasked($Remove_Button, "C:\Documents and Settings\Owner\My Documents\Autoit Applications\Forms\RockboxFNTConverter\button_icons\delete.bmp", 0x000000) _GUICtrlButton_SetImageList($Remove_Button, $hImagebtn3) I tried this...but all I got was blank patch inside my button. What am I doing wrong? Link to comment Share on other sites More sharing options...
ProgAndy Posted April 29, 2009 Share Posted April 29, 2009 (edited) Strange, this works for me on XP: expandcollapse popup;#AutoIt3Wrapper_au3check_parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 #include <GUIConstantsEx.au3> #include <GuiButton.au3> #include <GuiImageList.au3> Opt("MustDeclareVars", 1) _Main() Func _Main() Local $sBMPNormal = @ScriptDir&"\test.bmp" Local $btn1 Local $hImagebtn1 Local $msg, $hGUI ;Caveat: Minimum Operating Systems: Windows XP. ;Image list with multiple images will only show the images ;other than the 1st image when Themes are used. $hGUI = GUICreate("Button Imagelists - Minimum OS: Windows XP",400,300) GUICtrlCreatePic(@WindowsDir & "\Web\Wallpaper\Windows XP.jpg", 0, 0, 400, 300) GUICtrlSetState(-1, $GUI_DISABLE) ;multi state image Bitmap $btn1 = GUICtrlCreateButton("This Way", 30, 30, 90, 32) GUICtrlSetTip(-1, "Multi state bitmap imagelist") $hImagebtn1 = _GUIImageList_Create(24, 24, 5, 5) _GUIImageList_AddBitmapMasked($hImagebtn1, $sBMPNormal,0xFFFFFF);1 - Normal _GUICtrlButton_SetImageList($btn1, $hImagebtn1) GUISetState() While 1 $msg = GUIGetMsg() Switch $msg Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd EndFunc ;==>_Main ; #FUNCTION# ==================================================================================================================== ; Name...........: _GUIImageList_AddBitmapMasked ; Description ...: Adds a bitmap to an image list, generating a mask from the specified color ; Syntax.........: _GUIImageList_AddBitmapMasked($hWnd, $sImage, $iMask) ; Parameters ....: $hWnd - Handle to the control ; $sImage - Path to the bitmap that contains the image ; $iMask - Color used to generate the mask. Each pixel of this color in the specified bitmap is changed to ; +black, and the corresponding bit in the mask is set to 1. ; Return values .: Success - The index of the image ; Failrue - -1 ; Author ........: Paul Campbell (PaulIA), Prog@ndy ; Modified.......: ; Remarks .......: ; Related .......: _GUIImageList_AddMasked ; Link ..........; ; Example .......; Yes ; =============================================================================================================================== Func _GUIImageList_AddBitmapMasked($hWnd, $sImage, $iMask = 0) Local $hImage, $hMask = 0, $aSize, $iResult $aSize = _GUIImageList_GetIconSize($hWnd) $hImage = _WinAPI_LoadImage(0, $sImage, $__IMAGELISTCONSTANT_IMAGE_BITMAP, $aSize[0], $aSize[1], $__IMAGELISTCONSTANT_LR_LOADFROMFILE) If $hImage = 0 Then Return SetError(_WinAPI_GetLastError(), 1, -1) $iResult = _GUIImageList_AddMasked($hWnd, $hImage, $iMask) _WinAPI_DeleteObject($hImage) Return $iResult EndFunc ;==>_GUIImageList_AddBitmapMasked //Edit: Do you have 64bit? Maybe there are some structs not created properly for 64bit OS ... Edited April 29, 2009 by ProgAndy *GERMAN* [note: you are not allowed to remove author / modified info from my UDFs]My UDFs:[_SetImageBinaryToCtrl] [_TaskDialog] [AutoItObject] [Animated GIF (GDI+)] [ClipPut for Image] [FreeImage] [GDI32 UDFs] [GDIPlus Progressbar] [Hotkey-Selector] [Multiline Inputbox] [MySQL without ODBC] [RichEdit UDFs] [SpeechAPI Example] [WinHTTP]UDFs included in AutoIt: FTP_Ex (as FTPEx), _WinAPI_SetLayeredWindowAttributes Link to comment Share on other sites More sharing options...
motionman95 Posted August 7, 2010 Author Share Posted August 7, 2010 Old thread, I know - but if someone could help me out again...I'd be really grateful. I've been searching the forums, but all I've found are ways to use PNGs as buttons - but not inside a button. ProgAndy's function has been working great, but now I need to use a transparent icon inside my button, and BMP files aren't up to par. Is there anyway to add PNG support? Link to comment Share on other sites More sharing options...
seandisanti Posted August 7, 2010 Share Posted August 7, 2010 (edited) Old thread, I know - but if someone could help me out again...I'd be really grateful. I've been searching the forums, but all I've found are ways to use PNGs as buttons - but not inside a button. ProgAndy's function has been working great, but now I need to use a transparent icon inside my button, and BMP files aren't up to par. Is there anyway to add PNG support?not to oversimplify, but if you can use a png as a button, and you can set the size of the other button, and make both buttons do the same thing, how would your user know that the png is not just an image on the button?***edit*** i mean of course if you positioned the png button on top of the button that it's supposed to look like it's a graphic on... just in case that wasn't clear... Edited August 7, 2010 by cameronsdad Link to comment Share on other sites More sharing options...
motionman95 Posted August 7, 2010 Author Share Posted August 7, 2010 not to oversimplify, but if you can use a png as a button, and you can set the size of the other button, and make both buttons do the same thing, how would your user know that the png is not just an image on the button?***edit*** i mean of course if you positioned the png button on top of the button that it's supposed to look like it's a graphic on... just in case that wasn't clear......I think my brain just exploded. Link to comment Share on other sites More sharing options...
seandisanti Posted August 7, 2010 Share Posted August 7, 2010 ...I think my brain just exploded.you're welcome i think? Link to comment Share on other sites More sharing options...
motionman95 Posted August 8, 2010 Author Share Posted August 8, 2010 not to oversimplify, but if you can use a png as a button, and you can set the size of the other button, and make both buttons do the same thing, how would your user know that the png is not just an image on the button?***edit*** i mean of course if you positioned the png button on top of the button that it's supposed to look like it's a graphic on... just in case that wasn't clear...So you're saying I could just position a PNG over a button control? Link to comment Share on other sites More sharing options...
motionman95 Posted August 8, 2010 Author Share Posted August 8, 2010 Never mind, I solved the PNG problem, but with ProgAndy's code is there any way to center the image inside the button? Link to comment Share on other sites More sharing options...
motionman95 Posted August 8, 2010 Author Share Posted August 8, 2010 Gah, I'm an idiot. I went through about 50 functions before I realized it was in a function I was already using. >.< 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