Jump to content

mLipok

MVPs
  • Posts

    11,785
  • Joined

  • Last visited

  • Days Won

    66

mLipok last won the day on March 29

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

29,884 profile views

mLipok's Achievements

  1. my modified example: #include <MsgBoxConstants.au3> #include <WinAPISysWin.au3> #include <WindowsStylesConstants.au3> Example() Func Example() Local $hWnd_0 = GUICreate("Window 0") ConsoleWrite("$hWnd_0 = " & $hWnd_0 & @CRLF) Local $hWnd_1 = GUICreate("Window 1", Default, Default, -1, -1, -1, $WS_EX_MDICHILD, $hWnd_0) ConsoleWrite("$hWnd_1 = " & $hWnd_1 & @CRLF) Local $hWnd_2 = GUICreate("Window 2", Default, Default, -1, -1, -1, -1, $hWnd_0) ConsoleWrite("$hWnd_2 = " & $hWnd_2 & @CRLF) ConsoleWrite(@CRLF) Local $id_Label_1 = GUICtrlCreateLabel("Label 1", 0, 0) Local $h_Label_1 = GUICtrlGetHandle($id_Label_1) ConsoleWrite("$h_Label_1 = " & $h_Label_1 & @CRLF) Local $id_Label_2 = GUICtrlCreateLabel("Label_2", 0, 0) Local $h_Label_2 = GUICtrlGetHandle($id_Label_2) ConsoleWrite("$h_Label_2 = " & $h_Label_2 & @CRLF) ConsoleWrite(@CRLF) ConsoleWrite("- " & "TEST 1: Parent :: Get Parent Ancestor of " & $h_Label_2 & " > " & _WinAPI_GetAncestor($h_Label_2, $GA_PARENT) & ' TITLE=' & WinGetTitle(_WinAPI_GetAncestor($h_Label_2, $GA_PARENT)) & @CRLF) ConsoleWrite("- " & "TEST 2: Root :: Get Root Ancestor of " & $h_Label_2 & " > " & _WinAPI_GetAncestor($h_Label_2, $GA_ROOT) & ' TITLE=' & WinGetTitle(_WinAPI_GetAncestor($h_Label_2, $GA_ROOT)) & @CRLF) ConsoleWrite("- " & "TEST 3: Root Owner :: Get Root Owner Ancestor of " & $h_Label_2 & " > " & _WinAPI_GetAncestor($h_Label_2, $GA_ROOTOWNER) & ' TITLE=' & WinGetTitle(_WinAPI_GetAncestor($h_Label_2, $GA_ROOTOWNER)) & @CRLF) EndFunc ;==>Example and the question: Could somebody show example when Test 1 result is different from Test 2 ? my results:
  2. Please take a look here: https://www.autoitscript.com/autoit3/files/beta/autoit/docs/functions/AutoItSetOption.htm IMHO this bolded text should be moved/attached/described here: https://www.autoitscript.com/autoit3/docs/functions/GUISetCoord.htm And I would like to propose also changes like this What is your opinion in this regard ? Examples:
  3. small modification (Au3Check was fired): #include <File.au3> #include <WinAPIReg.au3> #include <WinAPI.au3> #include <GUIConstantsEx.au3> Global Const $CLSCTX_INPROC_SERVER = 1 Global Const $CLSCTX_LOCAL_SERVER = 4 Global Const $CLSCTX_SERVER = BitOR($CLSCTX_INPROC_SERVER, $CLSCTX_LOCAL_SERVER) Global Const $sIID_IPreviewHandler = "{8895b1c6-b41f-4c1c-a562-0d564250836f}" Global Const $sTagIPreviewHandler = "SetWindow hresult(hwnd;ptr); SetRect hresult(hwnd); DoPreview hresult(); Unload hresult(); SetFocus hresult(); QueryFocus hresult(hwnd*);TranslateAccelerator hresult(ptr*);" Global Const $sIID_IInitializeWithStream = "{B824B49D-22AC-4161-AC8A-9916E8FA3F7F}" Global Const $sIID_IInitializeWithFile = "{B7D14566-0509-4CCE-A71F-0A554233BD9B}" Global Const $sTagIInitializeWithFiler = "Initialize hresult(wstr;uint);" Global Const $sTagIInitializeWithStream = "Initialize hresult(ptr;uint);" _Test() Func _Test() _WinAPI_CoInitialize() Local $sFilePath = @ScriptDir & "\Tests.odt" ;chage me for another file If Not FileExists($sFilePath) Then $sFilePath = FileOpenDialog("Select a file to be loaded", @ScriptDir, "Any File Type (*.*)", $FD_FILEMUSTEXIST) If @error Then MsgBox($MB_SYSTEMMODAL, "", "No file(s) were selected.") FileChangeDir(@ScriptDir) Exit Else ; Change the working directory (@WorkingDir) back to the location of the script directory as FileOpenDialog sets it to the last accessed folder. FileChangeDir(@ScriptDir) $sFilePath = StringReplace($sFilePath, "|", @CRLF) EndIf EndIf Local $sExtension = _GetFilePathExtension($sFilePath) ConsoleWrite("$sExtension: " & $sExtension & @CRLF) Local $ExtensionCLSID = _GetShellExtensionCLSIDForFileType($sExtension) ConsoleWrite("$ExtensionClsid: " & $ExtensionCLSID & @CRLF) Local $tIIDExtensionCLSID = _WinAPI_GUIDFromString($ExtensionCLSID) Local $tIIDIPreviewHandler = _WinAPI_GUIDFromString($sIID_IPreviewHandler) Local $aRet = DllCall("ole32.dll", "long", "CoCreateInstance", "ptr", DllStructGetPtr($tIIDExtensionCLSID), "ptr", 0, "dword", $CLSCTX_SERVER, "ptr", DllStructGetPtr($tIIDIPreviewHandler), "ptr*", 0) Local $pIPreviewHandler = $aRet[5] ConsoleWrite("$pIPreviewHandler: " & $pIPreviewHandler & @CRLF) Local $oPreviewHandler = ObjCreateInterface($pIPreviewHandler, $sIID_IPreviewHandler, $sTagIPreviewHandler) ConsoleWrite("$oPreviewHandler: " & IsObj($oPreviewHandler) & @CRLF) Local $pIInitializeWithStream = 0 Local $pIInitializeWithFile = 0 $oPreviewHandler.QueryInterface($sIID_IInitializeWithStream, $pIInitializeWithStream) $oPreviewHandler.QueryInterface($sIID_IInitializeWithFile, $pIInitializeWithFile) ConsoleWrite("$pIInitializeWithStream: " & $pIInitializeWithStream & @CRLF) ConsoleWrite("$pIInitializeWithFile: " & $pIInitializeWithFile & @CRLF) If $pIInitializeWithStream Then Local $pIStream = 0 $aRet = DllCall("shlwapi.dll", "long", "SHCreateStreamOnFileEx", _ "wstr", $sFilePath, _ "dword", BitOR(0x00000000, 0x00000020), _ "dword", 0, _ "boolean", False, _ "ptr", 0, _ "ptr*", 0) $pIStream = $aRet[6] ConsoleWrite("$pIStream: " & $pIStream & @CRLF) Local $oIInitializeWithStream = ObjCreateInterface($pIInitializeWithStream, $sIID_IInitializeWithStream, $sTagIInitializeWithStream) $oIInitializeWithStream.Initialize($pIStream, 0) ElseIf $pIInitializeWithFile Then Local $oIInitializeWithFile = ObjCreateInterface($pIInitializeWithFile, $sIID_IInitializeWithFile, $sTagIInitializeWithFiler) ConsoleWrite("$oIInitializeWithFile: " & IsObj($oIInitializeWithFile) & @CRLF) ConsoleWrite("$oIInitializeWithFile.Initialize: " & $oIInitializeWithFile.Initialize($sFilePath, 0x00000000) & @CRLF) ;$STGM_READ = $STGM_READ Else ConsoleWrite("-Error Interface" & @CRLF) EndIf Local $hGUI = GUICreate("IPreviewHandler", 400, 400) Local $idPic = GUICtrlCreatePic("", 10, 10, 380, 380) Local $hWnd, $tRECT $hWnd = GUICtrlGetHandle($idPic) $tRECT = _WinAPI_GetClientRect($hWnd) ConsoleWrite("oPreviewHandler.etWindow: " & $oPreviewHandler.SetWindow($hWnd, DllStructGetPtr($tRECT)) & @CRLF) ConsoleWrite("oPreviewHandler.etWindow: " & $oPreviewHandler.DoPreview() & @CRLF) GUISetState(@SW_SHOW, $hGUI) While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop EndSwitch WEnd GUIDelete($hGUI) EndFunc ;==>_Test Func _GetFilePathExtension($sFilePath) Local $sDrive = "", $sDir = "", $sFileName = "", $sExtension = "" _PathSplit($sFilePath, $sDrive, $sDir, $sFileName, $sExtension) Return $sExtension EndFunc ;==>_GetFilePathExtension Func _GetShellExtensionCLSIDForFileType($sExtension) Local $sAssoc = _WinAPI_AssocQueryString($sExtension, $ASSOCSTR_SHELLEXTENSION, $ASSOCF_INIT_DEFAULTTOSTAR, $sIID_IPreviewHandler) Return $sAssoc EndFunc ;==>_GetShellExtensionCLSIDForFileType
  4. I'm not familiar with low level WinAPI so as so far ChatGPT results: #include <WinAPI.au3> #include <GUIConstantsEx.au3> ; GUID helper Func CLSIDFromString($sGUID) Local $tGUID = DllStructCreate("byte[16]") DllCall("ole32.dll", "long", "CLSIDFromString", "wstr", $sGUID, "ptr", DllStructGetPtr($tGUID)) Return $tGUID EndFunc ;==>CLSIDFromString ; --- INIT COM --- DllCall("ole32.dll", "long", "CoInitialize", "ptr", 0) Local $file = FileOpenDialog("PDF", @ScriptDir, "PDF (*.pdf)") If @error Then Exit ; --- pobierz CLSID preview handlera dla .pdf --- Local $reg = RegRead("HKEY_CLASSES_ROOT\.pdf\shellex\{8895b1c6-b41f-4c1c-a562-0d564250836f}", "") If @error Then MsgBox(16, "Error", "Brak preview handlera") Exit EndIf Local $tCLSID = CLSIDFromString($reg) Local $tIID_IPreviewHandler = CLSIDFromString("{8895b1c6-b41f-4c1c-a562-0d564250836f}") ; CoCreateInstance Local $aCall = DllCall("ole32.dll", "long", "CoCreateInstance", _ "ptr", DllStructGetPtr($tCLSID), _ "ptr", 0, _ "dword", 1, _ ; CLSCTX_INPROC_SERVER "ptr", DllStructGetPtr($tIID_IPreviewHandler), _ "ptr*", 0) If $aCall[0] <> 0 Then MsgBox(16, "Error", "CoCreateInstance failed") Exit EndIf Local $pPreview = $aCall[5] ; --- GUI --- $hGUI = GUICreate("IPreviewHandler", 800, 600) GUISetState() ; RECT Local $tRect = DllStructCreate("long Left;long Top;long Right;long Bottom") DllStructSetData($tRect, "Left", 0) DllStructSetData($tRect, "Top", 0) DllStructSetData($tRect, "Right", 800) DllStructSetData($tRect, "Bottom", 600) ; --- VTABLE --- Local $pVTable = DllStructGetData(DllStructCreate("ptr", $pPreview), 1) Func VTableCall($pObj, $index, $retType, $argTypes, $args) Local $pVT = DllStructGetData(DllStructCreate("ptr", $pObj), 1) Local $pFunc = DllStructGetData(DllStructCreate("ptr", $pVT + ($index * @AutoItX64 * 8)), 1) Return DllCallAddress($retType, $pFunc, "ptr", $pObj, $argTypes, $args) EndFunc ;==>VTableCall ; indeksy metod (IPreviewHandler) ; 3 = SetWindow ; 4 = SetRect ; 5 = DoPreview ; SetWindow(hwnd, rect) DllCallAddress("long", _ DllStructGetData(DllStructCreate("ptr", $pVTable + (3 * 8)), 1), _ "ptr", $pPreview, _ "hwnd", $hGUI, _ "ptr", DllStructGetPtr($tRect)) ; SetRect(rect) DllCallAddress("long", _ DllStructGetData(DllStructCreate("ptr", $pVTable + (4 * 8)), 1), _ "ptr", $pPreview, _ "ptr", DllStructGetPtr($tRect)) ; InitializeWithFile (inna interfejs!) ; GUID: IInitializeWithFile Local $tIID_Init = CLSIDFromString("{b7d14566-0509-4cce-a71f-0a554233bd9b}") Local $aQI = DllCall("ole32.dll", "long", "CoCreateInstance", _ "ptr", DllStructGetPtr($tCLSID), _ "ptr", 0, _ "dword", 1, _ "ptr", DllStructGetPtr($tIID_Init), _ "ptr*", 0) Local $pInit = $aQI[5] ; InitializeWithFile(file) Local $pVT2 = DllStructGetData(DllStructCreate("ptr", $pInit), 1) DllCallAddress("long", _ DllStructGetData(DllStructCreate("ptr", $pVT2 + (3 * 8)), 1), _ "ptr", $pInit, _ "wstr", $file, _ "dword", 0) ; DoPreview() DllCallAddress("long", _ DllStructGetData(DllStructCreate("ptr", $pVTable + (5 * 8)), 1), _ "ptr", $pPreview) ; loop While GUIGetMsg() <> $GUI_EVENT_CLOSE WEnd ; cleanup DllCall("ole32.dll", "none", "CoUninitialize") of course not working
  5. Maybe with this: https://learn.microsoft.com/en-us/windows/win32/api/shobjidl_core/nn-shobjidl_core-ipreviewhandler
  6. If you have LibreOffice installed, you can preview LibreOffice documents in Windows Explorer. I wonder if it's possible to embed the document preview itself into the AutoIt window? Will the PDF preview work the same way out of the box? I know about: and: Before I focus on these threads, I'd first like to ask your opinion on whether this is possible? Or has anyone already tried it?
  7. @jpm could you add this colors list to the HelpFile ?
  8. As you run 32bit SciTE
  9. I think You should move to WebDriver or WebView
  10. Thank you all for your commitment to solving this problem.
  11. Finall solution: #include <ComboConstants.au3> #include <GUIConstantsEx.au3> #include <GuiRichEdit.au3> Global Const $ES_EX_ALLOWEOL_CR = 0x0001 Global Const $ES_EX_ALLOWEOL_LF = 0x0002 Global Const $ES_EX_ALLOWEOL_ALL = BitOR($ES_EX_ALLOWEOL_CR, $ES_EX_ALLOWEOL_LF) Global Const $ES_EX_CONVERT_EOL_ON_PASTE = 0x0004 Global Const $ES_EX_ZOOMABLE = 0x0010 Global Const $EM_SETEXTENDEDSTYLE = ($ECM_FIRST + 10) ;~ Global Const $EM_GETEXTENDEDSTYLE = ($ECM_FIRST + 11) _Example() Func _Example() GUICreate("Example", 400, 400) Local $idEdit = GUICtrlCreateEdit("Ctrl Wheel to ZoomIn / ZoomOut", 4, 4, 392, 400 - 8) ; Don't use ES_EX_ with GUICtrlCreateEdit - Values are not window extended styles! ; wparam = bits of exstyle to set. lparam = exstyle GUICtrlSendMsg($idEdit, $EM_SETEXTENDEDSTYLE, $ES_EX_ZOOMABLE, $ES_EX_ZOOMABLE) GUISetState() ;Set zoom to 200% (wparam = numerator, lparam = denominator) GUICtrlSendMsg($idEdit, $EM_SETZOOM, 2, 1) Do Until GUIGetMsg() = $GUI_EVENT_CLOSE EndFunc ;==>_Example
  12. @Jos in reference to https://www.autoitscript.com/trac/autoit/ticket/4087 I notice 2 issues, and maybe one of them is exact the same like in the ticket. Please focus on the comments in the following repro script #include <Array.au3> #AutoIt3Wrapper_UseX64=n Func _Test1() ; I assume _Test1() should always use highlighting style like localy defined function >> style.au3.17 ; ISSUE 1: but sometimes it switch to style.au3.0 ; just try to jump in Array.au3 UDF and jump back to this testing file / script EndFunc ;==>_Test1 Volatile Func _Test2() ; I assume _Test2() uses the highlighting style >> style.au3.0 ; ISSUE 2: IMHO it should be the same like for _Test1() I mean style.au3.17 instead style.au3.0 ; because the fact that it is still function names - defined in current filean thus should use >> style.au3.17 instead >> style.au3.0 EndFunc ;==>_Test2 Func __someinternal() EndFunc ;==>__someinternal _ArrayDisplay() What is your opinion?
  13. It look like the -2 is default unset value: #Region ; *** Dynamically added Include files *** #include <WindowsStylesConstants.au3> ; added:04/02/26 03:50:18 #EndRegion ; *** Dynamically added Include files *** ; == Example 2 ; Coloring Groups #include <ColorConstants.au3> #include <GUIConstantsEx.au3> #include <GuiImageList.au3> #include <GuiListView.au3> #include <WinAPIGdi.au3> #include <WinAPIGdiDC.au3> #include <WinAPIHObj.au3> Global $g_hGUI = 0, $g_hListView = 00 Example() Func Example() ; create GUI window $g_hGUI = GUICreate("Example") ; create ListView control Local $idListview = GUICtrlCreateListView("", 10, 10, 350, 200) $g_hListView = ControlGetHandle($g_hGUI, '', $idListview) ; Enable extended control styles ;~ _GUICtrlListView_SetExtendedListViewStyle($idListview, BitOR($LVS_EX_FULLROWSELECT, $LVS_EX_SUBITEMIMAGES)) GUISetState(@SW_SHOW) ; Set ANSI format ;~ _GUICtrlListView_SetUnicodeFormat($idListview, False) GUIRegisterMsg($WM_NOTIFY, WM_NOTIFY) ; Load images Local $hImage = _GUIImageList_Create() _GUIImageList_Add($hImage, _GUICtrlListView_CreateSolidBitMap($idListview, $COLOR_RED, 16, 16)) _GUIImageList_Add($hImage, _GUICtrlListView_CreateSolidBitMap($idListview, $COLOR_GREEN, 16, 16)) _GUIImageList_Add($hImage, _GUICtrlListView_CreateSolidBitMap($idListview, $COLOR_BLUE, 16, 16)) _GUICtrlListView_SetImageList($idListview, $hImage, 1) ; Add columns _GUICtrlListView_AddColumn($idListview, "Column 1", 100) _GUICtrlListView_AddColumn($idListview, "Column 2", 100) _GUICtrlListView_AddColumn($idListview, "Column 3", 100) ; Add items _GUICtrlListView_AddItem($idListview, "Row 1: Col 1", 0) _GUICtrlListView_AddSubItem($idListview, 0, "Row 1: Col 2", 1, 1) _GUICtrlListView_AddSubItem($idListview, 0, "Row 1: Col 3", 2, 2) _GUICtrlListView_AddItem($idListview, "Row 2: Col 1", 1) _GUICtrlListView_AddSubItem($idListview, 1, "Row 2: Col 2", 1, 2) _GUICtrlListView_AddItem($idListview, "Row 3: Col 1", 2) For $I = 4 To 20 _GUICtrlListView_AddItem($idListview, "Row " & $I & ": Col 1", 2) Next ; Build groups _GUICtrlListView_EnableGroupView($idListview) _GUICtrlListView_InsertGroup($idListview, -1, 1, "Group 1") _GUICtrlListView_InsertGroup($idListview, -1, 2, "Group 2") _GUICtrlListView_SetItemGroupID($idListview, 0, 1) _GUICtrlListView_SetItemGroupID($idListview, 1, 2) _GUICtrlListView_SetItemGroupID($idListview, 2, 2) ; Inserting new item to the group _GUICtrlListView_InsertItem($idListview, "Inserted Item", 1, 1) MsgBox($MB_TOPMOST, "TEST #" & @ScriptLineNumber, 'Before Setting the GROUP assignment' & @CRLF & _GUICtrlListView_GetItemGroupID($idListview, 1)) _GUICtrlListView_SetItemGroupID($idListview, 1, 1) MsgBox($MB_TOPMOST, "TEST #" & @ScriptLineNumber, 'Before switching the GROUP assignment' & @CRLF & _GUICtrlListView_GetItemGroupID($idListview, 1)) _GUICtrlListView_SetItemGroupID($idListview, 1, 2) MsgBox($MB_TOPMOST, "TEST #" & @ScriptLineNumber, 'Before removing the GROUP assignment' & @CRLF & _GUICtrlListView_GetItemGroupID($idListview, 1)) _GUICtrlListView_SetItemGroupID($idListview, 1, -5) MsgBox($MB_TOPMOST, "TEST #" & @ScriptLineNumber, 'After removing the GROUP assignment' & @CRLF & _GUICtrlListView_GetItemGroupID($idListview, 1)) ; Loop until the user exits. Do Until GUIGetMsg() = $GUI_EVENT_CLOSE GUIDelete() EndFunc ;==>Example Func WM_NOTIFY($hWnd, $iMsg, $wParam, $lParam) #forceref $iMsg, $wParam If $hWnd = $g_hGUI Then ; check if Our GUI - in case you create multiple GUI - Window Local $tItem = DllStructCreate($tagNMLVCUSTOMDRAW, $lParam) If $tItem.hWndFrom = $g_hListView Then ; check if our ListView - in case you have few ListView on the same GUI - Window Local $iItemSpec = $tItem.dwItemSpec ; ItemIndex for "RowElement", GroupID for "GroupElement" If $iItemSpec >= 0 And $tItem.Code = $NM_CUSTOMDRAW And $tItem.dwItemType = $LVCDI_GROUP And $tItem.dwDrawStage = $CDDS_PREPAINT Then Local $tRect = DllStructCreate($tagRECT, DllStructGetPtr($tItem, "left")) #Region ; create full row background (black) with a leading line (red) $tRect.bottom = $tRect.top + 15 Local $hBrush = _WinAPI_CreateSolidBrush($COLOR_BLACK) _WinAPI_FillRect($tItem.HDC, $tRect, $hBrush) _WinAPI_DeleteObject($hBrush) Local $hPen = _WinAPI_CreatePen($PS_SOLID, 1, _WinAPI_SwitchColor($COLOR_RED)) ; RGB to BGR Local $oOrig = _WinAPI_SelectObject($tItem.HDC, $hPen) _WinAPI_DrawLine($tItem.HDC, $tRect.left + 5, $tRect.top + 8, $tRect.right - 5, $tRect.top + 8) _WinAPI_SelectObject($tItem.HDC, $oOrig) _WinAPI_DeleteObject($hPen) Local $aGroup = _GUICtrlListView_GetGroupInfo($tItem.hWndFrom, $iItemSpec) #EndRegion ; create full row background (black) with a leading line (red) #Region ; repaint the text with your own color (dark blue) and your own background (light blue) - on the previously created full row background _WinAPI_SetBkColor($tItem.HDC, _WinAPI_SwitchColor($COLOR_LIGHTBLUE)) ; RGB to BGR _WinAPI_SetBkMode($tItem.HDC, $OPAQUE) _WinAPI_SetTextColor($tItem.HDC, _WinAPI_SwitchColor($COLOR_BLUE)) ; RGB to BGR $tRect.left += 20 _WinAPI_DrawText($tItem.HDC, " " & $aGroup[0] & " ", $tRect, $DT_LEFT) #EndRegion ; repaint the text with your own color (dark blue) and your own background (light blue) - on the previously created full row background Return $CDRF_SKIPDEFAULT EndIf EndIf EndIf EndFunc ;==>WM_NOTIFY
  14. Still working around. Here is my new stuff: Modified: _GUICtrlListView_InsertGroup[2].au3 #Region ; *** Dynamically added Include files *** #include <WindowsStylesConstants.au3> ; added:04/02/26 03:50:18 #EndRegion ; *** Dynamically added Include files *** ; == Example 2 ; Coloring Groups #include <ColorConstants.au3> #include <GUIConstantsEx.au3> #include <GuiImageList.au3> #include <GuiListView.au3> #include <WinAPIGdi.au3> #include <WinAPIGdiDC.au3> #include <WinAPIHObj.au3> Global $g_hGUI = 0, $g_hListView = 00 Example() Func Example() ; create GUI window $g_hGUI = GUICreate("Example") ; create ListView control Local $idListview = GUICtrlCreateListView("", 10, 10, 350, 200) $g_hListView = ControlGetHandle($g_hGUI, '', $idListview) ; Enable extended control styles ;~ _GUICtrlListView_SetExtendedListViewStyle($idListview, BitOR($LVS_EX_FULLROWSELECT, $LVS_EX_SUBITEMIMAGES)) GUISetState(@SW_SHOW) ; Set ANSI format ;~ _GUICtrlListView_SetUnicodeFormat($idListview, False) GUIRegisterMsg($WM_NOTIFY, WM_NOTIFY) ; Load images Local $hImage = _GUIImageList_Create() _GUIImageList_Add($hImage, _GUICtrlListView_CreateSolidBitMap($idListview, $COLOR_RED, 16, 16)) _GUIImageList_Add($hImage, _GUICtrlListView_CreateSolidBitMap($idListview, $COLOR_GREEN, 16, 16)) _GUIImageList_Add($hImage, _GUICtrlListView_CreateSolidBitMap($idListview, $COLOR_BLUE, 16, 16)) _GUICtrlListView_SetImageList($idListview, $hImage, 1) ; Add columns _GUICtrlListView_AddColumn($idListview, "Column 1", 100) _GUICtrlListView_AddColumn($idListview, "Column 2", 100) _GUICtrlListView_AddColumn($idListview, "Column 3", 100) ; Add items _GUICtrlListView_AddItem($idListview, "Row 1: Col 1", 0) _GUICtrlListView_AddSubItem($idListview, 0, "Row 1: Col 2", 1, 1) _GUICtrlListView_AddSubItem($idListview, 0, "Row 1: Col 3", 2, 2) _GUICtrlListView_AddItem($idListview, "Row 2: Col 1", 1) _GUICtrlListView_AddSubItem($idListview, 1, "Row 2: Col 2", 1, 2) _GUICtrlListView_AddItem($idListview, "Row 3: Col 1", 2) For $I = 4 To 20 _GUICtrlListView_AddItem($idListview, "Row " & $I & ": Col 1", 2) Next ; Build groups _GUICtrlListView_EnableGroupView($idListview) _GUICtrlListView_InsertGroup($idListview, -1, 1, "Group 1") _GUICtrlListView_InsertGroup($idListview, -1, 2, "Group 2") _GUICtrlListView_SetItemGroupID($idListview, 0, 1) _GUICtrlListView_SetItemGroupID($idListview, 1, 2) _GUICtrlListView_SetItemGroupID($idListview, 2, 2) ; Inserting new item to the group _GUICtrlListView_InsertItem($idListview, "Inserted Item", 1, 1) _GUICtrlListView_SetItemGroupID($idListview, 1, 1) MsgBox($MB_TOPMOST, "TEST #" & @ScriptLineNumber, 'Before switching the GROUP assignment') _GUICtrlListView_SetItemGroupID($idListview, 1, 2) MsgBox($MB_TOPMOST, "TEST #" & @ScriptLineNumber, 'Before removing the GROUP assignment') _GUICtrlListView_SetItemGroupID($idListview, 1, -5) MsgBox($MB_TOPMOST, "TEST #" & @ScriptLineNumber, 'After removing the GROUP assignment' & @CRLF & _GUICtrlListView_GetItemGroupID($idListview, 1)) ; Loop until the user exits. Do Until GUIGetMsg() = $GUI_EVENT_CLOSE GUIDelete() EndFunc ;==>Example Func WM_NOTIFY($hWnd, $iMsg, $wParam, $lParam) #forceref $iMsg, $wParam If $hWnd = $g_hGUI Then ; check if Our GUI - in case you create multiple GUI - Window Local $tItem = DllStructCreate($tagNMLVCUSTOMDRAW, $lParam) If $tItem.hWndFrom = $g_hListView Then ; check if our ListView - in case you have few ListView on the same GUI - Window Local $iItemSpec = $tItem.dwItemSpec ; ItemIndex for "RowElement", GroupID for "GroupElement" If $iItemSpec >= 0 And $tItem.Code = $NM_CUSTOMDRAW And $tItem.dwItemType = $LVCDI_GROUP And $tItem.dwDrawStage = $CDDS_PREPAINT Then Local $tRect = DllStructCreate($tagRECT, DllStructGetPtr($tItem, "left")) #Region ; create full row background (black) with a leading line (red) $tRect.bottom = $tRect.top + 15 Local $hBrush = _WinAPI_CreateSolidBrush($COLOR_BLACK) _WinAPI_FillRect($tItem.HDC, $tRect, $hBrush) _WinAPI_DeleteObject($hBrush) Local $hPen = _WinAPI_CreatePen($PS_SOLID, 1, _WinAPI_SwitchColor($COLOR_RED)) ; RGB to BGR Local $oOrig = _WinAPI_SelectObject($tItem.HDC, $hPen) _WinAPI_DrawLine($tItem.HDC, $tRect.left + 5, $tRect.top + 8, $tRect.right - 5, $tRect.top + 8) _WinAPI_SelectObject($tItem.HDC, $oOrig) _WinAPI_DeleteObject($hPen) Local $aGroup = _GUICtrlListView_GetGroupInfo($tItem.hWndFrom, $iItemSpec) #EndRegion ; create full row background (black) with a leading line (red) #Region ; repaint the text with your own color (dark blue) and your own background (light blue) - on the previously created full row background _WinAPI_SetBkColor($tItem.HDC, _WinAPI_SwitchColor($COLOR_LIGHTBLUE)) ; RGB to BGR _WinAPI_SetBkMode($tItem.HDC, $OPAQUE) _WinAPI_SetTextColor($tItem.HDC, _WinAPI_SwitchColor($COLOR_BLUE)) ; RGB to BGR $tRect.left += 20 _WinAPI_DrawText($tItem.HDC, " " & $aGroup[0] & " ", $tRect, $DT_LEFT) #EndRegion ; repaint the text with your own color (dark blue) and your own background (light blue) - on the previously created full row background Return $CDRF_SKIPDEFAULT EndIf EndIf EndIf EndFunc ;==>WM_NOTIFY Question: Why _GUICtrlListView_GetItemGroupID() returns -2 here: MsgBox($MB_TOPMOST, "TEST #" & @ScriptLineNumber, 'After removing the GROUP assignment' & @CRLF & _GUICtrlListView_GetItemGroupID($idListview, 1))
×
×
  • Create New...