Jump to content

mLipok

MVPs
  • Posts

    11,977
  • Joined

  • Last visited

  • Days Won

    68

mLipok last won the day on May 11

mLipok had the most liked content!

About mLipok

  • Birthday 07/19/1978

Profile Information

  • Member Title
    Sometimes... even usually I'm nitpicky.
  • Location
    Europe, Poland, Upper Silesia, Zabrze
  • Interests
    ¯\_(ツ)_/¯

Recent Profile Visitors

30,818 profile views

mLipok's Achievements

  1. Thanks to @Nine code from here: ListView + ImageList for GroupHeader ( LVSIL_GROUPHEADER ) here is my modified code: ;~ https://www.autoitscript.com/forum/topic/213683-listview-imagelist-for-groupheader-lvsil_groupheader ; From Nine (base code of mLipok) #include <GUIConstantsEx.au3> #include <GuiListView.au3> #include <GuiImageList.au3> ;~ Global Const $LVNI_SAMEGROUPONLY = 0x0080 ;~ Global Const $LVSIL_GROUPHEADER = 3 Global Const $tagLVGROUPEx = _ "uint cbSize;" & _ "uint mask;" & _ "ptr pszHeader;" & _ "int cchHeader;" & _ "ptr pszFooter;" & _ "int cchFooter;" & _ "int iGroupId;" & _ "uint stateMask;" & _ "uint state;" & _ "uint uAlign;" & _ "ptr pszSubtitle;" & _ "uint cchSubtitle;" & _ "ptr pszTask;" & _ "uint cchTask;" & _ "ptr pszDescriptionTop;" & _ "uint cchDescriptionTop;" & _ "ptr pszDescriptionBottom;" & _ "uint cchDescriptionBottom;" & _ "int iTitleImage;" & _ "int iExtendedImage;" & _ "int iFirstItem;" & _ "uint cItems;" & _ "ptr pszSubsetTitle;" & _ "uint cchSubsetTitle" Global $tInfo = DllStructCreate("dword cbSize;dword dwMajorVersion;dword dwMinorVersion;dword dwBuildNumber;dword dwPlatformID;dword dwFlags;uint64 ullVersion;") $tInfo.cbSize = DllStructGetSize($tInfo) DllCall("ComCtl32.dll", "long", "DllGetVersion", "struct*", $tInfo) If $tInfo.dwMajorVersion < 6 Then Exit ConsoleWrite("You need version 6 or higher" & @CRLF) Example() Func Example() Local $hGUI = GUICreate("GroupHeaderImageList", 500, 300) #forceref $hGUI Local $idListView = GUICtrlCreateListView("Name|Value", 10, 10, 480, 250) Local $hListView = GUICtrlGetHandle($idListView) _GUICtrlListView_EnableGroupView($hListView) _GUICtrlListView_InsertGroup($hListView, -1, 101, 'Group A') Local $iItem0 = _GUICtrlListView_AddItem($hListView, "Item 0") _GUICtrlListView_AddSubItem($hListView, $iItem0, "123", 1) _GUICtrlListView_SetItemGroupID($hListView, $iItem0, 101) Local $iItem1 = _GUICtrlListView_AddItem($hListView, "Item 1") _GUICtrlListView_AddSubItem($hListView, $iItem1, "234", 1) _GUICtrlListView_SetItemGroupID($hListView, $iItem1, 101) #Region ; Nine code Local $hImageList = _GUIImageList_Create(16, 16, 5, 3) _GUIImageList_AddIcon($hImageList, @SystemDir & "\shell32.dll", 110) _SendMessage($hListView, $LVM_SETIMAGELIST, $LVSIL_GROUPHEADER, $hImageList) Local $sHeader = "Group B" Local $tText = DllStructCreate("wchar[" & StringLen($sHeader) + 1 & "]") DllStructSetData($tText, 1, $sHeader) Local $tGroup_template = DllStructCreate($tagLVGROUPEx) Local $tGroup = $tGroup_template $tGroup.cbSize = DllStructGetSize($tGroup) $tGroup.mask = BitOR($LVGF_HEADER, $LVGF_GROUPID, $LVGF_TITLEIMAGE) $tGroup.pszHeader = DllStructGetPtr($tText) $tGroup.cchHeader = StringLen($sHeader) $tGroup.iGroupId = 102 $tGroup.iTitleImage = 0 _SendMessage($hListView, $LVM_INSERTGROUP, -1, DllStructGetPtr($tGroup)) Local $iItem2 = _GUICtrlListView_AddItem($hListView, "Item 2") _GUICtrlListView_AddSubItem($hListView, $iItem2, "456", 1) _GUICtrlListView_SetItemGroupID($hListView, $iItem2, 102) ConsoleWrite("- $iItem2=" & $iItem2 & @CRLF) Local $iItem3 = _GUICtrlListView_AddItem($hListView, "Item 3") _GUICtrlListView_AddSubItem($hListView, $iItem3, "567", 1) _GUICtrlListView_SetItemGroupID($hListView, $iItem3, 102) ConsoleWrite("- $iItem3=" & $iItem3 & @CRLF) Local $iItem4 = _GUICtrlListView_AddItem($hListView, "Item 4") _GUICtrlListView_AddSubItem($hListView, $iItem4, "678", 1) _GUICtrlListView_SetItemGroupID($hListView, $iItem4, 102) ConsoleWrite("- $iItem4=" & $iItem4 & @CRLF) #EndRegion ; Nine code _GUICtrlListView_InsertGroup($hListView, -1, 103, 'Group C') Local $iItem5 = _GUICtrlListView_AddItem($hListView, "Item 5") _GUICtrlListView_AddSubItem($hListView, $iItem5, "9a", 1) _GUICtrlListView_SetItemGroupID($hListView, $iItem5, 103) Local $iItem6 = _GUICtrlListView_AddItem($hListView, "Item 6") _GUICtrlListView_AddSubItem($hListView, $iItem6, "9b", 1) _GUICtrlListView_SetItemGroupID($hListView, $iItem6, 103) ConsoleWrite("_GetGroupFirstItem() = " & _GetGroupFirstItem($hListView, 102) & @CRLF) ConsoleWrite("_GetGroupItemsCount() = " & _GetGroupItemsCount($hListView, 102) & @CRLF) _GetGroupAllItems($hListView, 102) GUISetState() While GUIGetMsg() <> $GUI_EVENT_CLOSE WEnd EndFunc ;==>Example Func _GetGroupAllItems($hListView, $iGroupID) Local $iFirstItem = _GetGroupFirstItem($hListView, $iGroupID) ConsoleWrite("+ $iFirstItem=" & $iFirstItem & @CRLF) ;~ For $IDX = $iFirstItem To $iFirstItem Local $iCheckItem = $iFirstItem, $iNextItem While 1 $iNextItem = _GetGroupNextItem($hListView, $iCheckItem) ;~ $iNextItem = _GUICtrlListView_GetNextItem_mod($hListView, $iCheckItem, 2, 16) ConsoleWrite("+ $iNextItem=" & $iNextItem & @CRLF) If $iNextItem = -1 Then ExitLoop $iCheckItem = $iNextItem Sleep(10) WEnd EndFunc ;==>_GetGroupAllItems Func _GetGroupNextItem($hListView, $iItemIndex) Local $iGroup = _GUICtrlListView_GetGroupIndexByItemIndex($hListView, $iItemIndex, $iGroup) ; https://learn.microsoft.com/en-us/windows/win32/api/commctrl/ns-commctrl-lvitemindex Local Const $tagLVITEMINDEX = "int iItem;int iGroup" Local $tIndex = DllStructCreate($tagLVITEMINDEX) $tIndex.iItem = $iItemIndex $tIndex.iGroup = $iGroup ConsoleWrite("- $iGroup=" & $iGroup & @CRLF) _SendMessage( _ $hListView, _ $LVM_GETNEXTITEMINDEX, _ DllStructGetPtr($tIndex), _ $LVNI_SAMEGROUPONLY) Return $tIndex.iItem EndFunc ;==>_GetGroupNextItem Func _GetGroupFirstItem($hListView, $iGroupID) Local $t = DllStructCreate($tagLVGROUPEx) $t.cbSize = DllStructGetSize($t) ; IMPORTANT: request iFirstItem $t.mask = $LVGF_ITEMS _SendMessage($hListView, $LVM_GETGROUPINFO, $iGroupID, DllStructGetPtr($t)) Return $t.iFirstItem EndFunc ;==>_GetGroupFirstItem Func _GetGroupItemsCount($hListView, $iGroupID) Local $t = DllStructCreate($tagLVGROUPEx) $t.cbSize = DllStructGetSize($t) ; IMPORTANT: request BOTH fields $t.mask = $LVGF_ITEMS _SendMessage($hListView, $LVM_GETGROUPINFO, $iGroupID, DllStructGetPtr($t)) Return $t.cItems EndFunc ;==>_GetGroupItemsCount Func _GUICtrlListView_GetNextItem_mod($hWnd, $iStart = -1, $iSearch = 0, $iState = 8) Local $aSearch[5] = [$LVNI_ALL, $LVNI_ABOVE, $LVNI_BELOW, $LVNI_TOLEFT, $LVNI_TORIGHT] Local $iFlags = $aSearch[$iSearch] If BitAND($iState, 1) <> 0 Then $iFlags = BitOR($iFlags, $LVNI_CUT) If BitAND($iState, 2) <> 0 Then $iFlags = BitOR($iFlags, $LVNI_DROPHILITED) If BitAND($iState, 4) <> 0 Then $iFlags = BitOR($iFlags, $LVNI_FOCUSED) If BitAND($iState, 8) <> 0 Then $iFlags = BitOR($iFlags, $LVNI_SELECTED) If BitAND($iState, 16) <> 0 Then $iFlags = BitOR($iFlags, $LVNI_SAMEGROUPONLY) If IsHWnd($hWnd) Then Return _SendMessage($hWnd, $LVM_GETNEXTITEM, $iStart, $iFlags) Else Return GUICtrlSendMsg($hWnd, $LVM_GETNEXTITEM, $iStart, $iFlags) EndIf EndFunc ;==>_GUICtrlListView_GetNextItem_mod Func _GUICtrlListView_GetGroupIndexByItemIndex($hWnd, $iItem) ;https://www.autoitscript.com/forum/topic/213679-listview-get-igroupid-and-igroup-for-listviewitem/#findComment-1552392 Local $iGroupID = _GUICtrlListView_GetItemGroupID($hWnd, $iItem) Return _GUICtrlListView_GetGroupIndexByGroupID($hWnd, $iGroupID) EndFunc ;==>_GUICtrlListView_GetGroupIndexByItemIndex Func _GUICtrlListView_GetGroupIndexByGroupID($hWnd, $iGroupID) ;https://www.autoitscript.com/forum/topic/213679-listview-get-igroupid-and-igroup-for-listviewitem/#findComment-1552392 Local $iMaxIndex = _GUICtrlListView_GetGroupCount($hWnd) - 1 Local $aInfo For $i = 0 To $iMaxIndex $aInfo = _GUICtrlListView_GetGroupInfoByIndex($hWnd, $i) If $aInfo[2] = $iGroupID Then Return $i Next Return SetError(1, 0, -1) EndFunc ;==>_GUICtrlListView_GetGroupIndexByGroupID This both function works: _GetGroupItemsCount() and _GetGroupFirstItem() but I still have problems with: Func _GetGroupNextItem($hListView, $iItemIndex) Local $iGroup = _GUICtrlListView_GetGroupIndexByItemIndex($hListView, $iItemIndex, $iGroup) ; https://learn.microsoft.com/en-us/windows/win32/api/commctrl/ns-commctrl-lvitemindex Local Const $tagLVITEMINDEX = "int iItem;int iGroup" Local $tIndex = DllStructCreate($tagLVITEMINDEX) $tIndex.iItem = $iItemIndex $tIndex.iGroup = $iGroup ConsoleWrite("- $iGroup=" & $iGroup & @CRLF) _SendMessage( _ $hListView, _ $LVM_GETNEXTITEMINDEX, _ DllStructGetPtr($tIndex), _ $LVNI_SAMEGROUPONLY) Return $tIndex.iItem EndFunc ;==>_GetGroupNextItem
  2. When I talked to AI then it talks that not only ✔ iTitleImage ✔ LVSIL_GROUPHEADER should works, but also this following one ✔ iFirstItem ✔ cItems ✔ LVNI_SAMEGROUPONLY I already get it to work with: ✔ iFirstItem ✔ cItems But still have some issues with: ✔ LVNI_SAMEGROUPONLY So would you be so nice and take a look also on: ListView LVM_GETNEXTITEM + LVNI_SAMEGROUPONLY ?
  3. ;~ https://www.autoitscript.com/forum/topic/213683-listview-imagelist-for-groupheader-lvsil_groupheader #include <GUIConstantsEx.au3> #include <GuiListView.au3> #include <GuiImageList.au3> #include <WinAPIGdi.au3> Global Const $LVSIL_GROUPHEADER = 2 _Example() Func _Example() Local $hGUI = GUICreate("GroupHeaderImageList", 500, 300) #forceref $hGUI Local $idListView = GUICtrlCreateListView("Name|Value", 10, 10, 480, 250) Local $hListView = GUICtrlGetHandle($idListView) ; Enable group view _SendMessage($hListView, $LVM_ENABLEGROUPVIEW, True, 0) ; ===================================================== ; Create ImageList ; ===================================================== Local $hImageList = _GUIImageList_Create(16, 16) Local $hIcon = _WinAPI_LoadIcon(0, $IDI_INFORMATION) ; Add icon to ImageList _GUIImageList_AddIcon($hImageList, $hIcon) ; ===================================================== ; Set Group Header ImageList ; ===================================================== ListView_SetGroupHeaderImageList($hListView, $hImageList) ; ===================================================== ; Get Group Header ImageList ; ===================================================== Local $hReturned = ListView_GetGroupHeaderImageList($hListView) ConsoleWrite("Original : " & $hImageList & @CRLF) ConsoleWrite("Returned : " & "0x" & Hex($hReturned) & @CRLF) ; ===================================================== ; Create group ; ===================================================== Local $tagLVGROUP = _ "uint cbSize;" & _ "uint mask;" & _ "ptr pszHeader;" & _ "int cchHeader;" & _ "ptr pszFooter;" & _ "int cchFooter;" & _ "int iGroupId;" & _ "uint stateMask;" & _ "uint state;" & _ "uint uAlign;" & _ "ptr pszSubtitle;" & _ "uint cchSubtitle;" & _ "ptr pszTask;" & _ "uint cchTask;" & _ "ptr pszDescriptionTop;" & _ "uint cchDescriptionTop;" & _ "ptr pszDescriptionBottom;" & _ "uint cchDescriptionBottom;" & _ "int iTitleImage;" & _ "int iExtendedImage;" & _ "int iFirstItem;" & _ "uint cItems;" & _ "ptr pszSubsetTitle;" & _ "uint cchSubsetTitle" Local $sHeader = "Group A" Local $tText = DllStructCreate("wchar[" & StringLen($sHeader) + 1 & "]") DllStructSetData($tText, 1, $sHeader) Local $tGroup = DllStructCreate($tagLVGROUP) DllStructSetData($tGroup, "cbSize", DllStructGetSize($tGroup)) DllStructSetData($tGroup, "mask", _ BitOR($LVGF_HEADER, $LVGF_GROUPID, $LVGF_TITLEIMAGE)) DllStructSetData($tGroup, "pszHeader", DllStructGetPtr($tText)) DllStructSetData($tGroup, "cchHeader", StringLen($sHeader)) DllStructSetData($tGroup, "iGroupId", 1) ; Use image index 0 DllStructSetData($tGroup, "iTitleImage", 0) ; Insert group _SendMessage($hListView, $LVM_INSERTGROUP, -1, DllStructGetPtr($tGroup)) ; ===================================================== ; Add item into group ; ===================================================== Local $iItem = _GUICtrlListView_AddItem($hListView, "Item 1") _GUICtrlListView_AddSubItem($hListView, $iItem, "123", 1) _GUICtrlListView_SetItemGroupID($hListView, $iItem, 1) GUISetState() While GUIGetMsg() <> $GUI_EVENT_CLOSE WEnd EndFunc ;==>_Example ; #FUNCTION# =================================================================== ; Name...........: ListView_SetGroupHeaderImageList ; Description ...: Sets the ImageList used by group headers. ; ============================================================================== Func ListView_SetGroupHeaderImageList($hListView, $hImageList) Return _SendMessage( _ $hListView, _ $LVM_SETIMAGELIST, _ $LVSIL_GROUPHEADER, _ $hImageList) EndFunc ;==>ListView_SetGroupHeaderImageList ; #FUNCTION# =================================================================== ; Name...........: ListView_GetGroupHeaderImageList ; Description ...: Gets the ImageList used by group headers. ; ============================================================================== Func ListView_GetGroupHeaderImageList($hListView) Return _SendMessage( _ $hListView, _ $LVM_GETIMAGELIST, _ $LVSIL_GROUPHEADER, _ 0) EndFunc ;==>ListView_GetGroupHeaderImageList Still not works well. It sets and returns: But no images are displayed.
  4. At least for testing yes. Use it we will be able to check if it relates to other gui stuff.
  5. 12 years too late Unless you have code to unlock this library ?
  6. Thanks to you both for answers. Ok. do you mean for example: __DM_WinAPI_GetDeviceCaps() which is currently in UDF as _WinAPI_GetDeviceCaps() and acts exactly the same way ? or __DM_WinAPI_GetTextExtentPoint32() >> _WinAPI_GetTextExtentPoint32()
  7. As long as you remember... please add standard header generated by SciTE (CTRL + ALT + H) to each Func __DM_WinAPI_ and fullfill the ; Author ........: ????? information You can keep all others information not changed (as SciTE generate them).
  8. Please take a look on: https://www.autoitscript.com/trac/autoit/ticket/4095 as you are creator of ths function I would like to ask you to give your opinion on that sugestion/feature request to the UDF.
  9. I notice that in _GUICtrlListView_SortItems.au3 example _GUIImageList_AddIcon() function uses negative integers for indexes . _GUIImageList_AddIcon() documentation says: Why the negative indexes are used ?
  10. I tried to get it to work. Without success. Can anyone confirm this isn't working? Or fix it?
  11. I was trying to use _WinAPI_CompressBitmapBits.au3 example from the helpfile #include "Extras\HelpFileInternals.au3" #include <MsgBoxConstants.au3> #include <WinAPIFiles.au3> #include <WinAPIGdi.au3> #include <WinAPIHObj.au3> #include <WinAPIMem.au3> #include <WinAPIRes.au3> _Example() Func _Example() ; Load image Local $sBmp = _Extras_PathFull('AutoIt.bmp') Local $hSource = _WinAPI_LoadImage(0, $sBmp, $IMAGE_BITMAP, 0, 0, BitOR($LR_LOADFROMFILE, $LR_CREATEDIBSECTION)) ; Resize bitmap to 256x256 pixels Local $hBitmap = _WinAPI_AdjustBitmap($hSource, 256, 256, $HALFTONE) ; Create compressed PNG data Local $pData = 0 Local $iLength = _WinAPI_CompressBitmapBits($hBitmap, $pData, 2) ;$COMPRESSION_BITMAP_PNG) ; Create .ico file If Not @error Then Local $tICO = DllStructCreate('align 1;ushort Reserved;ushort Type;ushort Count;byte Header[20]') Local $tHDR = DllStructCreate('byte Width;byte Height;byte ColorCount;byte Reserved;ushort Planes;ushort BitCount;long Size;long Offset', DllStructGetPtr($tICO, 'Header')) DllStructSetData($tICO, 'Reserved', 0) DllStructSetData($tICO, 'Type', 1) DllStructSetData($tICO, 'Count', 1) DllStructSetData($tHDR, 'Width', 0) DllStructSetData($tHDR, 'Height', 0) DllStructSetData($tHDR, 'ColorCount', 0) DllStructSetData($tHDR, 'Reserved', 0) DllStructSetData($tHDR, 'Planes', 1) DllStructSetData($tHDR, 'BitCount', 32) DllStructSetData($tHDR, 'Size', $iLength) DllStructSetData($tHDR, 'Offset', DllStructGetSize($tICO)) Local $hFile = _WinAPI_CreateFile(@TempDir & '\MyIcon.ico', 1, 4) Local $iBytes _WinAPI_WriteFile($hFile, $tICO, DllStructGetSize($tICO), $iBytes) _WinAPI_WriteFile($hFile, $pData, $iLength, $iBytes) _WinAPI_CloseHandle($hFile) ShellExecute("MsPaint", '"' & @TempDir & '\MyIcon.ico' & '"') Else MsgBox($MB_SYSTEMMODAL, "Error", "_WinAPI_CompressBitmapBits() failed (@error = " & @error & ")") EndIf ; Delete unnecessary bitmaps _WinAPI_DeleteObject($hSource) _WinAPI_DeleteObject($hBitmap) ; Free memory _WinAPI_FreeMemory($pData) EndFunc ;==>_Example I get: Any help please.
  12. it was introduced: From this time only occasionally, some examples in HelpFile were changed. Even more, many Standard UDF's are still not ready for Au3Stripper.
×
×
  • Create New...