我想要ListView的一个单元格输出包含换行符的内容,如:
varLv := a . "`n" . b 用MsgBox输出时两个变量的内容就在两行,把变量放到ListView的某一个单元格中还是在一行显示,请问该怎么办?谢谢!
请问,ListView的单元格内容中有"`n"换行符,为什么输出时内容还是在一行显示? Topic is solved
Moderators: tmplinshi, arcticir
Re: 请问,ListView的单元格内容中有"`n"换行符,为什么输出时内容还是在一行显示? Topic is solved
可以这样:
Code: Select all
Gui, Add, ListView, w600 h300 Grid, col1
lvCtrl_SetRowHeight(50)
LV_Add("", "line1`nline2")
Gui, Show
Return
GuiClose:
ExitApp
lvCtrl_SetRowHeight(Height) {
LV_SetImageList( DllCall( "ImageList_Create", Int,2, Int, Height, Int,0x18, Int,1, Int,1 ), 1 )
}
Re: 请问,ListView的单元格内容中有"`n"换行符,为什么输出时内容还是在一行显示?
EDIT : solved from user 'just me' 20181210 20:15 UTC
谢谢你,更大的ico的想法? ( bigger ICO without library )
https://autohotkey.com/boards/viewtopic.php?f=9&t=59791
https://autohotkey.com/boards/viewtopic.php?f=6&t=1256 just me LV_EX LIB
solved from user 'just me' :
Listview: added ICO with defined size with a part from :
https://github.com/AHK-just-me/IL_EX IL_EX LIB
IL_EX_SetSize(ILID, W, H)
谢谢你,更大的ico的想法? ( bigger ICO without library )
https://autohotkey.com/boards/viewtopic.php?f=9&t=59791
https://autohotkey.com/boards/viewtopic.php?f=6&t=1256 just me LV_EX LIB
solved from user 'just me' :
Listview: added ICO with defined size with a part from :
https://github.com/AHK-just-me/IL_EX IL_EX LIB
IL_EX_SetSize(ILID, W, H)
Code: Select all
;- Listview added ICO with defined size
;- LV_ICO_TEST > put the ico "032_neu_PDF_niO.png" in subfolder ICO
; "042_nix_PDF_niO.png"
;-----------------------------------------------------------------------------------------------------------
;- https://autohotkey.com/boards/viewtopic.php?f=6&t=1256 just me LV_EX LIB
;- https://autohotkey.com/boards/viewtopic.php?f=6&t=1273
;- https://github.com/AHK-just-me/IL_EX IL_EX LIB
;- https://autohotkey.com/boards/viewtopic.php?f=9&t=59791 german question for bigger ICOn's
;- https://autohotkey.com/boards/download/file.php?id=6127 download ICO for test
;--------------------------------------------------------
#warn
#noenv
#SingleInstance force
setworkingdir, %a_scriptdir%
Gui,2:default
Gui,2: -DPIScale
Gui,2:Font,CDefault s14 , Lucida Console
transform,s,chr,10
;----------------- TEST -------------------------
R3ICO=%A_scriptDir%\ICO ;- put your icons here
ifnotexist,%R3ICO%
FileCreateDir,%R3ICO%
png1:=r3ico . "\032_neu_PDF_niO.png" ;- for test
png2:=r3ico . "\042_nix_PDF_niO.png"
fx=%a_scriptdir%\test55.txt
ifnotexist,%fx%
fileappend,Line1`r`n,%fx%
fn=%a_scriptdir%\test56.csv
ifnotexist,%fn%
fileappend,Line1`r`n,%fn%
F12=%A_ScriptDir%\test.csv ;example
;filedelete,%f12%
ifnotexist,%F12%
{
fileappend,CALC;C:\windows\system32\calc.exe;`r`n,%f12%
fileappend,TEST;test55.txt;`r`n,%f12%
fileappend,TEST;test56.csv;`r`n,%f12%
}
;-----------------------------------------------
T1=300
T2=630
T3=0
T1K:=T1
T2K:=T1+T2+50
T2A:=T1+T2+70
Gui,2:Add, ListView, backgroundSilver grid x3 y10 h240 w%t2k% +hscroll altsubmit vMLV1 gMLV2, AA|BB|CC
ILid := IL_Create(1,1,0) ;- small
;ILid := IL_Create(1,1,1) ;- bigger
IL_EX_SetSize(ILID, 100, 45) ;- set ICO size <<<<<<<<<<<<<<
LV_SetImageList(ILid,1)
LV_Delete()
LV_ModifyCol(1,T1)
LV_ModifyCol(2,T2)
LV_ModifyCol(3,T3)
pict05:=""
loop,read,%F12%
{
c1=
c2=
c3=
stringsplit,c,A_LoopReadLine,`;,
SplitPath,c2,,,ext2,,
IconNumber := IL_Add(ILid, "%pict05%" ) ;- picture which not exist
;IL_Add(ImageListID, Filename [, IconNumber, ResizeNonIcon])
EXEX1=txt
if EXT2 in %EXEX1%
IconNumber := IL_Add(ILid,png1) ;-
EXEX1b=csv
if EXT2 in %EXEX1b%
IconNumber := IL_Add(ILid,png2 )
EXEX2=exe,dll,cpl,msc,chm
if EXT2 in %EXEX2%
IconNumber := IL_Add(ILid,c2 ) ;- original ico from exe file
LV_Add("icon" . iconnumber ,c1,c2,c3)
}
Gui,2: Show, x0 y50 w%t2a% h270, TEST ICONS
return
2Guiclose:
exitapp
;------------------------------
MLV2:
GuiControlGet,MLV1
LV_GetText(C2,A_EventInfo,2)
if A_GuiEvent=normal
run,%C2%
return
;-------------------------------
;----------- functiom from user 'just me' --------
;- https://github.com/AHK-just-me/IL_EX IL_EX LIB
; IL_EX_SetSize(ILID, W, H)
; Function: Sets the dimensions of images in an image list and removes all images from the list.
; Parameters: W - The width, in pixels, of all images in the image list.
; H - The height, in pixels, of all images in the image list.
; Return values: Returns nonzero if successful, or zero otherwise.
; MSDN: http://msdn.microsoft.com/en-us/library/bb775224(VS.85).aspx
; Remarks: All images in an image list have the same dimensions.
; ======================================================================================================================
IL_EX_SetSize(ILID, W, H) {
Return DllCall("ComCtl32.dll\ImageList_SetIconSize", "Ptr", ILID, "Int", W, "Int", H, "Int")
}
;========================================================================
Re: 请问,ListView的单元格内容中有"`n"换行符,为什么输出时内容还是在一行显示?
谢谢,这代码可以在Win7上运行,但是在XP上不行,看了一下MSDN,ImageList_Create最早支持到Windows Vista,还有别的办法没?tmplinshi wrote: ↑10 Dec 2018, 02:28可以这样:
Code: Select all
Gui, Add, ListView, w600 h300 Grid, col1 lvCtrl_SetRowHeight(50) LV_Add("", "line1`nline2") Gui, Show Return GuiClose: ExitApp lvCtrl_SetRowHeight(Height) { LV_SetImageList( DllCall( "ImageList_Create", Int,2, Int, Height, Int,0x18, Int,1, Int,1 ), 1 ) }
Re: 请问,ListView的单元格内容中有"`n"换行符,为什么输出时内容还是在一行显示?
谢谢,我试试garry wrote: ↑10 Dec 2018, 05:35EDIT : solved from user 'just me' 20181210 20:15 UTC
谢谢你,更大的ico的想法? ( bigger ICO without library )
https://autohotkey.com/boards/viewtopic.php?f=9&t=59791
https://autohotkey.com/boards/viewtopic.php?f=6&t=1256 just me LV_EX LIB
solved from user 'just me' :
Listview: added ICO with defined size with a part from :
https://github.com/AHK-just-me/IL_EX IL_EX LIB
IL_EX_SetSize(ILID, W, H)
Code: Select all
;- Listview added ICO with defined size ;- LV_ICO_TEST > put the ico "032_neu_PDF_niO.png" in subfolder ICO ; "042_nix_PDF_niO.png" ;----------------------------------------------------------------------------------------------------------- ;- https://autohotkey.com/boards/viewtopic.php?f=6&t=1256 just me LV_EX LIB ;- https://autohotkey.com/boards/viewtopic.php?f=6&t=1273 ;- https://github.com/AHK-just-me/IL_EX IL_EX LIB ;- https://autohotkey.com/boards/viewtopic.php?f=9&t=59791 german question for bigger ICOn's ;- https://autohotkey.com/boards/download/file.php?id=6127 download ICO for test ;-------------------------------------------------------- #warn #noenv #SingleInstance force setworkingdir, %a_scriptdir% Gui,2:default Gui,2: -DPIScale Gui,2:Font,CDefault s14 , Lucida Console transform,s,chr,10 ;----------------- TEST ------------------------- R3ICO=%A_scriptDir%\ICO ;- put your icons here ifnotexist,%R3ICO% FileCreateDir,%R3ICO% png1:=r3ico . "\032_neu_PDF_niO.png" ;- for test png2:=r3ico . "\042_nix_PDF_niO.png" fx=%a_scriptdir%\test55.txt ifnotexist,%fx% fileappend,Line1`r`n,%fx% fn=%a_scriptdir%\test56.csv ifnotexist,%fn% fileappend,Line1`r`n,%fn% F12=%A_ScriptDir%\test.csv ;example ;filedelete,%f12% ifnotexist,%F12% { fileappend,CALC;C:\windows\system32\calc.exe;`r`n,%f12% fileappend,TEST;test55.txt;`r`n,%f12% fileappend,TEST;test56.csv;`r`n,%f12% } ;----------------------------------------------- T1=300 T2=630 T3=0 T1K:=T1 T2K:=T1+T2+50 T2A:=T1+T2+70 Gui,2:Add, ListView, backgroundSilver grid x3 y10 h240 w%t2k% +hscroll altsubmit vMLV1 gMLV2, AA|BB|CC ILid := IL_Create(1,1,0) ;- small ;ILid := IL_Create(1,1,1) ;- bigger IL_EX_SetSize(ILID, 100, 45) ;- set ICO size <<<<<<<<<<<<<< LV_SetImageList(ILid,1) LV_Delete() LV_ModifyCol(1,T1) LV_ModifyCol(2,T2) LV_ModifyCol(3,T3) pict05:="" loop,read,%F12% { c1= c2= c3= stringsplit,c,A_LoopReadLine,`;, SplitPath,c2,,,ext2,, IconNumber := IL_Add(ILid, "%pict05%" ) ;- picture which not exist ;IL_Add(ImageListID, Filename [, IconNumber, ResizeNonIcon]) EXEX1=txt if EXT2 in %EXEX1% IconNumber := IL_Add(ILid,png1) ;- EXEX1b=csv if EXT2 in %EXEX1b% IconNumber := IL_Add(ILid,png2 ) EXEX2=exe,dll,cpl,msc,chm if EXT2 in %EXEX2% IconNumber := IL_Add(ILid,c2 ) ;- original ico from exe file LV_Add("icon" . iconnumber ,c1,c2,c3) } Gui,2: Show, x0 y50 w%t2a% h270, TEST ICONS return 2Guiclose: exitapp ;------------------------------ MLV2: GuiControlGet,MLV1 LV_GetText(C2,A_EventInfo,2) if A_GuiEvent=normal run,%C2% return ;------------------------------- ;----------- functiom from user 'just me' -------- ;- https://github.com/AHK-just-me/IL_EX IL_EX LIB ; IL_EX_SetSize(ILID, W, H) ; Function: Sets the dimensions of images in an image list and removes all images from the list. ; Parameters: W - The width, in pixels, of all images in the image list. ; H - The height, in pixels, of all images in the image list. ; Return values: Returns nonzero if successful, or zero otherwise. ; MSDN: http://msdn.microsoft.com/en-us/library/bb775224(VS.85).aspx ; Remarks: All images in an image list have the same dimensions. ; ====================================================================================================================== IL_EX_SetSize(ILID, W, H) { Return DllCall("ComCtl32.dll\ImageList_SetIconSize", "Ptr", ILID, "Int", W, "Int", H, "Int") } ;========================================================================
Who is online
Users browsing this forum: No registered users and 49 guests