Änderung der ListView Spaltenbreite detektieren

Post a reply


In an effort to prevent automatic submissions, we require that you complete the following challenge.
Smilies
:D :) ;) :( :o :shock: :? 8-) :lol: :x :P :oops: :cry: :evil: :twisted: :roll: :!: :?: :idea: :| :mrgreen: :geek: :ugeek: :arrow: :angel: :clap: :crazy: :eh: :lolno: :problem: :shh: :shifty: :sick: :silent: :think: :thumbup: :thumbdown: :salute: :wave: :wtf: :yawn: :facepalm: :bravo: :dance: :beard: :morebeard: :xmas: :HeHe: :trollface: :cookie: :rainbow: :monkeysee: :monkeysay: :happybday: :headwall: :offtopic: :superhappy: :terms: :beer:
View more smilies

BBCode is ON
[img] is OFF
[flash] is OFF
[url] is ON
Smilies are ON

Topic review
   

Expand view Topic review: Änderung der ListView Spaltenbreite detektieren

Re: Änderung der ListView Spaltenbreite detektieren

Post by effel » 17 Jul 2023, 14:27

just me wrote:
16 Jul 2023, 03:43
just me
danke @just me

Re: Änderung der ListView Spaltenbreite detektieren

Post by just me » 16 Jul 2023, 03:43

Moin,

wenn das automatisch über die Mausnachrichten passiert, kann ein Button nichts mehr tun. Wenn Du die Spaltenbreiten aber auch anders änderst oder die Automatik manchmal versagt, macht es schon Sinn. Du kannst dann den Buttonklick auf eine Routine ähnlich Deiner ursprünglichen Version von LVTAB2LVA: leiten:

Code: Select all

Gui, Add, ListView, w790 r5 hwndHLVTAB2LVA gLVTAB2LVA vLVTAB2LVA -Wrap +Checked, a|b|c|d|e|f|g|h|i|j|k
...
BtnCalcWidth:
   Gui, ListView, LVTAB2LVA
   LVWControl := 0
   Loop, LV_GetCount("Col")
      LVWControl += DllCall("SendMessage", "Ptr", HLVTAB2LVA, "UInt", 0x101D, "Ptr", A_Index - 1, "Ptr", 0, "Int")
   LVWControl += 20
   GuiControl, MoveDraw, LVTAB2LVA, w%LVWControl%
   Gui, Show, AutoSize
Return
Schönen Sonntag noch,
just me

Re: Änderung der ListView Spaltenbreite detektieren

Post by effel » 15 Jul 2023, 14:54

just me wrote:
15 Dec 2021, 05:57
Ich empfehle deshalb z.B. so etwas:
Kann ich das auch mit einem Button auslösen?

Sowohl als auch

Re: Änderung der ListView Spaltenbreite detektieren

Post by effel » 15 Dec 2021, 21:52

Dankeschön genau so sollte es funktionieren.
Unbenannt.png
Unbenannt.png (72.3 KiB) Viewed 1235 times

Re: Änderung der ListView Spaltenbreite detektieren

Post by just me » 15 Dec 2021, 05:57

Moin,

Mausklicks sind in 'normalen' Anwendungen nicht sehr häufig und können deshalb 'relativ gefahrlos' über OnMessage() behandelt werden. Ich empfehle deshalb z.B. so etwas:

Code: Select all

#NoEnv
SetBatchLines, -1
Gui, Add, ListView, w790 r5 hwndHLVTAB2LVA gLVTAB2LVA vLVTAB2LVA -Wrap +Checked, a|b|c|d|e|f|g|h|i|j|k
Loop, 5
   LV_Add("", StrSplit("a|b|c|d|e|f|g|h|i|j|k", "|")*)
Gui, Show, , LV Test
HHEADER := LV_GetHeader(HLVTAB2LVA)
OnMessage(0x0202, "WM_LBUTTONUP")
Return

GuiClose:
ExitApp

LVTAB2LVA:
Return

WM_LBUTTONUP(W, L, M, H) {
   ; HDM_HITTEST (0x1206) -> https://docs.microsoft.com/en-us/windows/win32/controls/hdm-hittest
   Global HHEADER
   If (H = HHEADER) {
      VarSetCapacity(HDHTI, 16, 0) ; HDHITTESTINFO
      NumPut(L << 48 >> 48, HDHTI, 0, "Int") ; Maus X
      NumPut(L << 32 >> 48, HDHTI, 4, "Int") ; Maus Y
      DllCall("SendMessage", "Ptr", H, "UInt", 0x1206, "Ptr", 0, "Ptr", &HDHTI) ; HDM_HITTEST
      If (NumGet(HDHTI, 8, "Int") = 0x0004) { ; HHT_ONDIVIDER
         Cols := DllCall("SendMessage", "Ptr", H, "UInt", 0x1200, "Ptr", 0, "Ptr", 0, "Int") ; HDM_GETITEMCOUNT
         HLV := DllCall("GetParent", "Ptr", H, "UPtr") ; Handle des 'Eltern'-ListView
         LVWControl := 0
         Loop, %Cols% ; 0x101D ist LVM_GETCOLUMNWIDTH.
            LVWControl += DllCall("SendMessage", "Ptr", HLV, "UInt", 0x101D, "Ptr", A_Index - 1, "Ptr", 0, "Int")
         LVWControl += 20
         GuiControl, MoveDraw, %HLV%, w%LVWControl%
         Gui, Show, AutoSize
      }
   }
}

LV_GetHeader(HLV) {
   ; LVM_GETHEADER (0x101F) -> https://docs.microsoft.com/en-us/windows/win32/controls/lvm-getheader
   Return DllCall("SendMessage", "Ptr", HLV, "UInt", 0x101F, "Ptr", 0, "Ptr", 0, "UPtr")
}

Änderung der ListView Spaltenbreite detektieren

Post by effel » 14 Dec 2021, 17:18

Hallo,

wenn ich die Spaltenbreite im Listview ändere, bekomme ich dies leider nicht im g Label mitgeteilt.

Erst wenn ich danach im Listview klicke, wird MoveDraw ausgeführt

Wie kann ich das loslassen der Maustaste als Detektor nutzen?

Code: Select all

gui,add,listview, w790 r5 hwndHLVTAB2LVA gLVTAB2LVA vLVTAB2LVA -Wrap +Checked, a|b|c|d|e|f|g|h|i|j|k
gui, show, w1200 h200
return
LVTAB2LVA:
Gui +LastFound
LVWControl =
gui, show, hide
Loop % LV_GetCount("Column")
{
SendMessage, 0x101D, A_Index - 1, 0, SysListView321  ; 0x101D ist LVM_GETCOLUMNWIDTH.
LVWControl += ErrorLevel
}
LVWControl += 20
GuiControl, MoveDraw, LVTAB2LVA, w%LVWControl%
gui, show
return

Top