regi Posted December 3, 2009 Posted December 3, 2009 Hi, I'm including an icon in in my build, but when showing it in a gui instead of being 48 x 48, it defaults to 32 x 32, is this a bug? Or am I missing something here? Demo script and attached icon file below... #Region #AutoIt3Wrapper_Res_Icon_Add=I:\numbers.ico #EndRegion #include <GUIConstants.au3> GUICreate(" My GUI Icons") $icon = GUICtrlCreateIcon (@ScriptFullPath, -5, 20, 20, 48, 48) GUISetState() While 1 $msg = GUIGetMsg() If $msg = $GUI_EVENT_CLOSE Then ExitLoop Wend This however, works fine: #include <GUIConstants.au3> GUICreate(" My GUI Icons") $icon = GUICtrlCreateIcon ("numbers.ico",-1, 20, 20, 48, 48) GUISetState() While 1 $msg = GUIGetMsg() If $msg = $GUI_EVENT_CLOSE Then ExitLoop Wend Source: http://www.autoitscript.com/forum/index.php?showtopic=14606numbers.ico
GEOSoft Posted December 3, 2009 Posted December 3, 2009 I believe that the next beta versiuon will support larger icons. Until then 32x32 is as large as you can use. George Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.*** The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number. Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else. "Old age and treachery will always overcome youth and skill!"
regi Posted December 3, 2009 Author Posted December 3, 2009 Oh, that's a shame. Thanks for the prompt reply though!
AdmiralAlkex Posted December 3, 2009 Posted December 3, 2009 Oh, that's a shame. Thanks for the prompt reply though!An icon bug was fixed in the latest beta, did you try that? .Some of my scripts: ShiftER, Codec-Control, Resolution switcher for HTC ShiftSome of my UDFs: SDL UDF, SetDefaultDllDirectories, Converting GDI+ Bitmap/Image to SDL Surface
Yashied Posted December 4, 2009 Posted December 4, 2009 (edited) You can also use Icons.au3. In it, the problem was solved long ago. Edited December 4, 2009 by Yashied My UDFs: iKey | FTP Uploader | Battery Checker | Boot Manager | Font Viewer | UDF Keyword Manager | Run Dialog Replacement | USBProtect | 3D Axis | Calculator | Sleep | iSwitcher | TM | NetHelper | File Types Manager | Control Viewer | SynFolders | DLL Helper Animated Tray Icons UDF Library | Hotkeys UDF Library | Hotkeys Input Control UDF Library | Caret Shape UDF Library | Context Help UDF Library | Most Recently Used List UDF Library | Icons UDF Library | FTP UDF Library | Script Communications UDF Library | Color Chooser UDF Library | Color Picker Control UDF Library | IPHelper (Vista/7) UDF Library | WinAPI Extended UDF Library | WinAPIVhd UDF Library | Icon Chooser UDF Library | Copy UDF Library | Restart UDF Library | Event Log UDF Library | NotifyBox UDF Library | Pop-up Windows UDF Library | TVExplorer UDF Library | GuiHotKey UDF Library | GuiSysLink UDF Library | Package UDF Library | Skin UDF Library | AITray UDF Library | RDC UDF Library Appropriate path | Button text color | Gaussian random numbers | Header's styles (Vista/7) | ICON resource enumeration | Menu & INI | Tabbed string size | Tab's skin | Pop-up circular menu | Progress Bar without animation (Vista/7) | Registry export | Registry path jumping | Unique hardware ID | Windows alignment More...
regi Posted December 4, 2009 Author Posted December 4, 2009 An icon bug was fixed in the latest beta, did you try that?Just tried 3.3.1.6, same result.You can also use Icons.au3. In it, the problem was solved long ago.Thanks, I'll look into it
Zedna Posted December 4, 2009 Posted December 4, 2009 (edited) AutoIt Changelog 3.3.1.6 (XX November, 2009) (Beta)AutoIt:- Added #1270: GuiSetIcon() now finds suitable large and small icons.Here is link to its Bug trac tickethttp://www.autoitscript.com/trac/autoit/ticket/1270#comment:5 Edited December 4, 2009 by Zedna Resources UDF Â ResourcesEx UDF Â AutoIt Forum Search
trancexx Posted December 4, 2009 Posted December 4, 2009 GUICtrlCreateIcon() is one function and GuiSetIcon() is another. regi is asking about former. ♡♡♡ . eMyvnE
FuryCell Posted January 29, 2010 Posted January 29, 2010 (edited) I am having the same problem with the newest version of Au3. When using the included icon I only get 32x32 however if the icon is out of the exe then it gets 48x48 fine. Have we had a regression in the latest version?Included IconExternal Icon Edited January 29, 2010 by P5ych0Gigabyte HKTunes:Softpedia | GoogleCodeLyricToy:Softpedia | GoogleCodeRCTunes:Softpedia | GoogleCodeMichtaToolsProgrammer n. - An ingenious device that turns caffeine into code.
trancexx Posted January 29, 2010 Posted January 29, 2010 I am having the same problem with the newest version of Au3. When using the included icon I only get 32x32 however if the icon is out of the exe then it gets 48x48 fine. Have we had a regression in the latest version?Included IconExternal IconRegression would imply some sort of previously done progression. ♡♡♡ . eMyvnE
FuryCell Posted January 29, 2010 Posted January 29, 2010 (edited) Regression would imply some sort of previously done progression.After looking at the exe in reshacker I can see that the icons included are 48x48 and did not get scaled down. So I am pretty sure this is a bug. I am going to file a report on trac. Submitted:Trac Edited January 29, 2010 by P5ych0Gigabyte HKTunes:Softpedia | GoogleCodeLyricToy:Softpedia | GoogleCodeRCTunes:Softpedia | GoogleCodeMichtaToolsProgrammer n. - An ingenious device that turns caffeine into code.
trancexx Posted January 29, 2010 Posted January 29, 2010 (edited) After looking at the exe in reshacker I can see that the icons included are 48x48 and did not get scaled down. So I am pretty sure this is a bug. I am going to file a report on trac. Submitted:Trac I just said that there has been no regression since there was no progression. When specifying icon file as icon to use there are two modes that AutoIt works in. First one is (will split in two sub modes): GUICtrlSetImage($ButtonTest, ".\Icon.ico", 0, 0) ; get small icon (16x16)GUICtrlSetImage($ButtonTest, ".\Icon.ico", 0, 1) ; get normal icon (32x32) The other is: GUICtrlSetImage($ButtonTest, ".\Icon.ico") ; get first icon found in icon file First mode uses ExtractIconExW to get icons and other LoadImageW. When doing the same thing but now specifying resource as icon to use, there is only one mode. The first one; ExtractIconExW. Third case would be just repeating second one. Why is this so I have no idea. Actually I don't know why is ExtractIconExW used at all. Probably some smart reason though. Maybe for simplicity (small/normal). Edited January 29, 2010 by trancexx ♡♡♡ . eMyvnE
picea892 Posted January 30, 2010 Posted January 30, 2010 Anyways...getting back to the question...Here is a way. expandcollapse popup#include <GUIConstantsEx.au3> #Include <Constants.au3> #include <GDIPlus.au3> #include <WinAPI.au3> $Gui = GUICreate("",200,200,-1,-1) $gradie = GUICtrlCreatePic("", 0, 0,48, 48) iconbutton_1(-1, "numbers.ico", -1) GUISetState() While 1 sleep(20) $msg=GUIGetMsg() if $msg=$GUI_EVENT_CLOSE then Exit WEnd Func iconbutton_1($control, $sIcon = "", $iIndex = "", $size=32) If Not $sIcon = "" Then _GDIPlus_Startup() $hwd = GUICtrlGetHandle($control) $width = _WinAPI_GetClientWidth($hwd) $height = _WinAPI_GetClientHeight($hwd) $hGraphic = _GDIPlus_GraphicsCreateFromHWND($hwd) $hBitmap1 = _GDIPlus_BitmapCreateFromGraphics($width, $height, $hGraphic) $hBitmap1 = _drawicon($hBitmap1, $width, $height, $sIcon, $iIndex,0,0) $hImage1 = _GDIPlus_ImageGetGraphicsContext($hBitmap1) $hBMP1 = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hBitmap1) _WinAPI_DeleteObject(GUICtrlSendMsg($control, 0x0172, 0, $hBMP1)) _GDIPlus_GraphicsDispose($hImage1) _WinAPI_DeleteObject($hBMP1) _GDIPlus_BitmapDispose($hBitmap1) _GDIPlus_GraphicsDispose($hGraphic) _GDIPlus_Shutdown() EndIf EndFunc ;==>iconbutton_1 Func _drawicon($bitmap, $width, $height, $ico, $ind,$hpos,$hvpos) $hbmp = _GDIPlus_BitmapCreateHBITMAPFromBitmap($bitmap) $hIcon = _WinAPI_SHExtractIcons($ico, $ind, 48, 48) $hDC = _WinAPI_GetDC(0) $hBackDC = _WinAPI_CreateCompatibleDC($hDC) $hBackSv = _WinAPI_SelectObject($hBackDC, $hbmp) If $hIcon <> 0 Then _WinAPI_DrawIconEx($hBackDC,$hpos, $hvpos, $hIcon, 0, 0, 0, 0, $DI_NORMAL) $bitmap = _GDIPlus_BitmapCreateFromHBITMAP($hbmp) _WinAPI_DeleteObject($hbmp) _WinAPI_SelectObject($hBackDC, $hBackSv) _WinAPI_DeleteDC($hBackDC) _WinAPI_ReleaseDC(0, $hDC) _WinAPI_DestroyIcon($hIcon) Return $bitmap Return EndFunc ;==>_drawicon Func _WinAPI_SHExtractIcons($sIcon, $iIndex, $iWidth, $iHeight) Local $Ret = DllCall('shell32.dll', 'int', 'SHExtractIconsW', 'wstr', $sIcon, 'int', $iIndex, 'int', $iWidth, 'int', $iHeight, 'ptr*', 0, 'ptr*', 0, 'int', 1, 'int', 0) If (@error) Or ($Ret[0] = 0) Or ($Ret[5] = Ptr(0)) Then Return SetError(1, 0, 0) EndIf Return $Ret[5] EndFunc ;==>_WinAPI_SHExtractIcons
FuryCell Posted January 30, 2010 Posted January 30, 2010 Anyways...getting back to the question...Here is a way.Thanks for the workaround. I'm gonna give that a try and see how it turns out. The thing is its for a gpl project. Are you OK with me using that code? HKTunes:Softpedia | GoogleCodeLyricToy:Softpedia | GoogleCodeRCTunes:Softpedia | GoogleCodeMichtaToolsProgrammer n. - An ingenious device that turns caffeine into code.
FuryCell Posted January 30, 2010 Posted January 30, 2010 (edited) of course.... So how would I get this to draw on a button. Something like the following. expandcollapse popup#include <GUIConstantsEx.au3> #Include <Constants.au3> #include <GDIPlus.au3> #include <WinAPI.au3> $Gui = GUICreate("",200,200,-1,-1) $gradie = GUICtrlCreateButton("", 0, 0,48, 48) iconbutton_1(-1, "go.ico", -1) GUISetState() While 1 sleep(20) $msg=GUIGetMsg() if $msg=$GUI_EVENT_CLOSE then Exit WEnd Func iconbutton_1($control, $sIcon = "", $iIndex = "", $size=32) If Not $sIcon = "" Then _GDIPlus_Startup() $hwd = GUICtrlGetHandle($control) $width = _WinAPI_GetClientWidth($hwd) $height = _WinAPI_GetClientHeight($hwd) $hGraphic = _GDIPlus_GraphicsCreateFromHWND($hwd) $hBitmap1 = _GDIPlus_BitmapCreateFromGraphics($width, $height, $hGraphic) $hBitmap1 = _drawicon($hBitmap1, $width, $height, $sIcon, $iIndex,0,0) $hImage1 = _GDIPlus_ImageGetGraphicsContext($hBitmap1) $hBMP1 = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hBitmap1) _WinAPI_DeleteObject(GUICtrlSendMsg($control, 0x0172, 0, $hBMP1)) _GDIPlus_GraphicsDispose($hImage1) _WinAPI_DeleteObject($hBMP1) _GDIPlus_BitmapDispose($hBitmap1) _GDIPlus_GraphicsDispose($hGraphic) _GDIPlus_Shutdown() EndIf EndFunc ;==>iconbutton_1 Func _drawicon($bitmap, $width, $height, $ico, $ind,$hpos,$hvpos) $hbmp = _GDIPlus_BitmapCreateHBITMAPFromBitmap($bitmap) $hIcon = _WinAPI_SHExtractIcons($ico, $ind, 48, 48) $hDC = _WinAPI_GetDC(0) $hBackDC = _WinAPI_CreateCompatibleDC($hDC) $hBackSv = _WinAPI_SelectObject($hBackDC, $hbmp) If $hIcon <> 0 Then _WinAPI_DrawIconEx($hBackDC,$hpos, $hvpos, $hIcon, 0, 0, 0, 0, $DI_NORMAL) $bitmap = _GDIPlus_BitmapCreateFromHBITMAP($hbmp) _WinAPI_DeleteObject($hbmp) _WinAPI_SelectObject($hBackDC, $hBackSv) _WinAPI_DeleteDC($hBackDC) _WinAPI_ReleaseDC(0, $hDC) _WinAPI_DestroyIcon($hIcon) Return $bitmap Return EndFunc ;==>_drawicon Func _WinAPI_SHExtractIcons($sIcon, $iIndex, $iWidth, $iHeight) Local $Ret = DllCall('shell32.dll', 'int', 'SHExtractIconsW', 'wstr', $sIcon, 'int', $iIndex, 'int', $iWidth, 'int', $iHeight, 'ptr*', 0, 'ptr*', 0, 'int', 1, 'int', 0) If (@error) Or ($Ret[0] = 0) Or ($Ret[5] = Ptr(0)) Then Return SetError(1, 0, 0) EndIf Return $Ret[5] EndFunc ;==>_WinAPI_SHExtractIcons Edited January 30, 2010 by P5ych0Gigabyte HKTunes:Softpedia | GoogleCodeLyricToy:Softpedia | GoogleCodeRCTunes:Softpedia | GoogleCodeMichtaToolsProgrammer n. - An ingenious device that turns caffeine into code.
picea892 Posted January 30, 2010 Posted January 30, 2010 Okay...different example #include <GDIPlus.au3> #include <GuiConstantsEx.au3> #include <WindowsConstants.au3> #include <WINAPI.au3> _GDIPlus_Startup() Global $Image1 = _GDIPlus_ImageLoadFromFile("sb.png") $width=_GDIPlus_ImageGetWidth($Image1) $height=_GDIPlus_ImageGetHeight($Image1) Global Const $AC_SRC_ALPHA = 1 $GUI = GUICreate("Example",$width,$height,-1,-1,$WS_POPUP) $pic=GUICtrlCreateButton("",0,0,$width,$height) GUISetState() Global $Graphic = _GDIPlus_GraphicsCreateFromHWND(GUICtrlGetHandle($pic)) _GDIPlus_GraphicsDrawImageRect($Graphic, $Image1,0,0,$width,$height) While 1 $MSG = GUIGetMsg() Switch $MSG Case -3 Quit() EndSwitch WEnd Func Quit() _GDIPlus_ImageDispose($Image1) _GDIPlus_GraphicsDispose($Graphic) _GDIPlus_Shutdown() Exit EndFunc
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