koiron Posted May 28, 2007 Share Posted May 28, 2007 I'm trying to make a combo drop down with icons for each item like that of the attached image. Is this possible with autoit?1.bmp -Koiron Link to comment Share on other sites More sharing options...
GaryFrost Posted May 28, 2007 Share Posted May 28, 2007 I'm trying to make a combo drop down with icons for each item like that of the attached image. Is this possible with autoit?Currently I don't think it doesThat would be something for Holger to look at. SciTE for AutoItDirections for Submitting Standard UDFs Don't argue with an idiot; people watching may not be able to tell the difference. Link to comment Share on other sites More sharing options...
Holger Posted May 28, 2007 Share Posted May 28, 2007 (edited) Here we are (was just a test for my PENetwork-project for language settings), modified it a litte bit: Only "ANSI"-version here... expandcollapse popup#include <GUIConstants.au3> Global Const $WM_SETFONT = 0x0030 Global Const $CBEM_INSERTITEMA = $WM_USER + 1 Global Const $CBEM_SETIMAGELIST = $WM_USER + 2 Global Const $CBEM_GETITEMA = $WM_USER + 4 Global Const $CBEM_SETITEMA = $WM_USER + 5 Global Const $CBEIF_TEXT = 0x00000001 Global Const $CBEIF_IMAGE = 0x00000002 Global Const $CBEIF_SELECTEDIMAGE = 0x00000004 Global Const $sCOMBOBOXEXITEM = "uint;" & _ ; Mask "int;" & _ ; Item index (0 based) "ptr;" & _ ; Item text "int;" & _ ; Text length "int;" & _ ; Image index in image list "int;" & _ ; Selected image index "int;" & _ ; Overlay image index "int;" & _ ; Indent spaces "dword" ; lParam Global Const $ILC_MASK = 0x0001 Global Const $ILC_COLOR32 = 0x0020 Dim $hGlobalFont = 0 $hMainGUI = GUICreate("Test") $hComboLang = MyGUICtrlCreateComboEx(5, 5, 120, 120, $hMainGUI, $CBS_DROPDOWNLIST) $hImageList = ImageList_Create(16, 16, BitOr($ILC_MASK, $ILC_COLOR32), 0, 1) $res = DllCall("user32.dll", "int", "SendMessage", "hwnd", $hComboLang, "int", $CBEM_SETIMAGELIST, "int", 0, "hwnd", $hImageList) $stIcon = DllStructCreate("dword") For $i = 0 To 50 ExtractIconEx("shell32.dll", $i, 0, DllStructGetPtr($stIcon), 1) $nImage = ImageList_AddIcon($hImageList, DllStructGetData($stIcon, 1)) MyGUICtrlCreateComboExItem($i, $hComboLang, -1, $nImage) Next GUISetState() While 1 $Msg = GUIGetMsg() If $Msg = $GUI_EVENT_CLOSE Then ExitLoop WEnd ImageList_Destroy($hImageList) Exit Func MyGUICtrlCreateComboEx($nX, $nY, $nW, $nH, $hParent, $nStyle = 0, $nExStyle = 0) Local $nID = GUICtrlCreateDummy() $hCtrl = CreateWindowEx($nExStyle, "ComboBoxEx32", "", BitOr($nStyle, $WS_VISIBLE, $WS_CHILD), $nX, $nY, $nW, $nH, $hParent, $nID, 0, 0) SetFont($hCtrl) Return $hCtrl EndFunc Func MyGUICtrlCreateComboExItem($sItemText, $hComboEx, $nIndex = -1, $nImage = 0) Local $stCBItem = DllStructCreate($sCOMBOBOXEXITEM) DllStructSetData($stCBItem, 1, BitOr($CBEIF_TEXT, $CBEIF_IMAGE, $CBEIF_SELECTEDIMAGE)) DllStructSetData($stCBItem, 2, $nIndex) Local $stString = DllStructCreate("char[" & StringLen($sItemText) + 1 & "]") DllStructSetData($stString, 1, $sItemText) DllStructSetData($stCBItem, 3, DllStructGetPtr($stString)) DllStructSetData($stCBItem, 5, $nImage) DllStructSetData($stCBItem, 6, $nImage) Local $nNewIndex = SendMessage($hComboEx, $CBEM_INSERTITEMA, 0, DllStructGetPtr($stCBItem)) Return $nNewIndex EndFunc Func CreateWindowEx($nExStyle, $sClassName, $sWndName, $nStyle, $nX, $nY, $nW, $nH, $hWndParent, $hMenu, $hInstance, $pParam) Local $nResult = DllCall("user32.dll", "hwnd", "CreateWindowEx", _ "int", $nExStyle, _ "str", $sClassName, _ "str", $sWndName, _ "int", $nStyle, _ "int", $nX, _ "int", $nY, _ "int", $nW, _ "int", $nH, _ "hwnd", $hWndParent, _ "hwnd", $hMenu, _ "hwnd", $hInstance, _ "ptr", $pParam) Return $nResult[0] EndFunc Func SendMessage($hWnd, $Msg, $wParam = 0, $lParam = 0) Local $nResult = DllCall("user32.dll", "int", "SendMessage", _ "hwnd", $hWnd, _ "int", $Msg, _ "int", $wParam, _ "int", $lParam) Return $nResult[0] EndFunc Func SetFont($hWnd) If $hGlobalFont = 0 Then $hGlobalFont = DllCall("gdi32.dll", "hwnd", "GetStockObject", "int", 17); Get "DEFAULT_GUI_FONT" ; ; -> font numbers can be : ; OEM_FIXED_FONT 10 ; ANSI_FIXED_FONT 11 ; ANSI_VAR_FONT 12 ; SYSTEM_FONT 13 ; DEVICE_DEFAULT_FONT 14 ; DEFAULT_PALETTE 15 ; SYSTEM_FIXED_FONT 16 ; DEFAULT_GUI_FONT 17 ; ; $hGlobalFont = $hGlobalFont[0] EndIf SendMessage($hWnd, $WM_SETFONT, $hGlobalFont, 1) EndFunc Func ImageList_Create($nImageWidth, $nImageHeight, $nFlags, $nInitial, $nGrow) Local $hImageList = DllCall('comctl32.dll', 'hwnd', 'ImageList_Create', _ 'int', $nImageWidth, _ 'int', $nImageHeight, _ 'int', $nFlags, _ 'int', $nInitial, _ 'int', $nGrow) Return $hImageList[0] EndFunc Func ImageList_AddIcon($hIml, $hIcon) Local $nIndex = DllCall('comctl32.dll', 'int', 'ImageList_AddIcon', _ 'hwnd', $hIml, _ 'hwnd', $hIcon) Return $nIndex[0] EndFunc Func ImageList_Destroy($hIml) Local $bResult = DllCall('comctl32.dll', 'int', 'ImageList_Destroy', _ 'hwnd', $hIml) Return $bResult[0] EndFunc Func ExtractIconEx($sIconFile, $nIconID, $ptrIconLarge, $ptrIconSmall, $nIcons) Local $nCount = DllCall('shell32.dll', 'int', 'ExtractIconEx', _ 'str', $sIconFile, _ 'int', $nIconID, _ 'ptr', $ptrIconLarge, _ 'ptr', $ptrIconSmall, _ 'int', $nIcons) Return $nCount[0] EndFunc Greets Holger Edited May 28, 2007 by Holger Old project:GUI/Tray menu with icons and colors Other old stuff:IconFileScanner, TriState/ThreeState GUI TreeView, GUI ContextMenu created out of a TreeView Link to comment Share on other sites More sharing options...
Zedna Posted May 28, 2007 Share Posted May 28, 2007 Here we are (was just a test for my PENetwork-project for language settings), modified it a litte bit:Only "ANSI"-version here...GreetsHolgerHey man that's fantasctic!Nice example for image lists. Resources UDF ResourcesEx UDF AutoIt Forum Search Link to comment Share on other sites More sharing options...
koiron Posted May 28, 2007 Author Share Posted May 28, 2007 So based on your awesome example, Holger, dll's are needed to add icons to combo items. I'm gonna go stare at the help file for a few hours to understand this hah Thanks for your help! -Koiron 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