pixelsearch Posted June 12, 2021 Share Posted June 12, 2021 (edited) @powerofos sorry to hear that, I can't reproduce it. Maybe an additional ghost column 0 (with 0 width) would be a more stable attempt, it would allow to drag all other visible headers and get rid of column 0 isssue, maybe... Edit 1: you're right, I just saw your pic in last post. It happens when we use the mouse directly in LV (strange it didn't happen in precedent versions). As I used only the scrollbars to move up and down (or the F3 key to search match) then it didn't happen to me. If a solution is not found then I'll delete this last version "2t". I felt that this "header dragging" function would bring problems not found in precedent versions ! Edit 2: what's interesting is that this issue happens in "2t" even when we don't drag any header (just tested). So I'll try to modify again the precedent version "2s" (which is working fine) hoping to catch the script line that creates this issue. Edit 3 : it's line #347 in version "2t" that creates the issue, but how not to use it as it's related to subitem 0 ? GUICtrlSendMsg( $g_idListView, $LVM_GETITEMRECT, $itemID, $pRect ) Especially that when we use the mouse wheel slowly in the listview (not using scrollbars), then all rows seem to be displayed correctly. Let's hope LarsJ will have an idea about this. I really wonder if an additional empty column 0 would solve this issue and allow us to use fluently the draggable header feature with virtual listview + over drawn. This was my 1st thought and I'll try it asap : a ghost column 0, non draggable, having 0 width. Until then, for users who read this, last stable version is "2s" in precedent page, not "2t" Jon just released AutoIt v3.3.15.4 Beta, that's very interesting Edited June 12, 2021 by pixelsearch Link to comment Share on other sites More sharing options...
LarsJ Posted June 12, 2021 Author Share Posted June 12, 2021 This error situation typically occurs in a message handler in a custom drawn, owner drawn or virtual listview, where more code is executed than there is time for. This is probably not an actual error in the code. The error is due to the fact that AutoIt as an interpreted language isn't fast enough to handle so many messages and so much code at once. You can analyze the problem with Windows Message Monitor. Compare e.g. the message flow when scrolling with the scroll bar and when scrolling with the mouse scroll button. It may be possible to limit the number of messages when scrolling with the mouse scroll button and thus get around the problem. pixelsearch and Norm73 2 Controls, File Explorer, ROT objects, UI Automation, Windows Message MonitorCompiled code: Accessing AutoIt variables, DotNet.au3 UDF, Using C# and VB codeShell menus: The Context menu, The Favorites menu. Shell related: Control Panel, System Image ListsGraphics related: Rubik's Cube, OpenGL without external libraries, Navigating in an image, Non-rectangular selectionsListView controls: Colors and fonts, Multi-line header, Multi-line items, Checkboxes and icons, Incremental searchListView controls: Virtual ListViews, Editing cells, Data display functions Link to comment Share on other sites More sharing options...
pixelsearch Posted June 13, 2021 Share Posted June 13, 2021 (edited) @LarsJ thanks for your good advices, as always @powerofos @Norm73 I just replaced 3 lines (346 to 348) in the last script "2t" found at the precedent page. 3 deleted lines : DllStructSetData( $tRect, 1, $LVIR_LABEL ) ; Left GUICtrlSendMsg( $g_idListView, $LVM_GETITEMRECT, $itemID, $pRect ) ; DllStructSetData( $tRect, 3, DllStructGetData( $tRect, 1 ) + GUICtrlSendMsg( $g_idListView, $LVM_GETCOLUMNWIDTH, 0, 0 ) ) Replaced with : Local $aRect = _GUICtrlHeader_GetItemRect($g_hHeader, 0) DllStructSetData( $tRect, 1, $aRect[0]) ; left DllStructSetData( $tRect, 3, $aRect[2]) ; right Now I can scroll using the mouse without any issue. Could you please try it, drag headers etc... then report if everything worked for you ? Thanks and fingers crossed. Edited June 13, 2021 by pixelsearch Link to comment Share on other sites More sharing options...
powerofos Posted June 13, 2021 Share Posted June 13, 2021 (edited) @ pixelsearch thank you! Function: _GUICtrlHeader_GetItemRect($g_hHeader, 0) The return value of getitemrect is static. It cannot dynamically update the position data of column 0 with the operation of the horizontal scroll bar of the listview So in the last report, I mentioned that I need to get the left column ID of 0 column , and use the position of the left column ID to dynamically update, so as to deal with the problem of self drawing and redrawing caused by horizontal scrolling I'm sorry that this issue was not mentioned in the last report Have a nice weekend! Edited June 13, 2021 by powerofos Link to comment Share on other sites More sharing options...
powerofos Posted June 13, 2021 Share Posted June 13, 2021 All the problems I mentioned are caused by the fact that the position X of column 0 cannot be dynamically obtained (horizontal scrolling) through the function after it is changed😖 Link to comment Share on other sites More sharing options...
pixelsearch Posted June 13, 2021 Share Posted June 13, 2021 35 minutes ago, powerofos said: ...the problem of self drawing and redrawing caused by horizontal scrolling I'm sorry that this issue was not mentioned in the last report No problem. So you have a horizontal scroll issue... At least the 3 replaced lines in "2t" fixed the vertical scroll issue, when there is no horizontal scrollbar, that's a good thing already done. Link to comment Share on other sites More sharing options...
pixelsearch Posted June 13, 2021 Share Posted June 13, 2021 (edited) @powerofos glad I didn't delete a few hours ago a text file named "keep a moment, who knows.txt", its content will be displayed below. I'm sticking to the idea of creating a ghost hidden column 0, maybe it could solve your issue of horizontal scrolling and headers dragging, it will leave column 0 hidden and untouched. This is just the basic (unfinished) changes you could try in version "2s" (not "2t") found in preceding page, to see where it goes. I tried it, now there is a horizontal scrollbar in the pic below ("strings" column width changed from 230 to 330) and its redraw looks fine when you drag and redrag it (as it's no more column 0) expandcollapse popupBasic changes in "2s" (or in a copy of "2s" to keep original untouched) =========== Lines 12-14 old Global $g_iRows = 1000, $g_iCols = 6, $g_hGui, $g_hListView, $g_hHeader, $g_hEdit Global $g_aCols = ["Strings", "Integers", "Floats", "Dates", "Times", "R/C"], $g_aWidths = [230, 61, 124, 70, 60, 60] Global $g_aColAligns[$g_iCols] = [2, 1, 1, 1, 1, 1] ; $HDF_LEFT = 0, $HDF_RIGHT = 1, $HDF_CENTER = 2 new Global $g_iRows = 1000, $g_iCols = 1 + 6, $g_hGui, $g_hListView, $g_hHeader, $g_hEdit Global $g_aCols = ["", "Strings", "Integers", "Floats", "Dates", "Times", "R/C"], $g_aWidths = [0, 330, 61, 124, 70, 60, 60] Global $g_aColAligns[$g_iCols] = [0, 2, 1, 1, 1, 1, 1] ; $HDF_LEFT = 0, $HDF_RIGHT = 1, $HDF_CENTER = 2 =========== Lines 58-61 old $g_idComboCol = GUICtrlCreateCombo("0", 452, 9, 41, 20, BitOR($GUI_SS_DEFAULT_COMBO, $CBS_DROPDOWNLIST)) $g_iSearchCol = 0 ; default column where to search (changeable) Local $iSearchColPrev = $g_iSearchCol For $i = 1 To $g_iCols - 1 new $g_idComboCol = GUICtrlCreateCombo("1", 452, 9, 41, 20, BitOR($GUI_SS_DEFAULT_COMBO, $CBS_DROPDOWNLIST)) $g_iSearchCol = 1 ; default column where to search (changeable) Local $iSearchColPrev = $g_iSearchCol For $i = 2 To $g_iCols - 1 =========== Line 71 old _GUICtrlListView_SetExtendedListViewStyle($g_idListView, BitOr($LVS_EX_DOUBLEBUFFER, $LVS_EX_FULLROWSELECT)) new _GUICtrlListView_SetExtendedListViewStyle($g_idListView, BitOr($LVS_EX_DOUBLEBUFFER, $LVS_EX_FULLROWSELECT, $LVS_EX_HEADERDRAGDROP)) =========== Line 444 old $g_aArray = FAS_Random2DArrayAu3($g_iRows, "sifdtr", "abcdefghijklmnopqrstuvwxyz") new $g_aArray = FAS_Random2DArrayAu3($g_iRows, "isifdtr", "abcdefghijklmnopqrstuvwxyz") Unfortunately, the search function needs now to be amended, but well, that's a start and better than nothing. I'm not sure I'll keep on digging into this as it's starting to be complicated, we'll see. Hope it will help you and good luck Edit: also please remember what LarsJ wrote about the issue of resizing columns in these LV ("No ListView column resizing by dragging header dividers") "A workaround for all these HDN_DIVIDERDBLCLICK issues is to set correct column widths from the start, and then disable column resize through dragging/double-clicking header dividers by adding the HDS_NOSIZING style to the header control." Edited June 13, 2021 by pixelsearch $HDS_NOSIZING note Norm73 1 Link to comment Share on other sites More sharing options...
Norm73 Posted June 13, 2021 Share Posted June 13, 2021 (edited) For me (2s with adjustment) all scroll options work fine. There are still two minor things to fix. P.S. If the width of the columns cannot be changed, and all of the text is not visible, then it makes sense to try to show it through the ToolTip when you hover over the SubItem or Heading. Edited June 13, 2021 by Norm73 pixelsearch 1 Link to comment Share on other sites More sharing options...
pixelsearch Posted June 13, 2021 Share Posted June 13, 2021 @Norm73 Glad to hear that "2s with adjustment" works for you. I was aware that the orange marker needs a little fix, but first I wanted to make sure that the basic adjustment works on your computer (it should work on powerofos's computer too) So the idea is to have an additional empty hidden column 0, so we get rid of all issues concerning column 0 if it stays constantly at the leftmost position, which means we also need to prevent any other header to be dragged at leftmost position ! In the test script below, I succeeded to prevent this. Imagine column 0 being hidden in this test script, then when you launch it, this is what happens : 1) You can't drag header 0 anywhere, great ! 2) If you try to drag any other header at the leftmost position (i.e. at the left of column 0) then it won't be accepted, which is what we want. All others dragging cases are accepted. Thanks to $tNMHEADER.pItem that I discovered recently on msdn #include <GuiListView.au3> #include <GuiConstantsEx.au3> #include <WindowsConstants.au3> $hGUI = GUICreate("ListView: prevent some dragging", 400, 300) $hListView = GUICtrlCreateListView("Column 0|Column 1|Column 2|Column 3", 2, 2, 394, 268) _GUICtrlListView_SetExtendedListViewStyle($hListView, BitOr($LVS_EX_FULLROWSELECT, $LVS_EX_HEADERDRAGDROP)) $g_hHeader = _GUICtrlListView_GetHeader($hListView) GUIRegisterMsg($WM_NOTIFY, "_WM_NOTIFY") GUISetState() Do Until GUIGetMsg() = $GUI_EVENT_CLOSE Func _WM_NOTIFY($hWnd, $iMsg, $wParam, $lParam) Local $tNMHEADER = DllStructCreate($tagNMHEADER, $lParam) Local $iCode = DllStructGetData($tNMHEADER, "Code") Switch $iCode Case $HDN_ENDDRAG ; "sent by a header control when a drag operation has ended on one of its items." Local $iCol = DllStructGetData($tNMHEADER, "Item") Local $tHDITEM = DllStructCreate($tagHDITEM, $tNMHEADER.pItem) ConsoleWrite("$iCol = " & $iCol & " $tHDITEM.Order = " & $tHDITEM.Order & @lf) ; if dragged header = column 0 (possible on hidden column ? [in another script]) OR ; if dragged header (> 0) is dropped at leftmost position (at the left of hidden column 0) ... ; ...then prevent header to be dragged (Return True) If $iCol = 0 Or $tHDITEM.Order = 0 Then Return True ; True prevents, False allows EndSwitch Return $GUI_RUNDEFMSG EndFunc ; see also "176a.au3" (for other very interesting use of $tNMHEADER.pItem) But no hurry, please do not add this Case $HDN_ENDDRAG to "2s with adjustment" right now as it needs $tNMHEADER etc... When a new version will be ready, I'll include the fixes we're talking about, though I won't touch at "2s" and "2t" in the precedent page : they work fine when there is no horizontal scrollbar. New versions will probably be "2u" etc... though the alphabet end will soon be reached Norm73 1 Link to comment Share on other sites More sharing options...
pixelsearch Posted June 13, 2021 Share Posted June 13, 2021 10 hours ago, Norm73 said: For me (2s with adjustment) all scroll options work fine. Unfortunately, for me it doesn't work fine and I have an issue, when some kind of searches are done, for example : * Tick "Show all rows" in context menu * Search what you want (for example an "a" in the String column) * Make sure the horizontal scrollbar is NOT at its leftmost position (drag it a bit on the right) * Then when you click "Next" button (or keyboard F3), the whole GUI will minimize... thanks to the horizontal scrollbar when it's not at its leftmost position. If you start again and do same with the horizontal scrollbar placed at its leftmost position, then everything works fine. And this has nothing to do with dragged headers or not. I already have a fix for this but it's really a strange issue. What's the fix ? Comment 3 lines in Case $idNext and same 3 lines in Case $idPrev ;~ _GUICtrlListView_ClickItem($g_idListView, $i) ;~ If $iStart = 0 Then ;~ EndIf (keep what's between If and EndIf of course) Now the match row appears always at the top of LV (whatever the position of the horizontal scrollbar) and the Gui doesn't minimize. I wonder if LarsJ already encountered an issue like that. Link to comment Share on other sites More sharing options...
Norm73 Posted June 13, 2021 Share Posted June 13, 2021 (edited) For @pixelsearch Drag and drop works as advertised. The described problem, with the disappearance of the window into the background, is also present for me. Edited June 14, 2021 by Norm73 Link to comment Share on other sites More sharing options...
Norm73 Posted June 14, 2021 Share Posted June 14, 2021 (edited) Hi @LarsJ, @pixelsearch I discovered another problem. I've made the second column extra narrower to show that. Can this be somehow removed? Edited June 14, 2021 by Norm73 Link to comment Share on other sites More sharing options...
pixelsearch Posted June 15, 2021 Share Posted June 15, 2021 10 hours ago, Norm73 said: Can this be somehow removed? Maybe by checking the rectangle coords for the matching substring, for example : ; Rectangle for matching substring ... ConsoleWrite($tRect.Left & " " & $tRect.Right & @lf) 135 142 As the blue rectangle goes from 135 to 142, which is outside the resized "Strings" column, then don't display the match, I'll try to think about it... when all the rest will be ok . By the way, the important orange marker is fixed now, no matter you drag a header or scroll horizontally. It will be added in next release. I found an incredible post of LarsJ concerning "AutoIt messages and Windows messages" in this link. He explains everything very well and his post should really be placed in AutoIt wiki pages (my bad if it's already there) Happy reading and re-reading it. Link to comment Share on other sites More sharing options...
pixelsearch Posted June 15, 2021 Share Posted June 15, 2021 On 6/13/2021 at 2:27 AM, powerofos said: _GUICtrlHeader_GetItemRect($g_hHeader, 0) The return value of getitemrect is static. It cannot dynamically update the position data of column 0 with the operation of the horizontal scroll bar of the listview... ...All the problems I mentioned are caused by the fact that the position X of column 0 cannot be dynamically obtained (horizontal scrolling) through the function after it is changed Though the return value is static while you scroll horizontally, I was able to obtain the new X position during the scrolling or after the scrolling (or after a header dragging), it allowed the orange marker to be placed just above any column after an horizontal scroll. The complete code isn't ready for a new release but meanwhile, here is the basis : 0 330 200 0 330 121 ... Global $g_idEndDragDummy ... $g_idEndDragDummy = GUICtrlCreateDummy() ... Case $g_idEndDragDummy ; in main loop _MoveMarker(GUICtrlRead($g_idComboCol)) ... Case $LVN_ENDSCROLL ; in Notify handler (listview part) _MoveMarker(GUICtrlRead($g_idComboCol)) ... Case $HDN_ENDDRAG ; in Notify handler (header part) GUICtrlSendToDummy($g_idEndDragDummy) Return False ; allow changes ... ;======================================================================== Func _MoveMarker($iCol) Local Static $tPoint = DllStructCreate("int X;int Y") Local $aLisViewPos = WinGetPos($g_hListView) ; left & top will change when user moves GUI Local $aRect = _GUICtrlHeader_GetItemRect($g_hHeader, $iCol) ; ConsoleWrite($aRect[0] & " " & $aRect[2] & @crlf) DllStructSetData($tPoint, "X", $aRect[0]) DllStructSetData($tPoint, "Y", $aRect[1]) ; unused _WinAPI_ClientToScreen($g_hHeader, $tPoint) ; ConsoleWrite($tPoint.X & " " & @crlf) ControlMove($g_hGui, "", $g_idMarker, $tPoint.X - $aLisViewPos[0] + 10, 40 - 3, $aRect[2] - $aRect[0] + 1, 3) ; 10 / 40 are LV coords EndFunc ;==>_MoveMarker LarsJ says that functions shouldn't be called from windows message handlers (his great link in previous post) so I should modify the code to reflect this. As you can see, though the rectangle is static (0 - 330, i.e. the width of our new String column) before and after the scroll in both pics, we also see "200" and "121" which corresponds to $tPoint.X in the 2nd ConsoleWrite of the function _MoveMarker() Thanks to the function _WinAPI_ClientToScreen() we can calculate $tPoint.X and it's not static anymore. For the orange marker, I also needed WinGetPos($g_hListView) in case the user moves the GUI, ending in the following X position for the orange marker after an horizontal scroll, or a dragged header, or a right click on a header (which switches to a new search column) have been performed : $tPoint.X - $aLisViewPos[0] + 10 ; 10 is a LV coord Concerning your issue, during the horizontal scrolling, you could dynamically track this X position through $LVN_ENDSCROLL message as shown in the precedent basic code : it will return plenty of new X coords, for example : $g_iRows = 1 $g_iCols = 7 Computed LV height = 69 pixels 0 330 200 0 330 199 0 330 198 0 330 192 ... 0 330 126 0 330 123 0 330 122 0 330 121 >Exit code: 0 By the way, In the 2 pics above, there is a hidden Col 0 (having 0 width) which explains why it's written "1" in the Combobox, because I don't want to use LVM_GETITEMRECT anymore for column 0, it created a mess while using the mouse for vertical scrolling (in version "2t"). The advantage of having a hidden Col 0 (not draggable) brings fresh air when you drag any other header to any place, starting at 1+ header, fingers crossed ! Hope this helps and see you on next release Lion66 and Norm73 2 Link to comment Share on other sites More sharing options...
pixelsearch Posted June 16, 2021 Share Posted June 16, 2021 (edited) On 6/13/2021 at 6:46 PM, Norm73 said: The described problem, with the disappearance of the window into the background, is also present for me. Gladly the code isn't responsible for that. As discussed today in this thread, spudw2k is encountering the same behavior in a very basic script I presented there. There's a problem with _GUICtrlListView_ClickItem() when an horizontal scrollbar is present. Now we have to find a solution for that. Edit: Trac Ticket #3827 created Edited June 16, 2021 by pixelsearch Norm73 1 Link to comment Share on other sites More sharing options...
pixelsearch Posted June 19, 2021 Share Posted June 19, 2021 (edited) Hi everybody, The attached script (version 2y) allows to drag and resize any column (even column 0) without having characters overlap other columns Well... this is the end of my "journey through incremental search" as all functionalities have been added. Thanks to all contributors and a special thanks to LarsJ Edit: June 22, 2021 * minor update (less code for computing col 0 coords, in Func WM_DRAWITEM, after an horizontal scrolling has been performed) * added functionality : do not draw actual non-visible column(s), this makes a big difference when LV got many columns : the scrolling stays smooth (tested) Edit: June 25, 2021 * Fixed issue with left-aligned columns in Func WM_DRAWITEM (thanks Norm73) Incremental Search (2y).au3 Edited June 25, 2021 by pixelsearch Issue fixed on June 25th, 2021 supersonic, Musashi and Norm73 1 2 Link to comment Share on other sites More sharing options...
supersonic Posted June 21, 2021 Share Posted June 21, 2021 @pixelsearch ... and all others involved: Thank you so much - I really appreciate your effort. I have very often wondered if or how to implement such functionality at all. All thumbs up! ☺️ pixelsearch 1 Link to comment Share on other sites More sharing options...
mLipok Posted June 21, 2021 Share Posted June 21, 2021 @LarsJ this thread is 5.5 years old and I notice that you never edit ZIP in your OP .... so I wonder do you have all changes/examples from this entire thread at one place ? Maybe you have done some fixes/improvments ? Could you merge them to single zip and attach in OP ? mLipok Signature beginning:* Please remember: "AutoIt"..... * Wondering who uses AutoIt and what it can be used for ? * Forum Rules ** ADO.au3 UDF * POP3.au3 UDF * XML.au3 UDF * IE on Windows 11 * How to ask ChatGPT for AutoIt Code * for other useful stuff click the following button: Spoiler Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind. My contribution (my own projects): * Debenu Quick PDF Library - UDF * Debenu PDF Viewer SDK - UDF * Acrobat Reader - ActiveX Viewer * UDF for PDFCreator v1.x.x * XZip - UDF * AppCompatFlags UDF * CrowdinAPI UDF * _WinMergeCompare2Files() * _JavaExceptionAdd() * _IsBeta() * Writing DPI Awareness App - workaround * _AutoIt_RequiredVersion() * Chilkatsoft.au3 UDF * TeamViewer.au3 UDF * JavaManagement UDF * VIES over SOAP * WinSCP UDF * GHAPI UDF - modest begining - comunication with GitHub REST API * ErrorLog.au3 UDF - A logging Library * Include Dependency Tree (Tool for analyzing script relations) * Show_Macro_Values.au3 * My contribution to others projects or UDF based on others projects: * _sql.au3 UDF * POP3.au3 UDF * RTF Printer - UDF * XML.au3 UDF * ADO.au3 UDF * SMTP Mailer UDF * Dual Monitor resolution detection * * 2GUI on Dual Monitor System * _SciLexer.au3 UDF * SciTE - Lexer for console pane * Useful links: * Forum Rules * Forum etiquette * Forum Information and FAQs * How to post code on the forum * AutoIt Online Documentation * AutoIt Online Beta Documentation * SciTE4AutoIt3 getting started * Convert text blocks to AutoIt code * Games made in Autoit * Programming related sites * Polish AutoIt Tutorial * DllCall Code Generator * Wiki: * Expand your knowledge - AutoIt Wiki * Collection of User Defined Functions * How to use HelpFile * Good coding practices in AutoIt * OpenOffice/LibreOffice/XLS Related: WriterDemo.au3 * XLS/MDB from scratch with ADOX IE Related: * How to use IE.au3 UDF with AutoIt v3.3.14.x * Why isn't Autoit able to click a Javascript Dialog? * Clicking javascript button with no ID * IE document >> save as MHT file * IETab Switcher (by LarsJ ) * HTML Entities * _IEquerySelectorAll() (by uncommon) * IE in TaskScheduler * IE Embedded Control Versioning (use IE9+ and HTML5 in a GUI) * PDF Related: * How to get reference to PDF object embeded in IE * IE on Windows 11 * I encourage you to read: * Global Vars * Best Coding Practices * Please explain code used in Help file for several File functions * OOP-like approach in AutoIt * UDF-Spec Questions * EXAMPLE: How To Catch ConsoleWrite() output to a file or to CMD *I also encourage you to check awesome @trancexx code: * Create COM objects from modules without any demand on user to register anything. * Another COM object registering stuff * OnHungApp handler * Avoid "AutoIt Error" message box in unknown errors * HTML editor * winhttp.au3 related : * https://www.autoitscript.com/forum/topic/206771-winhttpau3-download-problem-youre-speaking-plain-http-to-an-ssl-enabled-server-port/ "Homo sum; humani nil a me alienum puto" - Publius Terentius Afer"Program are meant to be read by humans and only incidentally for computers and execute" - Donald Knuth, "The Art of Computer Programming" , be and \\//_. Anticipating Errors : "Any program that accepts data from a user must include code to validate that data before sending it to the data store. You cannot rely on the data store, ...., or even your programming language to notify you of problems. You must check every byte entered by your users, making sure that data is the correct type for its field and that required fields are not empty." Signature last update: 2023-04-24 Link to comment Share on other sites More sharing options...
Norm73 Posted June 25, 2021 Share Posted June 25, 2021 Hello @pixelsearch, Thanks for the latest version I'm busy with right now. I stumbled upon one problem that appears if any column has Align set to 0. If there is such a column, then after moving it to the left, it becomes empty. For example: Global $ g_aColAligns [$ g_iCols] = [2, 0, 1, 0, 1, 2] pixelsearch 1 Link to comment Share on other sites More sharing options...
pixelsearch Posted June 25, 2021 Share Posted June 25, 2021 (edited) Hi Norm73, Thanks for the detailed report The issue can be easily fixed with a little modification. I got 2 possibilities for that : * Actual code in "2y" : this is the issue you described, because $iKeep_Left = $tRect.Left only for right-aligned or centered columns (not really good) ; Subitem rectangle for right and center aligned columns If $g_aColAligns[$iCol] Then ; $HDF_LEFT = 0, $HDF_RIGHT = 1, $HDF_CENTER = 2 DllCall( "gdi32.dll", "bool", "GetTextExtentPoint32W", "handle", $hDC, "wstr", $sItemText, "int", StringLen( $sItemText ), "struct*", $tSize ) ; _WinAPI_GetTextExtentPoint32 ; Keep left coord of subitem before it's lost $iKeep_Left = $tRect.Left Switch $g_aColAligns[$iCol] Case 1 ; $HDF_RIGHT DllStructSetData( $tRect, "Left", DllStructGetData( $tRect, "Right" ) - DllStructGetData( $tSize, "X" ) - 6 ) Case 2 ; $HDF_CENTER DllStructSetData( $tRect, "Left", DllStructGetData( $tRect, "Left" ) + ( DllStructGetData( $tRect, "Right" ) - DllStructGetData( $tRect, "Left" ) - DllStructGetData( $tSize, "X" ) ) / 2 - 3 ) EndSwitch EndIf 1) 1st possible way to fix this : $iKeep_Left no more in the "If $g_aColAligns" test, so it will have a correct value even for left-aligned columns, as soon as you move the line $iKeep_Left = $tRect.Left before the "If $g_aColAligns" test ; Keep left coord of subitem before it's lost $iKeep_Left = $tRect.Left ; Subitem rectangle for right and center aligned columns If $g_aColAligns[$iCol] Then ; $HDF_LEFT = 0, $HDF_RIGHT = 1, $HDF_CENTER = 2 DllCall( "gdi32.dll", "bool", "GetTextExtentPoint32W", "handle", $hDC, "wstr", $sItemText, "int", StringLen( $sItemText ), "struct*", $tSize ) ; _WinAPI_GetTextExtentPoint32 Switch $g_aColAligns[$iCol] Case 1 ; $HDF_RIGHT DllStructSetData( $tRect, "Left", DllStructGetData( $tRect, "Right" ) - DllStructGetData( $tSize, "X" ) - 6 ) Case 2 ; $HDF_CENTER DllStructSetData( $tRect, "Left", DllStructGetData( $tRect, "Left" ) + ( DllStructGetData( $tRect, "Right" ) - DllStructGetData( $tRect, "Left" ) - DllStructGetData( $tSize, "X" ) ) / 2 - 3 ) EndSwitch EndIf 2) 2nd possible way : Case 0 has been added ($HDF_LEFT) and the If $g_aColAligns" test is commented, then the +6 (pixels) found in Case 0 brings some space at the beginning of the left-aligned column, it seems enjoyable to bring a little distance between columns. ; Subitem rectangle for right and center aligned columns ;~ If $g_aColAligns[$iCol] Then ; $HDF_LEFT = 0, $HDF_RIGHT = 1, $HDF_CENTER = 2 DllCall( "gdi32.dll", "bool", "GetTextExtentPoint32W", "handle", $hDC, "wstr", $sItemText, "int", StringLen( $sItemText ), "struct*", $tSize ) ; _WinAPI_GetTextExtentPoint32 ; Keep left coord of subitem before it's lost $iKeep_Left = $tRect.Left Switch $g_aColAligns[$iCol] Case 0 ; $HDF_LEFT DllStructSetData( $tRect, "Left", $tRect.Left + 6) Case 1 ; $HDF_RIGHT DllStructSetData( $tRect, "Left", DllStructGetData( $tRect, "Right" ) - DllStructGetData( $tSize, "X" ) - 6 ) Case 2 ; $HDF_CENTER DllStructSetData( $tRect, "Left", DllStructGetData( $tRect, "Left" ) + ( DllStructGetData( $tRect, "Right" ) - DllStructGetData( $tRect, "Left" ) - DllStructGetData( $tSize, "X" ) ) / 2 - 3 ) EndSwitch ;~ EndIf 3) But as the message GetTextExtentPoint32W seems superfluous at this stage for left-aligned columns (in 2), then what follows seems better : ; Keep left coord of subitem before it's lost $iKeep_Left = $tRect.Left If $g_aColAligns[$iCol] Then ; $HDF_RIGHT = 1, $HDF_CENTER = 2 DllCall( "gdi32.dll", "bool", "GetTextExtentPoint32W", "handle", $hDC, "wstr", $sItemText, "int", StringLen( $sItemText ), "struct*", $tSize ) ; _WinAPI_GetTextExtentPoint32 Switch $g_aColAligns[$iCol] Case 1 ; $HDF_RIGHT DllStructSetData( $tRect, "Left", DllStructGetData( $tRect, "Right" ) - DllStructGetData( $tSize, "X" ) - 6 ) Case 2 ; $HDF_CENTER DllStructSetData( $tRect, "Left", DllStructGetData( $tRect, "Left" ) + ( DllStructGetData( $tRect, "Right" ) - DllStructGetData( $tRect, "Left" ) - DllStructGetData( $tSize, "X" ) ) / 2 - 3 ) EndSwitch Else ; $HDF_LEFT = 0 DllStructSetData( $tRect, "Left", $tRect.Left + 6) ; if left-aligned column, add some space between columns EndIf Please try any possibility and tell us which one suits you best, ok ? Thanks Edited June 25, 2021 by pixelsearch added 3rd possibility Norm73 1 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