Minikori Posted August 12, 2008 Share Posted August 12, 2008 Is it possible to put one icon on top of another? Here's my code: CODE$PowerIco = GUICtrlCreateIcon("shell32.dll", -28, 85, 130) $DeleteIco = GUICtrlCreateIcon("shell32.dll", -132, 85, 130) For those who are asking questions, look in the help file first. I'm tired of people asking stupid questions about how to do things when 10 seconds in the help file could solve their problem.[quote name='JRowe' date='24 January 2010 - 05:58 PM' timestamp='1264381100' post='766337'][quote name='beerman' date='24 January 2010 - 03:28 PM' timestamp='1264372082' post='766300']They already have a punishment system for abuse.[/quote]... and his his name is Valik.[/quote]www.minikori.com Link to comment Share on other sites More sharing options...
smashly Posted August 13, 2008 Share Posted August 13, 2008 (edited) Hi, you can set 2 images to 1 Icon control with a bit of trickery. Here's a crude example that doesn't have any error checking for incorrect user input..expandcollapse popup#include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <WinApi.au3> #include <GDIPlus.au3> #include <Constants.au3> $hGui = GUICreate('', 200, 200, -1, -1) $DeleteIco = GUICtrlCreateIcon("", 0, 10, 10, 32, 32) GUICtrlSetTip(-1, "Click icon to delete.") GUISetState(@SW_SHOW, $hGui) $hIcon1 = _SetTwoIconsToOneIconControl($hGui, $DeleteIco, "shell32.dll", 27, 131) While 1 $msg = GUIGetMsg() Switch $msg Case $GUI_EVENT_CLOSE If $hIcon1 Then _WinAPI_DestroyIcon($hIcon1) Exit Case $DeleteIco GUICtrlDelete($DeleteIco) _WinAPI_DestroyIcon($hIcon1) $hIcon1 = 0 EndSwitch WEnd Func _SetTwoIconsToOneIconControl($hWnd, $cID, $sFile, $iName1, $iName2) Local Const $STM_SETIMAGE = 0x0172 Local $hCID, $tL1, $pL1, $tL2, $pL2, $hImage1, $hGraphic, $hImage2, $hIcon, $hSetIcon $hCID = GUICtrlGetHandle($cID) $tL1 = DllStructCreate("int Handle[1]") $pL1 = DllStructGetPtr($tL1) $tL2 = DllStructCreate("int Handle[1]") $pL2 = DllStructGetPtr($tL2) _WinAPI_ExtractIconEx($sFile, $iName1, $pL1, 0, 1) _WinAPI_ExtractIconEx($sFile, $iName2, $pL2, 0, 1) _GDIPlus_Startup() $hImage1 = DllCall($ghGDIPDll,"int", "GdipCreateBitmapFromHICON", "hWnd", DllStructGetData($tL1, "Handle", 1), "int*", 0) $hGraphic = _GDIPlus_ImageGetGraphicsContext($hImage1[2]) $hImage2 = DllCall($ghGDIPDll,"int", "GdipCreateBitmapFromHICON", "hWnd", DllStructGetData($tL2, "Handle", 1), "int*", 0) _GDIPlus_GraphicsDrawImageRect($hGraphic, $hImage2[2], 0, 0, _GDIPlus_ImageGetWidth($hImage1[2]), _GDIPlus_ImageGetHeight($hImage1[2])) $hIcon = DllCall($ghGDIPDll,"int", "GdipCreateHICONFromBitmap", "hWnd", $hImage1[2], "int*", 0) _GDIPlus_ImageDispose($hImage2) _GDIPlus_GraphicsDispose($hGraphic) _GDIPlus_ImageDispose($hImage1) _GDIPlus_Shutdown() $hSetIcon = DllCall("user32.dll", "hwnd", "SendMessage", "hwnd", $hCID, "int", $STM_SETIMAGE, "int", $IMAGE_ICON, "int", $hIcon[2]) _WinAPI_DestroyIcon(DllStructGetData($tL1, "Handle", 1)) _WinAPI_DestroyIcon(DllStructGetData($tL2, "Handle", 1)) If $hSetIcon[0] <> 0 Then _WinAPI_DeleteObject($hSetIcon[0]) Return $hIcon[2] EndFunc Any Questions ? Cheers Edit: Changed the way the hIcon is destroyed. Edited August 13, 2008 by smashly Link to comment Share on other sites More sharing options...
MrCreatoR Posted October 24, 2008 Share Posted October 24, 2008 Very nice example smashly!One question: can it be used to set an image for a Listbox item? I opened a thread with this question, and martin has pointed to this topic so i will see how to draw icon image on the control, but the problem is that list item have no(?) control id, how we can get the handle of each item (index) and apply this method to set the icon?P.SSorry for the offtopic. Spoiler Using OS: Win 7 Professional, Using AutoIt Ver(s): 3.3.6.1 / 3.3.8.1 AutoIt Russian Community My Work... Spoiler Projects: ATT - Application Translate Tool {new}| BlockIt - Block files & folders {new}| SIP - Selected Image Preview {new}| SISCABMAN - SciTE Abbreviations Manager {new}| AutoIt Path Switcher | AutoIt Menu for Opera! | YouTube Download Center! | Desktop Icons Restorator | Math Tasks | KeyBoard & Mouse Cleaner | CaptureIt - Capture Images Utility | CheckFileSize ProgramUDFs: OnAutoItErrorRegister - Handle AutoIt critical errors {new}| AutoIt Syntax Highlight {new}| Opera Library! | Winamp Library | GetFolderToMenu | Custom_InputBox()! | _FileRun UDF | _CheckInput() UDF | _GUIInputSetOnlyNumbers() UDF | _FileGetValidName() UDF | _GUICtrlCreateRadioCBox UDF | _GuiCreateGrid() | _PathSplitByRegExp() | _GUICtrlListView_MoveItems - UDF | GUICtrlSetOnHover_UDF! | _ControlTab UDF! | _MouseSetOnEvent() UDF! | _ProcessListEx - UDF | GUICtrl_SetResizing - UDF! | Mod. for _IniString UDFs | _StringStripChars UDF | _ColorIsDarkShade UDF | _ColorConvertValue UDF | _GUICtrlTab_CoverBackground | CUI_App_UDF | _IncludeScripts UDF | _AutoIt3ExecuteCode | _DragList UDF | Mod. for _ListView_Progress | _ListView_SysLink | _GenerateRandomNumbers | _BlockInputEx | _IsPressedEx | OnAutoItExit Handler | _GUICtrlCreateTFLabel UDF | WinControlSetEvent UDF | Mod. for _DirGetSizeEx UDF Examples: ScreenSaver Demo - Matrix included | Gui Drag Without pause the script | _WinAttach()! | Turn Off/On Monitor | ComboBox Handler Example | Mod. for "Thinking Box" | Cool "About" Box | TasksBar Imitation Demo Like the Projects/UDFs/Examples? Please rate the topic (up-right corner of the post header: Rating ) * === My topics === * ================================================== ================================================== AutoIt is simple, subtle, elegant. © AutoIt Team Link to comment Share on other sites More sharing options...
martin Posted October 24, 2008 Share Posted October 24, 2008 Very nice example smashly!One question: .. but the problem is that list item have no(?) control id, how we can get the handle of each item (index) and apply this method to set the icon?I posted a question back in your thread MrCreator. Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script. 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