Leaderboard
Popular Content
Showing content with the highest reputation on 03/26/2021 in all areas
-
Set author in excel
FrancescoDiMuro and one other reacted to robertocm for a topic
Another example: #include <Excel.au3> #include <WinAPIFiles.au3> Opt("MustDeclareVars", 1) Opt("TrayIconDebug", 1) Global $sFilePath = @ScriptDir & "\" & "test.xlsx" Global $oMyError = ObjEvent("AutoIt.Error", "ErrFunc") ;Install a custom error handler Global $iEventError ; to be checked to know if com error occurs. Must be reset after handling. Global $oAppl = _Excel_Open() ;$oAppl.EnableEvents = False ;$oAppl.DisplayAlerts = False Global $oWorkbook = _Excel_BookNew($oAppl) $oWorkbook.Author = @YEAR & @MON & @MDAY _Excel_BookSaveAs($oWorkbook, $sFilePath, $xlOpenXMLWorkbook, True) ;$xlOpenXMLWorkbook 51 ;$xlExcel8 56 _Excel_BookClose($oWorkbook, False) ;$oAppl.EnableEvents = True ;$oAppl.DisplayAlerts = True While _WinAPI_FileInUse($sFilePath) Sleep(1000) Wend _Excel_Close($oAppl, False, True) ;This is a custom error handler Func ErrFunc() Local $HexNumber = Hex($oMyError.number, 8) ;~ MsgBox(0, "", "We intercepted a COM Error !" & @CRLF & _ ;~ "Number is: " & $HexNumber & @CRLF & _ ;~ "WinDescription is: " & $oMyError.windescription) ConsoleWrite("-> We intercepted a COM Error !" & @CRLF & _ "-> err.number is: " & @TAB & $HexNumber & @CRLF & _ "-> err.source: " & @TAB & $oMyError.source & @CRLF & _ "-> err.windescription: " & @TAB & $oMyError.windescription & _ "-> err.scriptline is: " & @TAB & $oMyError.scriptline & @CRLF) $iEventError = 1 ; Use to check when a COM Error occurs EndFunc ;==>ErrFunc2 points -
[Solved] AutoIt Window Info tool -> "Highlight Controls" MenuItem
pixelsearch and one other reacted to Nine for a topic
No there is no bug. You need to think with a wider scope. There is a reason why this option exists. Try mixing different options and you will find the usage of this particular one.2 points -
A virtual treeview with hundreds of thousands of items will most likely be used to provide some sort of overview of data, while it's less likely that it'll be used to correct a few individual items. If there's a need to manually correct a few individual items, then it'll be better to create a treeview that contains only those few items that it's about. When it comes to (human) manual correction of data, it's of course only about a very small amount of data. It's simply not possible to manually correct a very large amount of data. And when it comes to only a small amount of data, there's no problem in using a conventional treeview where all necessary functionality is already implemented. When it comes to very large amounts of data, then it must be a requirement that data is handled completely automatically. At least what I'm doing with virtual treeviews here is meant to provide some sort of overview of data. Therefore, it isn't my plan to code functions to handle individual items. Another problem with updating individual items in a large virtual treeview is that the update must take place in the data source. Data isn't stored in the treeview itself. But to update a large array (e.g. move array elements up/down when a treeview item is deleted/added) in an interpreted language like AutoIt isn't fast. But even worse is that since the array index is stored in the Param field of the TVITEM structure, moving array elements up/down will invalidate many of these Param values. And it'll ruin the whole idea by using a virtual treeview. Item imagesSet the iImage and iSelectedImage fields in the TVITEM structure to the value $I_IMAGECALLBACK to use item images in a virtual treeview. And then set the index in the image list of the item image when responding to TVN_GETDISPINFO notifications. Here, the item image index in the image list is indicated in the second column (Item Images.txt) 0|0|0 0|0|1 0|0|2 1|0|3 1|0|This|Line 2 1|0|is 2|1|6 2|1|a 2|1|very 2|1|nice|Line 2|Line 3 3|1|10 3|2|TreeView 0|2|, (comma) 1|2|13 1|2|indeed. 0|2|15 The same item image is used for both selected and unselected treeview items. Code to create image list: ; Create small image ImageList Local $hImageList = _GUIImageList_Create( 16, 16, 5, 1 ) ; Add small images to ImageList _GUIImageList_Add( $hImageList, _WinAPI_CreateSolidBitmap( $hGui, 0xFF0000, 16, 16 ) ) ; Index 0, Red _GUIImageList_Add( $hImageList, _WinAPI_CreateSolidBitmap( $hGui, 0xFF00FF, 16, 16 ) ) ; Index 1, Magenta _GUIImageList_Add( $hImageList, _WinAPI_CreateSolidBitmap( $hGui, 0x0000FF, 16, 16 ) ) ; Index 2, Blue ; Add ImageList to TreeView _GUICtrlTreeView_SetNormalImageList( $hTreeView, $hImageList ) Set Image and SelectedImage fields in the TVITEM structure: DllStructSetData( $tInsert, "Image", -1 ) ; $I_IMAGECALLBACK DllStructSetData( $tInsert, "SelectedImage", -1 ) ; $I_IMAGECALLBACK Respond to TVN_GETDISPINFO notifications: Case $TVN_GETDISPINFOW ; Display TreeView item text and image Local Static $tBuffer = DllStructCreate( "wchar Text[50]" ), $pBuffer = DllStructGetPtr( $tBuffer ) Local $tDispInfo = DllStructCreate( $tagNMTVDISPINFO, $lParam ), $aItem = StringSplit( $aItems[DllStructGetData($tDispInfo,"Param")], "|", 2 ) DllStructSetData( $tBuffer, "Text", $aItem[2] ) DllStructSetData( $tDispInfo, "Text", $pBuffer ) DllStructSetData( $tDispInfo, "TextMax", 2 * StringLen( $aItem[2] ) + 2 ) DllStructSetData( $tDispInfo, "Image", $aItem[1] ) DllStructSetData( $tDispInfo, "SelectedImage", $aItem[1] ) Multi-line itemsFor multi-line items, the rectangle containing all text lines should be shifted to the right to make room for the item image. Ie. the $iLeft value of the rectangle should be increased by the width of the image plus a few pixels: ; $iLeft without item image $iLeft = $iTVIndent * ( $aItem[0] + 1 ) + 3 ; $iLeft with item image $iLeft = $iTVIndent * ( $aItem[0] + 1 ) + 16 + 3 + 3 New 7z-file at bottom of first post.2 points
-
[Solved] The Difference between Several AutoComplete MenuItems in Scite Lite
Zohar and one other reacted to pixelsearch for a topic
Hi Zohar, I'm also using Scite-Lite and some google search about these 4 items explains the behavior of each one (all search links at the end of this post) 1) Complete Symbol (Ctrl+I) The "Complete Symbol" command looks at the characters before the caret and displays the subset of the API file starting with that string. 2) Complete Word (Ctrl+Enter) SciTE command "Complete Word" searches document for any words starting with characters before caret. 3) Expand Abbreviation (Ctrl+B) You need 1st to create a couple of abbreviations in the abbreviations file (menu Options => Open Abbreviations file) and Save the abbreviation file when you are done Later, when you type hi in your script, then Ctrl+B, your "hi" will expand to "hi, this is a long sentence" Typing bye, then Ctrl+B would expand to "bye for now" 4) Insert Abbreviation (Ctrl+Shift+R) Links used for this post : https://www.scintilla.org/SciTEDoc.html https://www.scintilla.org/ScintillaHistory.html (takes a long time to appear) https://www.autoitscript.com/autoit3/scite/docs/SciTE4AutoIt3/SciTE4AutoIt3-AbbreviationHowTo.html https://www.autoitscript.com/autoit3/scite/docs/SciTE4AutoIt3/abbrev-manager.html2 points -
How to avoid window activation ?
argumentum and one other reacted to mLipok for a topic
Here are results of my work:2 points -
Set author in excel
FrancescoDiMuro reacted to TheXman for a topic
@robertocm https://docs.microsoft.com/en-us/office/vba/api/excel.workbook#properties For some reason, Microsoft doesn't list the Workbook.Author property, but it does use it in an example on the same page. That's odd. In any case, thanks for the example.1 point -
[Solved] AutoIt Window Info tool -> "Highlight Controls" MenuItem
pixelsearch reacted to Zohar for a topic
Hmm Freeze=Off + Highlight Controls=On (and to make Freeze=Off express itself, we have to move the Focus away from the Window Info tool to any other window, by clicking some other window, or else Freeze=Off will not be expressed) Thanks.. BTW to make this easier for others, consider naming the MenuItem as "Highlight Controls even when Freeze=Off" or something with this meaning)1 point -
Problems after upgrading to Windows 10
TheXman reacted to Earthshine for a topic
you need to add debugging code to your app to find out where and why it fails. make sure you are error checking everywhere and logging it with your debug statements. Share your code if you would like others to help1 point -
Is GUICtrlDelete() recommended for zapping listview items?
CYCho reacted to pixelsearch for a topic
Hi CYCho A year ago, I added a comment concerning your question, in this post ("2 - Now let's talk about deleting all items in listview") Hope it will help.1 point -
Just have a look at the commandline being ran by SciTE in the Output pane and you would have known.1 point
-
I've tested in a machine without foxit or acrobat and it does not show the PDF file. It show as a download progress file and then request to open with a default pdf viewer in my case SumatraPDF. Of course it will not work because there is not any object registered/associated to .pdf like acrobat and foxit do. Saludos1 point
-
How to avoid window activation ?
argumentum reacted to mLipok for a topic
In conclusion, after this post below I started working on improving this UDF Hence so many new questions.1 point -
1 point
-
ISN AutoIt Studio
musicstashall reacted to ISI360 for a topic
Hi folks! Itยดs update time again! ISN AutoIt Studio version 1.12 is now online! Like everywhere else, the Corona crisis has made my past ISN development quite a mess. But now I have finally put together a final version. The special highlight of this version is the final replacement of AutoIt *.exe files in the ISN package. Everything is now changed to *.a3x files (except the AutoIt_Studio.exe...which is now "only" a launcher for the actual *.a3x and is NOT created with AutoIt anymore (PureBasic). So the "virus scanner and false positive" topic should be now finally solved! (hopefully) Have fun with it, and as always: Feedback is welcome! ๐ Here the detailed changelog (translated by google): -> ISN AutoIt Studio: <- ----------------------------------- [Bug fixes] - Various bug fixes - Fixed a bug that caused the ISN to crash without warning or error message. - Fixed graphic bugs (gray area) in the script tree. - The logos of the plugins were often displayed in the wrong size in the program settings. This is now fixed. - Error when renaming shortcuts (* .lnk) files in the project tree has been fixed. - Resize bug with undocked plugins fixed. - Resize bug with Aero Snap fixed. - Folders that have already been opened / expanded in the project tree are no longer closed sporadically as soon as the view is updated. - Fixed a bug where the project tree stopped registering entries with the mouse after several hours. - Fixed flickering of the menu bar when opening a new file. [Improvements] - Due to the persistent virus reports (false positives) from various AV scanners, the following changes are introduced in this version: The most important components of the ISN AutoIt Studio are no longer delivered as * .exe, but as * .a3x. The ISN AutoIt Studio now contains a separate copy of "AutoIt3.exe" in the "\ Data" folder, which is used to start the ISN Studio itself and various program components. There will still be an "Autoit_Studio.exe" in the program directory, but this is NO longer written in AutoIt, but with PureBasic. (False positives shouldn't be an issue here) The new "Autoit_Studio.exe" only serves as a "launcher" for Autoit_Studio.a3x and AutoIt3.exe. With all of these changes, I hope that the false positive issue will be dealt with for a long time to come. - Import & export of macros has been improved. It is now possible to export individual macros. - Reduced "flickering" when changing the window size of the ISN AutoIt Studios main window. - The "Macros" window has been revised. - Files & folders with a dot "." are now hidden from the project tree. (Known from the Linux world) - When renaming files in the project tree, only the file name (without extension) is now selected. Prevents accidental removal of the file extension. - Improved performance with large scripts. - The window for ISN variables has been revised. Variables from the selection can now be inserted in any input control via drag and drop. - The root folder of the currently open project is now symbolized in the project tree with a "Home" icon. (Known from the first ISN versions) - The function "Jump to function (CTRL + J)" now searches not only the currently opened script, but all files that were added as an include by the main file. [New Features] - Added Polish translation (thx to MasterKnack) - There are two new entries in the context menu of the project tree: "Open new CMD / PowerShell window here" - There is now a new button in the "Create new macro" window with which the macro can be tested (executed) directly. - The number of macro slots has been increased from 7 to 10. (Info: The 3 new slots must be added manually to the toolbar in the program settings!) - Global macros: In addition to the previous project-related macros, there are now cross-project (global) macros that apply to all ISN AutoIt Studio projects. These global projects are saved directly in the config.ini of the ISN AutoIt Studio. Global macros are always executed first in the sequence, then the project-related ones. - The limitation of "One macro per macro slot" has been removed. Several macros can now be assigned to one macro slot. These are then carried out in sequence. - In the project tree there is now a "Favorites" area at the top. Each file in the project tree can now be marked "as a favorite" in the context menu and can then be found as a link in this new area. The favorites area behaves like a normal folder. You can also create subfolders etc. in it. The favorites are created in a subfolder of the project with the name ".Favorites". If you wish, this favorite area can be deactivated again in the program settings. - Two new ISN variables added: %ProjecttreeSelectedFile_Name% & %ProjecttreeSelectedFile_Path%. These contain the file name or the file path of the file currently selected in the project tree. (Perfect for macros in the context menu of the project tree!) -> ISN Form Studio 2: <- ----------------------------------- [Bug fixes] - Various bug fixes - Fixed a bug with disappearing "Rich Edit" controls in the GUI. - Made some performance improvements. -> ISN Command Line Tool: <- ----------------------------------- Note: The "ISN AutoIt Studio Command Line Tool" is available for download separately on my homepage from ISN AutoIt Studio Version 1.12! (So it is no longer included in the ISN installation!) The reason for this is that this tool unfortunately has to remain an .exe file (i.e. it cannot be converted into a * .a3x file). The .exe would again increase the risk of a "false positive" alarm from various AV scanners and has therefore been removed from the ISN package. [New Features] - New parameters for the ISN Command Line Tool have been added. More on this in the help. - The command line tool can now output the STDOUT stream of the ISN when compiling or testing a project. - The Command Line Tool now waits for certain commands until they are finished. (e.g. open project)1 point -
Calling files to do functions inside an array
TheXman reacted to FrancescoDiMuro for a topic
@don00 The function _Excel_SheetAdd() is probably failing to add those sheets. Put some error checking and see what's going on in your script. Nice to see that you listened to the suggestion "Leave _Excel_Open() outside the loop".1 point -
Multi-line treeview itemsMulti-line treeview items are supported through the iIntegral field in the TVITEM structure and custom draw code. The iIntegral value handles multi-line items in the treeview structure. Custom draw code draws the entire item rectangle, the dotted focus rectangle and the individual multi-line texts. Multi-line treeview items are supported by all treeviews and not just semi-virtual or virtual treeviews. To add a multi-line item with 2, 3 or 4 lines, simply set the value of iIntegral to 2, 3 or 4. Both the width and height of a rectangle that can accommodate all the lines must be calculated in the custom draw code. The height is just 2, 3 or 4 times the height of a single-line item. The width must be set to the width of the widest text string in pixels of the 2, 3, or 4 substrings. The width of a text string in pixels is calculated using the GetTextExtentPoint32W() function. The left position of the rectangle is calculated with _GUICtrlTreeView_GetIndent() and the item level. You'll also need to consider that the width of the entire treeview control may not be large enough to accommodate the longest text strings. Data source for multi-line items (Multiline.txt) 0|0 0|1 0|2 1|3 1|This|Line 2 1|is 2|6 2|a 2|very 2|nice|Line 2|Line 3 3|10 3|TreeView 0|, (comma) 1|13 1|indeed. 0|15 Code in a semi-virtual treeview to create and draw multi-line items (1) Multiline Items.au3) ; Create TreeView structure Func CreateTreeView( $aItems ) ; TreeView item information Local $aItem, $iItem ; TreeView level information Local $aLevels[100][2], $iLevel = 0, $iLevelPrev = 0 ; $aLevels[$iLevel][0]/[1] contains the last item/parent of that level ; TreeView insert structure Local $tInsert = DllStructCreate( $tagTVINSERTSTRUCT ), $pInsert = DllStructGetPtr( $tInsert ) DllStructSetData( $tInsert, "InsertAfter", $TVI_LAST ) DllStructSetData( $tInsert, "Mask", $TVIF_HANDLE+$TVIF_PARAM+$TVIF_TEXT+$TVIF_INTEGRAL ) DllStructSetData( $tInsert, "Text", -1 ) ; $LPSTR_TEXTCALLBACK ; Add TreeView root $aItem = StringSplit( $aItems[0], "|", 2 ) $iItem = UBound( $aItem ) $aLevels[$iLevel][1] = NULL DllStructSetData( $tInsert, "Param", 0 ) DllStructSetData( $tInsert, "Parent", $aLevels[$iLevel][1] ) DllStructSetData( $tInsert, "Integral", $iItem > 2 ? $iItem - 1 : 1 ) $aLevels[$iLevel][0] = GUICtrlSendMsg( $idTreeView, $TVM_INSERTITEMW, 0, $pInsert ) ; Add TreeView items For $i = 1 To UBound( $aItems ) - 1 $aItem = StringSplit( $aItems[$i], "|", 2 ) $iItem = UBound( $aItem ) $iLevel = $aItem[0] If $iLevel <> $iLevelPrev Then $aLevels[$iLevel][1] = $iLevel > $iLevelPrev ? $aLevels[$iLevelPrev][0] _ ; A child of the previous level : GUICtrlSendMsg( $idTreeView, $TVM_GETNEXTITEM, $TVGN_PARENT, $aLevels[$iLevel][0] ) ; A sibling of the level $iLevelPrev = $iLevel EndIf DllStructSetData( $tInsert, "Param", $i ) DllStructSetData( $tInsert, "Parent", $aLevels[$iLevel][1] ) DllStructSetData( $tInsert, "Integral", $iItem > 2 ? $iItem - 1 : 1 ) $aLevels[$iLevel][0] = GUICtrlSendMsg( $idTreeView, $TVM_INSERTITEMW, 0, $pInsert ) Next ; $aLevels[$iLevel][0]/[1] contains the last item/parent of that level EndFunc Func WM_NOTIFY( $hWnd, $iMsg, $wParam, $lParam ) Local $tNMHDR = DllStructCreate( $tagNMHDR, $lParam ) Switch HWnd( DllStructGetData( $tNMHDR, "hWndFrom" ) ) Case $hTreeView Switch DllStructGetData( $tNMHDR, "Code" ) Case $TVN_GETDISPINFOW ; Display TreeView item text Local Static $tBuffer = DllStructCreate( "wchar Text[50]" ), $pBuffer = DllStructGetPtr( $tBuffer ) Local $tDispInfo = DllStructCreate( $tagNMTVDISPINFO, $lParam ), $sText = StringSplit( $aItems[DllStructGetData($tDispInfo,"Param")], "|", 2 )[1] DllStructSetData( $tBuffer, "Text", $sText ) DllStructSetData( $tDispInfo, "Text", $pBuffer ) DllStructSetData( $tDispInfo, "TextMax", 2 * StringLen( $sText ) + 2 ) Case $NM_CUSTOMDRAW Local $tCustomDraw = DllStructCreate( $tagNMTVCUSTOMDRAW, $lParam ) Switch DllStructGetData( $tCustomDraw, "DrawStage" ) ; The current drawing stage Case $CDDS_PREPAINT ; Before the paint cycle begins Return $CDRF_NOTIFYITEMDRAW ; Notify the parent before painting an item Case $CDDS_ITEMPREPAINT ; Before painting an item If UBound( StringSplit( $aItems[DllStructGetData($tCustomDraw,"ItemParam")], "|", 2 ) ) > 2 Then _ Return $CDRF_NOTIFYPOSTPAINT ; Notify the parent after painting an item ; Draw multiline item texts Case $CDDS_ITEMPOSTPAINT ; After painting an item Local Static $iTVIndent = _GUICtrlTreeView_GetIndent( $hTreeView ), $tSize = DllStructCreate( $tagSIZE ), $hBrushHighLight = _WinAPI_GetSysColorBrush( $COLOR_HIGHLIGHT ), $hBrushButtonFace = _WinAPI_GetSysColorBrush( $COLOR_BTNFACE ), $hBrushWhite = _WinAPI_CreateSolidBrush( 0xFFFFFF ) Local $hDC = DllStructGetData( $tCustomDraw, "HDC" ), $tRect = DllStructCreate( $tagRECT, DllStructGetPtr( $tCustomDraw, "Left" ) ), $aItem = StringSplit( $aItems[DllStructGetData($tCustomDraw,"ItemParam")], "|", 2 ), $iItem = UBound( $aItem ), $iMaxTextLen = 0, $iLeft = $iTVIndent * ( $aItem[0] + 1 ) + 3, $iRectWidth = DllStructGetData( $tCustomDraw, "Right" ) - $iLeft, $iTop = DllStructGetData( $tRect, "Top" ), $iItemState = DllStructGetData( $tCustomDraw, "ItemState" ) ; Longest text in pixels of all item texts For $i = 1 To $iItem - 1 DllCall( "gdi32.dll", "bool", "GetTextExtentPoint32W", "handle", $hDC, "wstr", $aItem[$i], "int", StringLen( $aItem[$i] ), "struct*", $tSize ) ; _WinAPI_GetTextExtentPoint32 If DllStructGetData( $tSize, "X" ) + 1 > $iMaxTextLen Then $iMaxTextLen = DllStructGetData( $tSize, "X" ) + 1 Next ; Rectangle that includes all item texts If $iMaxTextLen + 4 > $iRectWidth Then _ $iMaxTextLen = $iRectWidth - 4 DllStructSetData( $tRect, "Left", $iLeft ) DllStructSetData( $tRect, "Right", $iLeft + $iMaxTextLen + 4 ) DllStructSetData( $tRect, "Bottom", $iTop + 18 * ( $iItem - 1 ) ) DllCall( "gdi32.dll", "int", "SetBkMode", "handle", $hDC, "int", $TRANSPARENT ) ; _WinAPI_SetBkMode() Switch BitAND( $iItemState, $CDIS_SELECTED + $CDIS_FOCUS ) Case $CDIS_SELECTED + $CDIS_FOCUS DllCall( "user32.dll", "int", "FillRect", "handle", $hDC, "struct*", $tRect, "handle", $hBrushHighLight ) ; _WinAPI_FillRect() DllCall( "user32.dll", "bool", "DrawFocusRect", "handle", $hDC, "struct*", $tRect ) ; _WinAPI_DrawFocusRect() DllCall( "gdi32.dll", "INT", "SetTextColor", "handle", $hDC, "INT", 0xFFFFFF ) ; _WinAPI_SetTextColor() Case $CDIS_SELECTED DllCall( "user32.dll", "int", "FillRect", "handle", $hDC, "struct*", $tRect, "handle", $hBrushButtonFace ) ; _WinAPI_FillRect() Case $CDIS_FOCUS Case Else DllCall( "user32.dll", "int", "FillRect", "handle", $hDC, "struct*", $tRect, "handle", $hBrushWhite ) ; _WinAPI_FillRect() EndSwitch ; Left start position for item texts DllStructSetData( $tRect, "Left", $iLeft + 2 ) ; Draw all item texts For $i = 1 To UBound( $aItem ) - 1 DllStructSetData( $tRect, "Top", $iTop + 18 * ( $i - 1 ) + 1 ) DllCall( "user32.dll", "int", "DrawTextW", "handle", $hDC, "wstr", $aItem[$i], "int", -1, "struct*", $tRect, "uint", $DT_LEFT+$DT_WORD_ELLIPSIS ) ; _WinAPI_DrawText() Next EndSwitch EndSwitch EndSwitch #forceref $hWnd, $iMsg, $wParam EndFunc Store MaxTextLen in data sourceBecause the width of the longest text string in pixels ($iMaxTextLen) must be calculated each time a multi-line item needs to be redrawn, it can be an advantage to store this width directly in the data source. Multiline-2.txt: 0|000|0 0|000|1 0|000|2 1|000|3 1|000|This|Line 2 1|000|is 2|000|6 2|000|a|A somewhat long new line 2|000|very 2|000|nice|A TreeView item with three lines|Line 3 3|000|10 3|000|TreeView 0|000|, (comma) 1|000|13 1|000|indeed. 0|000|15 2) Store MaxTextLen.au3: ; Cleanup GUIDelete( $hGui ) If $bSaveItems Then _FileWriteFromArray( "Multiline-2.txt", $aItems ) $aItem = StringSplit( $aItems[DllStructGetData($tCustomDraw,"ItemParam")], "|", 2 ) $iMaxTextLen = $aItem[1]+0 ; Longest text in pixels of all item texts If Not $iMaxTextLen Then For $i = 2 To $iItem - 1 DllCall( "gdi32.dll", "bool", "GetTextExtentPoint32W", "handle", $hDC, "wstr", $aItem[$i], "int", StringLen( $aItem[$i] ), "struct*", $tSize ) ; _WinAPI_GetTextExtentPoint32 If DllStructGetData( $tSize, "X" ) + 1 > $iMaxTextLen Then $iMaxTextLen = DllStructGetData( $tSize, "X" ) + 1 Next $bSaveItems = True $iIndex = DllStructGetData( $tCustomDraw, "ItemParam" ) $aItems[$iIndex] = StringReplace( $aItems[$iIndex], 3, StringFormat( "%03i", $iMaxTextLen ) ) EndIf Too narrow treeview control3) Store MaxTextLen.au3 is similar to the example above except that the treeview control is too narrow for the longest text strings. New 7z-file at bottom of first post. The first set of examples in 1) Virtual TreeView\ has all been updated with some very minor changes.1 point
-
Variable must be of type object
mLipok reacted to albertmaathuis for a topic
Thanks, done that, and it tells me on the 2e line (objcreate) : Class not registered. (After that of course the other errors variable must be of type object) Strange because the VBS works fine, so the registration has been succesfull.....1 point -
WM_Notify with Multiple ListViews
hudsonhock reacted to LurchMan for a topic
Never mind...its been a long day and I figured it out. Solution: #include <GUIConstantsEx.au3> #include <ListViewConstants.au3> #include <WindowsConstants.au3> #Include <GuiListView.au3> Opt("GUIOnEventMode", 1) $Form1 = GUICreate("Purple Sheets", 376, 550, -1,-1) GUISetOnEvent($GUI_EVENT_CLOSE, "_Exit") $ListViewExp = GUICtrlCreateListView("", 8, 16, 106, 382, $LVS_SHOWSELALWAYS) $ListViewLind = GUICtrlCreateListView("", 130, 16, 106, 382, $LVS_SHOWSELALWAYS) $ListViewScott = GUICtrlCreateListView("", 256, 16, 106, 382, $LVS_SHOWSELALWAYS) _GUICtrlListView_AddColumn($ListViewExp, "Expected", 85) _GUICtrlListView_AddColumn($ListViewLind, "Lindsey", 85) _GUICtrlListView_AddColumn($ListViewScott, "Scott", 85) _GUICtrlListView_AddItem($ListViewExp, "testing1", 0) _GUICtrlListView_AddItem($ListViewLind, "testing2", 0) _GUICtrlListView_AddItem($ListViewScott, "testing3", 0) GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY") ;~ Global $B_DESCENDING[_GUICtrlListView_GetColumnCount($ListViewExp)] GUISetState(@SW_SHOW) While 1 Sleep (100) Wend Func WM_NOTIFY($hWnd, $iMsg, $iwParam, $ilParam) #forceref $hWnd, $iMsg, $iwParam Local $hWndFrom, $iIDFrom, $iCode, $tNMHDR, $hWndListView, $tInfo $hWndListView1 = GUICtrlGetHandle($ListViewExp) $hWndListView2 = GUICtrlGetHandle($ListViewLind) $hWndListView3 = GUICtrlGetHandle($ListViewScott) ;~ If Not IsHWnd($ListViewExp) Then $hWndListView = GUICtrlGetHandle($ListViewExp) $tNMHDR = DllStructCreate($tagNMHDR, $ilParam) $hWndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom")) $iIDFrom = DllStructGetData($tNMHDR, "IDFrom") $iCode = DllStructGetData($tNMHDR, "Code") Switch $hWndFrom Case $hWndListView1 Switch $iCode Case $NM_DBLCLK ; Sent by a list-view control when the user double-clicks an item with the left mouse button $tInfo = DllStructCreate($tagNMITEMACTIVATE, $ilParam) $text = _GUICtrlListView_GetItemText ($ListViewExp, DllStructGetData($tInfo, "Index")) MsgBox (0, "you clicked on", $text) EndSwitch Case $hWndListView2 Switch $iCode Case $NM_DBLCLK ; Sent by a list-view control when the user double-clicks an item with the left mouse button $tInfo = DllStructCreate($tagNMITEMACTIVATE, $ilParam) $text = _GUICtrlListView_GetItemText ($ListViewLind, DllStructGetData($tInfo, "Index")) MsgBox (0, "you clicked on", $text) EndSwitch Case $hWndListView3 Switch $iCode Case $NM_DBLCLK ; Sent by a list-view control when the user double-clicks an item with the left mouse button $tInfo = DllStructCreate($tagNMITEMACTIVATE, $ilParam) $text = _GUICtrlListView_GetItemText ($ListViewScott, DllStructGetData($tInfo, "Index")) MsgBox (0, "you clicked on", $text) EndSwitch EndSwitch Return $GUI_RUNDEFMSG EndFunc ;==>WM_NOTIFY Func _Exit () Exit EndFunc1 point -
Select and unselect an item of listview WITH $LVS_NOCOLUMNHEADER ? [SOLVED]
hudsonhock reacted to rasim for a topic
Jikoo Use a $LVS_SHOWSELALWAYS style: #include <GuiListView.au3> #include <GuiImageList.au3> $gui = GUICreate('Test ListView select-unselect', 300, 200) $glList = GUICtrlCreateListView('Column ', 0, 0, 300, 160, BitOR($LVS_SHOWSELALWAYS, $LVS_NOCOLUMNHEADER)) $b1 = GUICtrlCreateButton('Select', 20, 170) $b2 = GUICtrlCreateButton('Unselect', 70, 170) $hImage = _GUIImageList_Create(16, 16, 5, 3) _GUIImageList_AddIcon($hImage, "shell32.dll", 3) _GUIImageList_AddIcon($hImage, "shell32.dll", 1) _GUIImageList_AddIcon($hImage, "shell32.dll", 11) _GUICtrlListView_SetImageList($glList, $hImage, 1) _GUICtrlListView_AddItem($glList, "Item0", 0) _GUICtrlListView_AddItem($glList, "Item1", 1) _GUICtrlListView_AddItem($glList, "Item2", 2) GUISetState() While 1 Sleep(10) Switch GUIGetMsg() Case - 3 Exit Case $b1 _GUICtrlListView_SetItemSelected($glList, 1, True, True) Case $b2 _GUICtrlListView_SetItemSelected($glList, 1, False) EndSwitch WEnd1 point