GUICtrlCreateListView怎么在项目内换行1000论坛币求助
本帖最后由 黑色袜子 于 2013-8-20 23:29 编辑解决了。再次感谢 破帽遮颜 不知道怎么称呼UID12的压力好大。哈哈,顺便感谢下小海牛。他给我的大洋。不然我也没那么豁达。哈哈#include <GUIConstantsEx.au3>
#include <ListViewConstants.au3>
#include <WindowsConstants.au3>
#include <GuiListView.au3>
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 615, 438, 192, 124)
$hListView = GUICtrlCreateListView("", 56, 56, 442, 326)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
_GUICtrlListView_InsertColumn($hListView, 0, "Column 1", 400)
_GUICtrlListView_InsertItem($hListView, "第一项目第一行"&@crlf&"第一项目第二行crlf无效", -1)
_GUICtrlListView_InsertItem($hListView, "第2项目第一行"&@crlf&"第2项目第二行crlf无效",-1)
_GUICtrlListView_InsertItem($hListView, "最好能设置项目的高度", -1)
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
EndSwitch
WEnd
昨天发了个GUICtrlCreateList的没得到解决,现在我换了GUICtrlCreateListView控件。
因为那个贴子无法弄悬赏的,就再开了个贴子。斑竹谅解下!
#include <GuiConstantsEx.au3>
#include <GuiListView.au3>
#include <GuiImageList.au3>
#include <WindowsConstants.au3>
Opt('MustDeclareVars', 1)
Global Const $LVTVIF_AUTOSIZE = 0x00000000
Global Const $LVTVIF_FIXEDWIDTH = 0x00000001
Global Const $LVTVIF_FIXEDHEIGHT = 0x00000002
Global Const $LVTVIF_FIXEDSIZE = 0x00000003
Global Const $LVTVIF_EXTENDED = 0x00000004
Global Const $LVTVIM_TILESIZE = 0x00000001
Global Const $LVTVIM_COLUMNS = 0x00000002
Global Const $LVTVIM_LABELMARGIN = 0x00000004
Global Const $tagLVTILEINFO = "uint Size; int Item; uint Count; ptr Columns; ptr ColFmt"
Global Const $tagLVTILEVIEWINFO = "uint Size; dword Mask; dword Flags; " & $tagSIZE & "; int Lines; " & $tagRECT
_Main()
Func _Main()
Local $hGUI, $hListView, $aiSize
$hGUI = GUICreate("ListView get tile size", 400, 300)
$hListView = _GUICtrlListView_Create($hGUI, "Item|Price", 2, 2, 394, 268)
_GUICtrlListView_SetView($hListView, 4)
_GUICtrlListView_SetTileSize($hListView, 390, 50)
_AddItem($hListView, "第一项目第二行crlf无效"&@CRLF&'第二行', '??')
_AddItem($hListView, "11111111111111111111111111111111"&@CRLF&'换行换行', '??')
GUISetState()
While 1
Switch GUIGetMsg()
Case $GUI_EVENT_CLOSE
ExitLoop
EndSwitch
WEnd
GUIDelete()
EndFunc
Func _AddItem($hWnd, $sItem, $sPrice)
Local $iItem, $aiCols
$iItem = _GUICtrlListView_AddItem($hWnd, $sItem)
_GUICtrlListView_AddSubItem($hWnd, $iItem, $sPrice, 1)
$aiCols = 1
_GUICtrlListView_SetTileInfo($hWnd, $iItem, $aiCols)
EndFunc
Func _GUICtrlListView_SetTileSize($hWnd, $iTileWidth = Default, $iTileHeight = Default)
If $Debug_LV Then __UDF_ValidateClassName($hWnd, $__LISTVIEWCONSTANT_ClassName)
Local $tLVTVI, $iFlags, $fResult
$tLVTVI = DllStructCreate($tagLVTILEVIEWINFO)
DllStructSetData($tLVTVI, "Size", DllStructGetSize($tLVTVI))
DllStructSetData($tLVTVI, "Mask", $LVTVIM_TILESIZE)
$iFlags = $LVTVIF_AUTOSIZE
If $iTileWidth <> Default Then
$iFlags = BitOR($iFlags, $LVTVIF_FIXEDWIDTH)
DllStructSetData($tLVTVI, "X", $iTileWidth)
EndIf
If $iTileHeight <> Default Then
$iFlags = BitOR($iFlags, $LVTVIF_FIXEDHEIGHT)
DllStructSetData($tLVTVI, "Y", $iTileHeight)
EndIf
DllStructSetData($tLVTVI, "Flags", $iFlags)
If Not IsHWnd($hWnd) Then
$fResult = GUICtrlSendMsg($hWnd, $LVM_SETTILEVIEWINFO, 0, DllStructGetPtr($tLVTVI))
Else
$fResult = _SendMessage($hWnd, $LVM_SETTILEVIEWINFO, 0, DllStructGetPtr($tLVTVI))
EndIf
Return $fResult <> 0
EndFunc
Func _GUICtrlListView_GetTileSize($hWnd)
If $Debug_LV Then __UDF_ValidateClassName($hWnd, $__LISTVIEWCONSTANT_ClassName)
Local $tLVTVI, $fResult, $aRet
$tLVTVI = DllStructCreate($tagLVTILEVIEWINFO)
DllStructSetData($tLVTVI, "Size", DllStructGetSize($tLVTVI))
DllStructSetData($tLVTVI, "Mask", $LVTVIM_TILESIZE)
If Not IsHWnd($hWnd) Then
$fResult = GUICtrlSendMsg($hWnd, $LVM_GETTILEVIEWINFO, 0, DllStructGetPtr($tLVTVI))
Else
$fResult = _SendMessage($hWnd, $LVM_GETTILEVIEWINFO, 0, DllStructGetPtr($tLVTVI))
EndIf
If Not $fResult Then Return SetError(1, 0, 0)
If BitAND(DllStructGetData($tLVTVI, "Flags"), $LVTVIF_FIXEDWIDTH) Then
$aRet = DllStructGetData($tLVTVI, "X")
Else
$aRet = Default
EndIf
If BitAND(DllStructGetData($tLVTVI, "Flags"), $LVTVIF_FIXEDHEIGHT) Then
$aRet = DllStructGetData($tLVTVI, "Y")
Else
$aRet = Default
EndIf
Return $aRet
EndFunc
Func _GUICtrlListView_SetTileInfo($hWnd, $iItem, $aiCols, $iStart = 0)
If $Debug_LV Then __UDF_ValidateClassName($hWnd, $__LISTVIEWCONSTANT_ClassName)
Local $tLVTI, $tCols, $fResult
$tLVTI = DllStructCreate($tagLVTILEINFO)
DllStructSetData($tLVTI, "Size", DllStructGetSize($tLVTI))
DllStructSetData($tLVTI, "Item", $iItem)
DllStructSetData($tLVTI, "Count", UBound($aiCols) - $iStart)
$tCols = DllStructCreate("uint[" & (UBound($aiCols) - $iStart) & "]")
For $i = $iStart To UBound($aiCols) - 1
DllStructSetData($tCols, 1, Int($aiCols[$i]), $i - $iStart + 1)
Next
DllStructSetData($tLVTI, "Columns", DllStructGetPtr($tCols))
If Not IsHWnd($hWnd) Then
$fResult = GUICtrlSendMsg($hWnd, $LVM_SETTILEINFO, 0, DllStructGetPtr($tLVTI))
Else
$fResult = _SendMessage($hWnd, $LVM_SETTILEINFO, 0, DllStructGetPtr($tLVTI))
EndIf
Return $fResult <> 0
EndFunc _GUICtrlListView_SetView($hListView, 4)
这个可以达到我的效果,但是设置不了宽度。 没金币了~来求楼主贡献点。{:face (88):} 回复 3# 破帽遮颜
很有创意的代码 回复 4# 破帽遮颜
还有个小问题:
能不能搞3行以及3行以上的?我刚才测试了下没搞出来。汗。 回复 6# 黑色袜子
如果需要多行的话,建议自绘吧。
关于这种我有一个收藏代码,P大的,自绘view控件
回复 7# 破帽遮颜
谢谢了。不知道钱到账没? 呵呵~一直抽着没钱呢~现在有了,谢谢楼主 回复 9# 破帽遮颜
哈哈,是我谢谢你才对,还有个问题,就是GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY")无效了。
还有就是$menu = GUICtrlCreateContextMenu($ListView1)这个菜单也没了。汗 回复 9# 破帽遮颜
解决了。不好意思,我用回GUICtrlCreateListView这个函数创建就OK了 可以去官网找哈
页:
[1]