rysiora Posted March 24, 2006 Share Posted March 24, 2006 The Tab Iconsexpandcollapse popup#include <GUIConstants.au3> GUICreate("Tab Icons") $Tab=GUICtrlCreateTab(10,10,300,200) $Tab0=GUICtrlCreateTabItem("Tab-1") GUICtrlCreateLabel("Inside Tab 1", 150, 50, 102, 17, -1, $WS_EX_TRANSPARENT) GUICtrlCreateButton("Button",100,100,50,20) $Tab1=GUICtrlCreateTabItem("Tab-2") GUICtrlCreateLabel("Inside Tab 2", 100, 50, 102, 17, -1, $WS_EX_TRANSPARENT) GUICtrlCreateButton("Button",150,100,50,20) $Tab2=GUICtrlCreateTabItem("Tab-3") GUICtrlCreateLabel("Inside Tab 3", 150, 50, 102, 17, -1, $WS_EX_TRANSPARENT) GUICtrlCreateButton("Button",100,100,50,20) GUICtrlCreateTabItem("") GUISetState() Global $ILC_MASK = 0x0001 Global $ILC_COLOR32 = 0x0020 Global $TCM_SETIMAGELIST = 0x1303 Global $TCM_SETITEM = 0x1306 Global $TCIF_IMAGE = 2 Global $TC_ITEM = DllStructCreate("int;int;int;int;int;int;int") DllStructSetData($TC_ITEM,1,0) DllStructSetData($TC_ITEM,2,0) DllStructSetData($TC_ITEM,3,0) DllStructSetData($TC_ITEM,4,0) DllStructSetData($TC_ITEM,5,0) DllStructSetData($TC_ITEM,6,0) DllStructSetData($TC_ITEM,7,0) Global $TabImageList = ImageList_Create(16, 16, BitOR($ILC_MASK, $ILC_COLOR32), 0, 1) TabSetIcon($tab,0,"shell32.dll",22) TabSetIcon($tab,1,"shell32.dll",31) TabSetIcon($tab,2,"shell32.dll",23) Func TabSetIcon($Tab, $Item, $sIconFile, $nIconID) $stIcon = DllStructCreate("int") ExtractIconEx($sIconFile, $nIconID, 0, DllStructGetPtr($stIcon), 1) $hIcon = DllStructGetData($stIcon, 1) $nIndex = ImageList_AddIcon($TabImageList, $hIcon) DestroyIcon($hIcon) GUICtrlSendMsg($Tab, $TCM_SETIMAGELIST, 0, $TabImageList) DllStructSetData($TC_ITEM,1,$TCIF_IMAGE) DllStructSetData($TC_ITEM,6,$nIndex) GUICtrlSendMsg($Tab, $TCM_SETITEM, $Item, DllStructGetPtr($TC_ITEM)) EndFunc ;==>TabSetIcon While 1 $msg = GUIGetMsg() If $msg = $GUI_EVENT_CLOSE Then ExitLoop Wend Func ImageList_Create($nImageWidth, $nImageHeight, $nFlags, $nInitial, $nGrow) $hImageList = DllCall('comctl32.dll', 'hwnd', 'ImageList_Create', 'int', $nImageWidth, 'int', $nImageHeight, 'int', $nFlags, 'int', $nInitial, 'int', $nGrow) Return $hImageList[0] EndFunc ;==>ImageList_Create Func ImageList_AddIcon($hIml, $hIcon) $nIndex = DllCall('comctl32.dll', 'int', 'ImageList_AddIcon', 'hwnd', $hIml, 'hwnd', $hIcon) Return $nIndex[0] EndFunc ;==>ImageList_AddIcon Func ImageList_Destroy($hIml) $bResult = DllCall('comctl32.dll', 'int', 'ImageList_Destroy', 'hwnd', $hIml) Return $bResult[0] EndFunc ;==>ImageList_Destroy Func ExtractIconEx($sIconFile, $nIconID, $ptrIconLarge, $ptrIconSmall, $nIcons) $nCount = DllCall('shell32.dll', 'int', 'ExtractIconEx', 'str', $sIconFile, 'int', $nIconID, 'ptr', $ptrIconLarge, 'ptr', $ptrIconSmall, 'int', $nIcons) Return $nCount[0] EndFunc ;==>ExtractIconEx Func DestroyIcon($hIcon) $bResult = DllCall('user32.dll', 'int', 'DestroyIcon', 'hwnd', $hIcon) Return $bResult[0] EndFunc ;==>DestroyIconAnd ListView Headersexpandcollapse popup#include <GUIConstants.au3> Global $ILC_MASK = 0x0001 Global $ILC_COLOR32 = 0x0020 Global $LVM_SETCOLUMNWIDTH = 0x101E Global $LVM_GETHEADER = 0x101F Global $HDM_SETIMAGELIST = 0x1208 Global $HDM_SETITEM = 0x1204 Global $HDI_FORMAT = 0x4 Global $HDI_IMAGE = 0x20 Global $HDF_STRING = 0x4000 Global $HDF_IMAGE = 0x800 Global $HDF_BITMAP_ON_RIGHT = 0x1000 Global $HD_ITEM = DllStructCreate("int;int;ptr;int;int;int;int;int;int") DllStructSetData($HD_ITEM,1,0) DllStructSetData($HD_ITEM,2,0) DllStructSetData($HD_ITEM,3,0) DllStructSetData($HD_ITEM,4,0) DllStructSetData($HD_ITEM,5,0) DllStructSetData($HD_ITEM,6,0) DllStructSetData($HD_ITEM,7,0) DllStructSetData($HD_ITEM,8,0) DllStructSetData($HD_ITEM,9,0) Global $LViewImageList = ImageList_Create(16, 16, BitOR($ILC_MASK, $ILC_COLOR32), 2, 0) $stIcon = DllStructCreate("int") ExtractIconEx(@ScriptDir & "\SORT_ASC.ico", 0, 0, DllStructGetPtr($stIcon), 1) ImageList_AddIcon($LViewImageList, DllStructGetData($stIcon, 1)) ExtractIconEx(@ScriptDir & "\SORT_DESC.ico", 0, 0, DllStructGetPtr($stIcon), 1) ImageList_AddIcon($LViewImageList, DllStructGetData($stIcon, 1)) DestroyIcon(DllStructGetData($stIcon, 1)) $stIcon = 0 Global Const $LVFI_PARAM = 0x0001 Global Const $LVIF_TEXT = 0x0001 Global Const $LVM_FIRST = 0x1000 Global Const $LVM_GETITEM = $LVM_FIRST + 5 Global Const $LVM_FINDITEM = $LVM_FIRST + 13 Global Const $LVM_SETSELECTEDCOLUMN = $LVM_FIRST + 140 Global $nCurCol = -1, $nSortDir = 1, $bSet = 0, $nCol = -1, $Done = 0 $hGUI = GUICreate("ListView Header Icons", 300, 200) $lv = GUICtrlCreateListView("Column 1|Column 2", 10, 10, 280, 180) GUICtrlRegisterListViewSort(-1, "LVSort"); Register the function "SortLV" for the sorting callback GUICtrlCreateListViewItem("ABC|Item 3", $lv) GUICtrlSetImage(-1, "shell32.dll", 7) GUICtrlCreateListViewItem("DEF|Item 2", $lv) GUICtrlSetImage(-1, "shell32.dll", 12) GUICtrlCreateListViewItem("CDE|Item 1", $lv) GUICtrlSetImage(-1, "shell32.dll", 3) GUICtrlCreateListViewItem("FGH|Item 4", $lv) GUICtrlSetImage(-1, "shell32.dll", 22) GUICtrlCreateListViewItem("XYZ|Item 5", $lv) GUICtrlSetImage(-1, "shell32.dll", 31) GUICtrlCreateListViewItem("RPS|Item 6", $lv) GUICtrlSetImage(-1, "shell32.dll", 23) GUICtrlSendMsg($lv ,$LVM_SETCOLUMNWIDTH,0,135) GUICtrlSendMsg($lv ,$LVM_SETCOLUMNWIDTH,1,135) GUISetState() While 1 $msg = GUIGetMsg() Switch $msg Case $GUI_EVENT_CLOSE Exit Case $lv $Done = 0 $bSet = 0 $nCurCol = $nCol GUICtrlSendMsg($lv, $LVM_SETSELECTEDCOLUMN, GUICtrlGetState($lv), 0) DllCall("user32.dll", "int", "InvalidateRect", "hwnd", GUICtrlGetHandle($lv), "int", 0, "int", 1) EndSwitch WEnd ; Our sorting callback funtion Func LVSort($hWnd, $nItem1, $nItem2, $nColumn) Local $nSort ; Switch the sorting direction If $nColumn = $nCurCol Then If Not $bSet Then $nSortDir = $nSortDir * -1 $bSet = 1 EndIf Else $nSortDir = 1 EndIf If $Done = 0 AND $nSortDir = 1 Then SetHeaderIcon($hWnd, $nColumn, 0) Global $Done = 1 ElseIf $Done = 0 AND $nSortDir = -1 Then SetHeaderIcon($hWnd, $nColumn, 1) Global $Done = 1 Endif $nCol = $nColumn $val1 = GetSubItemText($lv, $nItem1, $nColumn) $val2 = GetSubItemText($lv, $nItem2, $nColumn) ; If it is the 3rd colum (column starts with 0) then compare the dates If $nColumn = 2 Then $val1 = StringRight($val1, 4) & StringMid($val1, 4, 2) & StringLeft($val1, 2) $val2 = StringRight($val2, 4) & StringMid($val2, 4, 2) & StringLeft($val2, 2) EndIf $nResult = 0 ; No change of item1 and item2 positions If $val1 < $val2 Then $nResult = -1 ; Put item2 before item1 ElseIf $val1 > $val2 Then $nResult = 1 ; Put item2 behind item1 EndIf $nResult = $nResult * $nSortDir Return $nResult EndFunc ; Retrieve the text of a listview item in a specified column Func GetSubItemText($nCtrlID, $nItemID, $nColumn) Local $stLvfi = DllStructCreate("uint;ptr;int;int[2];int") DllStructSetData($stLvfi, 1, $LVFI_PARAM) DllStructSetData($stLvfi, 3, $nItemID) Local $stBuffer = DllStructCreate("char[260]") $nIndex = GUICtrlSendMsg($nCtrlID, $LVM_FINDITEM, -1, DllStructGetPtr($stLvfi)) Local $stLvi = DllStructCreate("uint;int;int;uint;uint;ptr;int;int;int;int") DllStructSetData($stLvi, 1, $LVIF_TEXT) DllStructSetData($stLvi, 2, $nIndex) DllStructSetData($stLvi, 3, $nColumn) DllStructSetData($stLvi, 6, DllStructGetPtr($stBuffer)) DllStructSetData($stLvi, 7, 260) GUICtrlSendMsg($nCtrlID, $LVM_GETITEM, 0, DllStructGetPtr($stLvi)); $sItemText = DllStructGetData($stBuffer, 1) Local $stLvi = 0, $stLvfi = 0, $stBuffer = 0 Return $sItemText EndFunc Func SetHeaderIcon($LView, $iCol, $iSortOrder) $Header = GUICtrlSendMsg($LView, $LVM_GETHEADER, 0, 0) DllCall("user32.dll", "int", "SendMessage", "hwnd", $Header, "int", $HDM_SETIMAGELIST, "int", 0, "hwnd", $LViewImageList) DllStructSetData($HD_ITEM,1,BitOR($HDI_IMAGE,$HDI_FORMAT)) DllStructSetData($HD_ITEM,8,$iSortOrder) For $x = 0 To 2 If $x = $iCol Then DllStructSetData($HD_ITEM,6,BitOR($HDF_STRING,$HDF_IMAGE,$HDF_BITMAP_ON_RIGHT)) Else DllStructSetData($HD_ITEM,6,$HDF_STRING) EndIf DllCall("user32.dll", "int", "SendMessage", "hwnd", $Header, "int", $HDM_SETITEM, "int", $x, "ptr", DllStructGetPtr($HD_ITEM)) Next EndFunc ;==>SetHeaderIcon Func ImageList_Create($nImageWidth, $nImageHeight, $nFlags, $nInitial, $nGrow) $hImageList = DllCall('comctl32.dll', 'hwnd', 'ImageList_Create', 'int', $nImageWidth, 'int', $nImageHeight, 'int', $nFlags, 'int', $nInitial, 'int', $nGrow) Return $hImageList[0] EndFunc ;==>ImageList_Create Func ImageList_AddIcon($hIml, $hIcon) $nIndex = DllCall('comctl32.dll', 'int', 'ImageList_AddIcon', 'hwnd', $hIml, 'hwnd', $hIcon) Return $nIndex[0] EndFunc ;==>ImageList_AddIcon Func ImageList_Destroy($hIml) $bResult = DllCall('comctl32.dll', 'int', 'ImageList_Destroy', 'hwnd', $hIml) Return $bResult[0] EndFunc ;==>ImageList_Destroy Func ExtractIconEx($sIconFile, $nIconID, $ptrIconLarge, $ptrIconSmall, $nIcons) $nCount = DllCall('shell32.dll', 'int', 'ExtractIconEx', 'str', $sIconFile, 'int', $nIconID, 'ptr', $ptrIconLarge, 'ptr', $ptrIconSmall, 'int', $nIcons) Return $nCount[0] EndFunc ;==>ExtractIconEx Func DestroyIcon($hIcon) $bResult = DllCall('user32.dll', 'int', 'DestroyIcon', 'hwnd', $hIcon) Return $bResult[0] EndFunc ;==>DestroyIconAnd the icons:SORT_ASC.icoSORT_DESC.ico Link to comment Share on other sites More sharing options...
rysiora Posted March 25, 2006 Author Share Posted March 25, 2006 And the function for LV Headers if you want to set constant Icon (not for use while sorting): expandcollapse popupGlobal $ILC_MASK = 0x0001 Global $ILC_COLOR32 = 0x0020 Global $LVM_GETHEADER = 0x101F Global $HDM_SETIMAGELIST = 0x1208 Global $HDM_SETITEM = 0x1204 Global $HDI_FORMAT = 0x4 Global $HDI_IMAGE = 0x20 Global $HDF_STRING = 0x4000 Global $HDF_IMAGE = 0x800 Global $HDF_BITMAP_ON_RIGHT = 0x1000 Global $HD_ITEM = DllStructCreate("int;int;ptr;int;int;int;int;int;int") DllStructSetData($HD_ITEM,1,0) DllStructSetData($HD_ITEM,2,0) DllStructSetData($HD_ITEM,3,0) DllStructSetData($HD_ITEM,4,0) DllStructSetData($HD_ITEM,5,0) DllStructSetData($HD_ITEM,6,0) DllStructSetData($HD_ITEM,7,0) DllStructSetData($HD_ITEM,8,0) DllStructSetData($HD_ITEM,9,0) Global $LViewImageList = ImageList_Create(16, 16, BitOR($ILC_MASK, $ILC_COLOR32), 0, 1) Func ColumnSetIcon($LView, $Item, $sIconFile, $nIconID) $stIcon = DllStructCreate("int") ExtractIconEx($sIconFile, $nIconID, 0, DllStructGetPtr($stIcon), 1) $hIcon = DllStructGetData($stIcon, 1) $nIndex = ImageList_AddIcon($LViewImageList, $hIcon) DestroyIcon($hIcon) $Header = GUICtrlSendMsg($LView, $LVM_GETHEADER, 0, 0) DllCall("user32.dll", "int", "SendMessage", "hwnd", $Header, "int", $HDM_SETIMAGELIST, "int", 0, "hwnd", $LViewImageList) DllStructSetData($HD_ITEM,1,BitOR($HDI_IMAGE,$HDI_FORMAT)) DllStructSetData($HD_ITEM,6,BitOR($HDF_STRING,$HDF_IMAGE,$HDF_BITMAP_ON_RIGHT)) DllStructSetData($HD_ITEM,8,$nIndex) DllCall("user32.dll", "int", "SendMessage", "hwnd", $Header, "int", $HDM_SETITEM, "int", $Item, "ptr", DllStructGetPtr($HD_ITEM)) EndFunc ;==>ColumnSetIcon ;EXAMPLE ColumnSetIcon($ListView, 1, "shell32.dll", 22) Link to comment Share on other sites More sharing options...
Holger Posted March 25, 2006 Share Posted March 25, 2006 Your tab icons a little bit easier (since beta 3.1.1.78) #include <GUIConstants.au3> GUICreate("Tab Icons") $Tab=GUICtrlCreateTab(10,10,300,200) $Tab0=GUICtrlCreateTabItem("Tab-1") GUICtrlCreateLabel("Inside Tab 1", 150, 50, 102, 17, -1, $WS_EX_TRANSPARENT) GUICtrlCreateButton("Button",100,100,50,20) $Tab1=GUICtrlCreateTabItem("Tab-2") GUICtrlCreateLabel("Inside Tab 2", 100, 50, 102, 17, -1, $WS_EX_TRANSPARENT) GUICtrlCreateButton("Button",150,100,50,20) $Tab2=GUICtrlCreateTabItem("Tab-3") GUICtrlCreateLabel("Inside Tab 3", 150, 50, 102, 17, -1, $WS_EX_TRANSPARENT) GUICtrlCreateButton("Button",100,100,50,20) GUICtrlCreateTabItem("") GUISetState() GUICtrlSetImage($Tab0,"shell32.dll",22) GUICtrlSetImage($Tab1,"shell32.dll",31) GUICtrlSetImage($Tab2,"shell32.dll",23) While 1 $msg = GUIGetMsg() If $msg = $GUI_EVENT_CLOSE Then ExitLoop Wend Greets 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...
PezoFaSho Posted March 25, 2006 Share Posted March 25, 2006 thats cool, your really into gui design 50% of the time, it works all the time Link to comment Share on other sites More sharing options...
GaryFrost Posted March 25, 2006 Share Posted March 25, 2006 http://www.autoitscript.com/forum/index.ph...ndpost&p=160433 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...
rysiora Posted March 25, 2006 Author Share Posted March 25, 2006 Your tab icons a little bit easier (since beta 3.1.1.78) A small thing that I've missed Thanks Holgerhttp://www.autoitscript.com/forum/index.ph...ndpost&p=160433Yeah, it's very similar but I didn't see this topic 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