I fear that it won't be "inside a tooltip" but more like a fake tooltip
I'd like to see an example like the one you mention
Formatting a multi-line Tooltip to align like columns ? Topic is solved
- Blue Kodiak
- Posts: 26
- Joined: 17 Mar 2019, 00:45
Re: Formatting a multi-line Tooltip to align like columns ?
Monospace font and count characters.
I think that's the only way.
I think that's the only way.
Re: Formatting a multi-line Tooltip to align like columns ?
Okay I found a way to make this with a listView. Its rather complex and heavy just for a tooltip but maybe in the end you may decide if its worth it:
PS: I left more code than necessary to include other provided example by the kind contributors in posts above
In my real script it looks like this and it is shown on WM_MOUSEMOVE if hWnd = a Row # static ctrl
PS: I left more code than necessary to include other provided example by the kind contributors in posts above
In my real script it looks like this and it is shown on WM_MOUSEMOVE if hWnd = a Row # static ctrl
Code: Select all
#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory.
#SingleInstance, Force ; Prevent double execution of this script
#Persistent
; Faking what are normally dynamic variables (changing with different calculations)
Qt_1 := 2
, Mt_1 := 100000.00
, RawTs_1 := 4000.35
, RawTq_1 := 8000.68
; Prepare the values to display in the tooltip
Line := []
, Line.OverRowNumb := 1
, OverRowNumb := Line.OverRowNumb
, Line.Quantite := Qt_%OverRowNumb%
, Line.PrixUnitaire := Mt_%OverRowNumb%
, Line.TPSUnitaire := RawTs_%OverRowNumb%
, Line.TVQUnitaire := RawTq_%OverRowNumb%
, Line.TotalHorsTx := (Line.PrixUnitaire - (Line.TPSUnitaire + Line.TVQUnitaire)) * Line.Quantite
, Line.TotalTPS := Line.TPSUnitaire * Line.Quantite
, Line.TotalTVQ := Line.TVQUnitaire * Line.Quantite
, Line.TotalTAXES := Line.TotalTPS + Line.TotalTVQ
, Line.TotalAvecTx := Line.PrixUnitaire * Line.Quantite
; _________________________________________________________
, Line.StrLen := StrLen(Line.TotalAvecTx) + 3
, Line._ := ""
Loop, % Line.StrLen {
Line._ .= "_"
}
;/*
;-----------------------------------------------------------------------------------------------------------------------------------------
TT_ListView(Line)
;-----------------------------------------------------------------------------------------------------------------------------------------
*/
/*
data=
(
"Calcul Line #%OverRowNumb% :
"`nSous-total hors taxes,%Ligne_TotalHorsTx%,"$ ( %Ligne_PrixUnitaire%$ * Quantité = %Ligne_TotalAvecTx%$ - Taxes )"
" + TPS","%Ligne_TotalTPS%","$ ( %Ligne_TPSUnitaire%$ * Quantité )"
" + TVQ","%Ligne_TotalTVQ%","$ ( %Ligne_TVQUnitaire%$ * Quantité )"
"_____________________ "
"Sous-total avec taxes","%Ligne_TotalAvecTx%","$"
)
ToolTipFont("s10 q5", "Consolas")
TT_Tip := st_columnize(data, "csv", 1,, " ") ; 1=gauche, 2=right, 3=center
*/
;ToolTip, % TT_Tip, % A_ScreenWidth//3, % A_ScreenHeight // 2.5 ; Show the ToolTip
SetTimer, ToolTipOff, -5000 ; Set the Timer to automatically turn off tooltip after number of ms ;*[Untitled1]
Return
ToolTipOff:
Tooltip ; Off
ExitApp
;-----------------------------------------------------------------------------------------------------------------------------------------
TT_ListView(ByRef Line) { ; Pass an Object by Reference
;-----------------------------------------------------------------------------------------------------------------------------------------
Gui, TT_ListView:New, -Caption ; Creates a new GUI, destroying any existing GUI with that name and sets it as the default for the current thread.
Gui, Margin, 0, 0
Gui, Add, ListView, w800 r8 +Grid -hdr, % "Calcul Line #"Line.OverRowNumb "| | | "
LV_Add( "", "Calcul Line #"Line.OverRowNumb " :")
, LV_Add( "") ; EMPTY
, LV_Add( "", " Sous-total hors taxes", Line.TotalHorsTx " $ ", " Formule : ( Quantité x PRIX ) - TAXES ", " ( " Line.Quantite " x " Line.PrixUnitaire " $ ) - " Line.TotalTAXES " $" )
, LV_Add( "", " + TPS" , Line.TotalTPS " $ ", " Formule : ( Quantité x TPS ) " , " ( " Line.Quantite " x " Line.TPSUnitaire " $ ) " )
, LV_Add( "", " + TVQ" , Line.TotalTVQ " $ ", " Formule : ( Quantité x TVQ ) " , " ( " Line.Quantite " x " Line.TVQUnitaire " $ ) " )
, LV_Add( ""," _________________ " , Line._ )
, LV_Add( "", " Sous-total avec taxes", Line.TotalAvecTx " $ ")
, LV_ModifyCol(1, "AutoHDR")
, LV_ModifyCol(2, "AutoHDR Right")
, LV_ModifyCol(3, "AutoHDR Left")
, LV_ModifyCol(4, "AutoHDR Left")
Gui, Show
}
; provided by ahk7
ToolTipFont(Options := "", Name := "", hwnd := "") {
static hfont := 0
if (hwnd = "")
hfont := Options="Default" ? 0 : _TTG("Font", Options, Name), _TTHook()
else
DllCall("SendMessage", "ptr", hwnd, "uint", 0x30, "ptr", hfont, "ptr", 0)
}
ToolTipColor(Background := "", Text := "", hwnd := "") {
static bc := "", tc := ""
if (hwnd = "") {
if (Background != "")
bc := Background="Default" ? "" : _TTG("Color", Background)
if (Text != "")
tc := Text="Default" ? "" : _TTG("Color", Text)
_TTHook()
}
else {
VarSetCapacity(empty, 2, 0)
DllCall("UxTheme.dll\SetWindowTheme", "ptr", hwnd, "ptr", 0
, "ptr", (bc != "" || tc != "") ? &empty : 0)
if (bc != "")
DllCall("SendMessage", "ptr", hwnd, "uint", 1043, "ptr", bc, "ptr", 0)
if (tc != "")
DllCall("SendMessage", "ptr", hwnd, "uint", 1044, "ptr", tc, "ptr", 0)
}
}
_TTHook() {
static hook := 0
if !hook
hook := DllCall("SetWindowsHookExW", "int", 4
, "ptr", RegisterCallback("_TTWndProc"), "ptr", 0
, "uint", DllCall("GetCurrentThreadId"), "ptr")
}
_TTWndProc(nCode, _wp, _lp) {
Critical 999
;lParam := NumGet(_lp+0*A_PtrSize)
;wParam := NumGet(_lp+1*A_PtrSize)
uMsg := NumGet(_lp+2*A_PtrSize, "uint")
hwnd := NumGet(_lp+3*A_PtrSize)
if (nCode >= 0 && (uMsg = 1081 || uMsg = 1036)) {
_hack_ = ahk_id %hwnd%
WinGetClass wclass, %_hack_%
if (wclass = "tooltips_class32") {
ToolTipColor(,, hwnd)
ToolTipFont(,, hwnd)
}
}
return DllCall("CallNextHookEx", "ptr", 0, "int", nCode, "ptr", _wp, "ptr", _lp, "ptr")
}
_TTG(Cmd, Arg1, Arg2 := "") {
static htext := 0, hgui := 0, WM_CTLCOLORSTATIC := 0x138, WM_GETFONT := 0x31, WS_CHILD := 0x40000000
if !htext {
Gui _TTG: +hwndhgui +%WS_CHILD%
Gui _TTG: Add, Text, hwndhtext
}
Gui _TTG: %Cmd%, %Arg1%, %Arg2%
if (Cmd = "Font") {
GuiControl _TTG: Font, %htext%
SendMessage, WM_GETFONT, 0, 0,, ahk_id %htext%
return ErrorLevel
}
if (Cmd = "Color") {
hdc := DllCall("GetDC", "ptr", htext, "ptr")
SendMessage, WM_CTLCOLORSTATIC, hdc, htext,, ahk_id %hgui%
clr := DllCall("GetBkColor", "ptr", hdc, "uint")
DllCall("ReleaseDC", "ptr", htext, "ptr", hdc)
return clr
}
}
/* ; from string things by Tidbit
st_columnize
Take a set of data with a common delimiter (csv, tab, |, "a string", anything) and
nicely organize it into a column structure, like an EXCEL spreadsheet.
data = [String] Your input data to be organized.
delim = [Optional] What separates each set of data? It can be a string or it can
be the word "csv" to treat it as a CSV document.
justify = [Optional] Specify 1 to align the data to the left of the column, 2 for
aligning to the right or 3 to align centered. You may enter a
string such as "2|1|3" to adjust columns specifically. Columns are
separeted by |.
pad = [Optional] The string that should fill in shorter column items to match
the longest item.
colsep = [Optional] What string should go between every column?
example:
data=
(
"Date","Pupil","Grade"
----,-----,-----
"25 May","Bloggs, Fred","C"
"25 May","Doe, Jane","B"
"15 July","Bloggs, Fred","A"
"15 April","Muniz, Alvin ""Hank""","A"
)
output:=Columnize(data, "csv", 2)
output:
Date | Pupil | Grade
---- | ----- | -----
25 May | Bloggs, Fred | C
25 May | Doe, Jane | B
15 July | Bloggs, Fred | A
15 April | Muniz, Alvin "Hank" | A
*/
st_columnize(data, delim="csv", justify=1, pad=" ", colsep=" | ")
{
widths:=[]
dataArr:=[]
if (instr(justify, "|"))
colMode:=strsplit(justify, "|")
else
colMode:=justify
; make the arrays and get the total rows and columns
loop, parse, data, `n, `r
{
if (A_LoopField="")
continue
row:=a_index
if (delim="csv")
{
loop, parse, A_LoopField, csv
{
dataArr[row, a_index]:=A_LoopField
if (dataArr.maxindex()>maxr)
maxr:=dataArr.maxindex()
if (dataArr[a_index].maxindex()>maxc)
maxc:=dataArr[a_index].maxindex()
}
}
else
{
dataArr[a_index]:=strsplit(A_LoopField, delim)
if (dataArr.maxindex()>maxr)
maxr:=dataArr.maxindex()
if (dataArr[a_index].maxindex()>maxc)
maxc:=dataArr[a_index].maxindex()
}
}
; get the longest item in each column and store its length
loop, %maxc%
{
col:=a_index
loop, %maxr%
if (strLen(dataArr[a_index, col])>widths[col])
widths[col]:=strLen(dataArr[a_index, col])
}
; the main goodies.
loop, %maxr%
{
row:=a_index
loop, %maxc%
{
col:=a_index
stuff:=dataArr[row,col]
len:=strlen(stuff)
difference:=abs(strlen(stuff)-widths[col])
; generate a repeating string about the length of the longest item
; in the column.
loop, % ceil(widths[col]/((strlen(pad)<1) ? 1 : strlen(pad)))
padSymbol.=pad
if (isObject(colMode))
justify:=colMode[col]
; justify everything correctly.
; 3 = center, 2= right, 1=left.
if (strlen(stuff)<widths[col])
{
if (justify=3)
stuff:=SubStr(padSymbol, 1, floor(difference/2)) . stuff
. SubStr(padSymbol, 1, ceil(difference/2))
else
{
if (justify=2)
stuff:=SubStr(padSymbol, 1, difference) stuff
else ; left justify by default.
stuff:= stuff SubStr(padSymbol, 1, difference)
}
}
out.=stuff ((col!=maxc) ? colsep : "")
}
out.="`r`n"
}
stringTrimRight, out, out, 2 ; remove the last blank newline
return out
}
Re: Formatting a multi-line Tooltip to align like columns ?
Give this a go.
Code: Select all
#SingleInstance,Force
#NoEnv
ListLines,Off
SetBatchLines,-1
CoordMode,Mouse,Screen
Columns:=["Date","Pupil","Grade"]
Column1:=["25 May","25 May","15 July","15 April"]
;~ Column2:=["Bloggs, Fred","Doe, Jane","Bloggs, Fred","Muniz, Alvin, Hank"]
Column2:=["Bloggs, Fred","Doe, Jane","Bloggs, Fred","Muniz, Alvin, Hank, Bob, Sam, Tom, Dick, Harry"]
Column3:=["C","B","A","A"]
Sep:=[]
loop 3 {
num:=BSort(strlen(columns[A_Index]),strlen(column%A_Index%[1]),strlen(column%A_Index%[2]),strlen(column%A_Index%[3]),strlen(column%A_Index%[4])),index:=A_Index
Loop,% num +3
Sep[Index].="_"
}
;Example 2
;--------------------------------------------------------------------------------
Gui,1:+AlwaysOnTop -Caption +ToolWindow +Border ; +E0x20 Not working for some reason?
Gui,1:Color,000000
Gui,1:Margin,0,0
Gui,1:Font,cBlack s8,Courier New
loop 3
Gui,1:Add,Edit,% ((A_Index=1)?("xm"):("x+0")) " y0 -Wrap -VScroll +Disabled -e0x200 +Border",% "`n " columns[A_Index] " `n " Sep[A_Index] "`n " Column%A_Index%[1] "`n " Column%A_Index%[2] "`n " Column%A_Index%[3] "`n " Column%A_Index%[4] "`n"
Gui,1:Show, NA,ToolTip Window
;Example 2
;--------------------------------------------------------------------------------
Gui,2:+AlwaysOnTop -Caption +ToolWindow +Border ; +E0x20 Not working for some reason?
Gui,2:Color,00ff00
Gui,2:Margin,0,0
Gui,2:Font,s10 Bold,Arial
loop 3
Gui,2:Add,Edit,% ((A_Index=1)?("xm"):("x+0")) " y0 -Wrap -VScroll +Disabled -e0x200 +Border",% "`n " columns[A_Index] " `n " Sep[A_Index] "`n " Column%A_Index%[1] "`n " Column%A_Index%[2] "`n " Column%A_Index%[3] "`n " Column%A_Index%[4] "`n"
Gui,2:Show,x0 y0 NA,ToolTip Window
;Example 3
;--------------------------------------------------------------------------------
Gui,3:+AlwaysOnTop -Caption +ToolWindow +Border
Gui,3:Color,660000
Gui,3:Margin,0,0
Gui,3:Font,cBlack s12,Segoe UI
loop 3
Gui,3:Add,Edit,% ((A_Index=1)?("xm"):("x+0")) " y0 -Wrap -VScroll +Disabled -e0x200 +Border hwndhwnd",% "`n " columns[A_Index] " `n " Sep[A_Index] "`n " Column%A_Index%[1] "`n " Column%A_Index%[2] "`n " Column%A_Index%[3] "`n " Column%A_Index%[4] "`n"
Gui,3:Show,x300 y300 NA,ToolTip Window
;Example 4
;--------------------------------------------------------------------------------
Gui,4:+AlwaysOnTop -Caption +ToolWindow +Border
Gui,4:Color,FFFFFF
Gui,4:Margin,0,0
Gui,4:Font,cBlack s12,Arial Black
loop 3
Gui,4:Add,Edit,% ((A_Index=1)?("xm"):("x+0")) " y0 -Wrap -VScroll +Disabled -e0x200 +Border hwndhwnd",% "`n " columns[A_Index] " `n " Sep[A_Index] "`n " Column%A_Index%[1] "`n " Column%A_Index%[2] "`n " Column%A_Index%[3] "`n " Column%A_Index%[4] "`n"
Gui,4:Show,x500 y500 NA,ToolTip Window
SetTimer,Move_Window,10
return
GuiClose:
*Esc::
ExitApp
Move_Window(){
MouseGetPos,tx,ty
Gui,1:Show,% "x" tx+15 " y" ty+15 " NA"
}
BSort(a,b,c,d,e){
if(a>=b&&a>=c&&a>=d&&a>=e)
return a
else if(b>=c&&b>=d&&b>=e)
return b
else if(c>=d&&c>=e)
return c
else if(d>=e)
return d
return e
}
Re: Formatting a multi-line Tooltip to align like columns ?
make your own LV_Gui
Code: Select all
#NoEnv
#SingleInstance Force
Table := []
Table.Push({Date: "25 May", Pupil: "Bloggs, Fred", Grade: "C"})
Table.Push({Date: "25 May", Pupil: "Doe, Jane", Grade: "B"})
Table.Push({Date: "15 July", Pupil: "Bloggs, Fred", Grade: "A"})
Table.Push({Date: "15 April", Pupil: "Muniz, Alvin 'Hank'", Grade: "A"})
config := [[" A_Index "," # "," AutoHdr Integer Center "]
, [" Date "," Date "," AutoHdr "]
, [" Pupil "," Pupil "," AutoHdr "]
, [" Grade "," Grade "," AutoHdr Center"]]
LV_Gui(Table, config)
LV_Gui(ByRef Obj, config) {
for each, Column in config
Headers .= Trim(Column[2]) "|"
Gui, LV_Gui: New,, LV_Gui
Gui, -Caption
Gui, Margin, 0, 0
Gui, Add, ListView, w220 Grid, %Headers%%A_Space%
Col := []
for each, Column in config
if (A_Index > 1)
Col[A_Index] := Trim(Column[1])
for each, Row in Obj {
Private := []
if IsObject(Row)
Loop, % config.Length() - 1
Private.Push(Row[Col[A_Index + 1]])
else
Private.Push(each, Row)
LV_Add("", A_Index, Private*)
}
for each, Column in config
LV_ModifyCol(A_Index, Column[3])
LV_ModifyCol(LV_GetCount("Col"), 0)
Gui, Show
}
Re: Formatting a multi-line Tooltip to align like columns ?
Damn nice usage of For loops and objects!!
I've messed with it too!
Code: Select all
#NoEnv
#SingleInstance Force
Table := []
Table.Push({Date: "25 May", Pupil: "Bloggs, Fred", Grade: "C"})
Table.Push({Date: "25 May", Pupil: "Doe, Jane", Grade: "B"})
Table.Push({Date: "15 July", Pupil: "Bloggs, Fred", Grade: "A"})
Table.Push({Date: "15 April", Pupil: "Muniz, Alvin 'Hank'", Grade: "A"})
config := [[" A_Index "," # "," AutoHdr Integer Center "]
, [" Date "," Date "," AutoHdr "]
, [" Pupil "," Pupil "," AutoHdr "]
, [" Grade "," Grade "," AutoHdr Center"]]
LV_Gui(Table, config)
return
;-----------------------------------------------------------------------------------------------------------------------------------------
LV_Gui(ByRef Obj, config) {
;-----------------------------------------------------------------------------------------------------------------------------------------
Col := []
for each, Column in config {
Headers .= Trim(Column[2]) "|"
if (A_Index > 1)
Col[A_Index] := Trim(Column[1])
}
Gui, LV_Gui: New, -Caption, LV_Gui
Gui, Margin, 0, 0
Gui, Add, ListView, w220 Grid, %Headers%%A_Space%
for each, Row in Obj {
Private := []
if IsObject(Row)
Loop, % config.Length() - 1
Private.Push(Row[Col[A_Index + 1]])
else
Private.Push(each, Row)
LV_Add("", A_Index, Private*)
}
for each, Column in config
LV_ModifyCol(A_Index, Column[3])
LV_ModifyCol(LV_GetCount("Col"), 0)
Gui, Show
}
Thank you every one this is fabulous and I think we got a good amount of examples here to solve this problem in flexible ways.
Re: Formatting a multi-line Tooltip to align like columns ?
BSort just checks to see what the longest item in a column is and adds a appropriately long divider between the column heading and entry's.
Most of the code is contained in the 4 examples, I'd suggest removing all but the first one and it will be much simpler to follow. Likewise, if you don't need it to follow your cursor you can remove the timer, setting the coordmode and the move function. You can use any font and any any size and it should fit just the same.
Code: Select all
#SingleInstance,Force
Columns:=["Date","Pupil","Grade"]
Column1:=["25 May","25 May","15 July","15 April"]
Column2:=["Bloggs, Fred","Doe, Jane","Bloggs, Fred","Muniz, Alvin, Hank"]
Column3:=["C","B","A","A"]
Sep:=[]
loop 3 {
num:=BSort(strlen(columns[A_Index]),strlen(column%A_Index%[1]),strlen(column%A_Index%[2]),strlen(column%A_Index%[3]),strlen(column%A_Index%[4])),index:=A_Index
Loop,% num +3
Sep[Index].="_"
}
Gui,1:+AlwaysOnTop -Caption +ToolWindow +Border
Gui,1:Color,000000
Gui,1:Margin,0,0
Gui,1:Font,s8,Courier New
loop 3
Gui,1:Add,Edit,% ((A_Index=1)?("xm"):("x+0")) " y0 -Wrap -VScroll +Disabled -e0x200 +Border",% "`n " columns[A_Index] " `n " Sep[A_Index] "`n " Column%A_Index%[1] "`n " Column%A_Index%[2] "`n " Column%A_Index%[3] "`n " Column%A_Index%[4] "`n"
Gui,1:Show, NA,ToolTip Window
return
GuiClose:
*Esc::
ExitApp
BSort(a,b,c,d,e){
if(a>=b&&a>=c&&a>=d&&a>=e)
return a
else if(b>=c&&b>=d&&b>=e)
return b
else if(c>=d&&c>=e)
return c
else if(d>=e)
return d
return e
}
Last edited by Hellbent on 28 Mar 2019, 21:15, edited 1 time in total.
Re: Formatting a multi-line Tooltip to align like columns ?
I cleaned up config and compressed the code
edit: Byref added
Code: Select all
#NoEnv
#SingleInstance Force
Table := []
Table.Push({Date: "25 May", Pupil: "Bloggs, Fred", Grade: "C"})
Table.Push({Date: "25 May", Pupil: "Doe, Jane", Grade: "B"})
Table.Push({Date: "15 July", Pupil: "Bloggs, Fred", Grade: "A"})
Table.Push({Date: "15 April", Pupil: "Muniz, Alvin 'Hank'", Grade: "A"})
config := [["Date"], ["Pupil"], ["Grade", "Center"]]
LV_Gui(Table, config)
Esc:: ExitApp
;-------------------------------------------------------------------------------
LV_Gui(ByRef Obj, ByRef config) {
;-------------------------------------------------------------------------------
Col := []
for each, Column in config
Headers .= (Col[A_Index] := Column[1]) "|"
Gui, -Caption
Gui, Margin, 0, 0
Gui, Add, ListView, w200 Grid, % Headers A_Space
for each, Row in Obj {
Private := []
if IsObject(Row)
Loop, % config.Length() - 1
Private.Push(Row[Col[A_Index + 1]])
else
Private.Push(each, Row)
LV_Add("", A_Index, Private*)
}
for each, Column in config
LV_ModifyCol(A_Index, "AutoHdr " Column[2])
LV_ModifyCol(LV_GetCount("Col"), 0)
Gui, Show
}
Last edited by wolf_II on 28 Mar 2019, 21:47, edited 1 time in total.
Re: Formatting a multi-line Tooltip to align like columns ?
Yes intuitively I did remove the other example and focused on one to customize it until I get it.
Its pretty nice. Thank you for clarifications about BSort too.
Now I am hesitating between regular ListView and this custom Gui. I'll keep testing on this topic tommorow.
I'm amazed how many different ways there are to do the same things
Re: Formatting a multi-line Tooltip to align like columns ?
I added a second ByRef.
Re: Formatting a multi-line Tooltip to align like columns ?
I've been messing around with this for a while and trying uncommun stuff.
Is therre a way to know what width a LV col is ?
I am trying such a idea :
Is therre a way to know what width a LV col is ?
I am trying such a idea :
Code: Select all
#NoEnv
#SingleInstance Force
Table := []
Table.Push({Date: "25 May", Pupil: "Bloggs, Fred", Grade: "C"})
Table.Push({Date: "25 May", Pupil: "Doe, Jane", Grade: "B"})
Table.Push({Date: "15 July", Pupil: "Bloggs, Fred", Grade: "A"})
Table.Push({Date: "15 April", Pupil: "Muniz, Alvin 'Hank'", Grade: "A"})
config := [["Date"], ["Pupil"], ["Grade", "Center"]]
LV_Gui(Table, config)
Esc:: ExitApp
;-------------------------------------------------------------------------------
LV_Gui(ByRef Obj, ByRef config) {
;-------------------------------------------------------------------------------
Col := []
for each, Column in config
Headers .= (Col[A_Index] := Column[1]) "|"
Gui, -Caption
Gui, Color, 000000 ; Black Gui Background
Gui, Margin, 0, 0 ; Creates Black border around the ListView
w := 300
Gui, Add, ListView, Y30 w%w% R4 Grid -hdr, % Headers A_Space
for each, Row in Obj {
Private := []
if IsObject(Row)
Loop, % config.Length() - 1
Private.Push(Row[Col[A_Index + 1]])
else
Private.Push(each, Row)
LV_Add("", A_Index, Private*)
}
for each, Column in config
LV_ModifyCol(A_Index, "AutoHdr " Column[2])
LV_ModifyCol(LV_GetCount("Col"), 0)
Gui, Font, s11 cWhite Bold
Gui, Add, Text, % "x0 y0 w"55 " h30 +0x201 +bORDER" , % "DATE"
Gui, Add, Text, % "x+-1 y0 w"85 " h30 +0x201 +bORDER" , % "PUPIL"
Gui, Add, Text, % "x+-1 y0 w"65 " h30 +0x201 +bORDER" , % "GRADE"
Gui, Show
}
Re: Formatting a multi-line Tooltip to align like columns ?
Code: Select all
; get column widths (4125 = LVM_GETCOLUMNWIDTH)
SendMessage, 4125, 0, 0, SysListView321 ; 0 = column_#1
Code: Select all
#NoEnv
#SingleInstance Force
Table := []
Table.Push({Date: "25 May", Pupil: "Bloggs, Fred", Grade: "C"})
Table.Push({Date: "25 May", Pupil: "Doe, Jane", Grade: "B"})
Table.Push({Date: "15 July", Pupil: "Bloggs, Fred", Grade: "A"})
Table.Push({Date: "15 April", Pupil: "Muniz, Alvin 'Hank'", Grade: "A"})
config := [["Date"], ["Pupil"], ["Grade", "Center"]]
LV_Gui(Table, config)
Esc:: ExitApp
;-------------------------------------------------------------------------------
LV_Gui(ByRef Obj, ByRef config) {
;-------------------------------------------------------------------------------
Col := []
for each, Column in config
Headers .= (Col[A_Index] := Column[1]) "|"
Gui, -Caption +LastFound
Gui, Color, 000000 ; Black Gui Background*
Gui, Margin, 0, 0 ; Creates Black border around the ListView
w := 300
Gui, Add, ListView, Y30 w%w% R4 Grid -hdr, % Headers A_Space
for each, Row in Obj {
Private := []
if IsObject(Row)
Loop, % config.Length() - 1
Private.Push(Row[Col[A_Index + 1]])
else
Private.Push(each, Row)
LV_Add("", A_Index, Private*)
}
for each, Column in config
LV_ModifyCol(A_Index, "AutoHdr " Column[2])
LV_ModifyCol(LV_GetCount("Col"), 0)
; get column widths (4125 = LVM_GETCOLUMNWIDTH)
SendMessage, 4125, 0, 0, SysListView321
w1 := ErrorLevel
SendMessage, 4125, 1, 0, SysListView321
w2 := ErrorLevel
SendMessage, 4125, 2, 0, SysListView321
w3 := ErrorLevel
Gui, Font, cWhite Bold
Gui, Add, Text, x0 y0 w%w1% h30 +0x201 +bORDER , % "DATE"
Gui, Add, Text, x+-1 y0 w%w2% h30 +0x201 +bORDER , % "PUPIL"
Gui, Add, Text, x+-1 y0 w%w3% h30 +0x201 +bORDER , % "GRADE"
Gui, Show
}
Re: Formatting a multi-line Tooltip to align like columns ?
Thank you. This has led me to other experimentations, I'll post when I get something different and usable. I'm going 100% custom Gui. It might takae a day or two ebfore I post again tho
Who is online
Users browsing this forum: No registered users and 148 guests