回复 14# cxm23
你在指定位置创建不就行了,难道都是按个人的需求写好的吗
如果真想在listview中创建,就像happy那样 哇这个新东西哦没见过 支持下 記得官網有看過,但沒有下拉。
這個是另一種例子。
http://www.autoitscript.com/forum/topic/38313-simple-grid-of-input-controls-in-au3/ 本帖最后由 netegg 于 2012-5-22 11:19 编辑
#include <Constants.au3>
#include <GUIConstantsEx.au3>
#include <GUIComboBox.au3>
#include <GUIListView.au3>
#include <WindowsConstants.au3>
Opt('GUIOnEventMode', 1)
Dim $hGUI = GUICreate('Test', 300, 200)
Dim $ListView = GUICtrlCreateListView('A|B|C', 0, 0, 300, 200, $LVS_NOSORTHEADER)
Dim $hListView = GUICtrlGetHandle($ListView)
Dim $hHeader = _GUICtrlListView_GetHeader($hListView)
Dim $hComboBox = _GUICtrlComboBox_Create($hListView, 'A|B|C|D', 0, 0)
Dim $hProc = DllCallbackRegister('_ListViewHandler', 'lresult', 'hwnd;uint;wparam;lparam')
Dim $pProc = DllCallbackGetPtr($hProc)
Dim $hListViewProc = _WinAPI_SetWindowLong($hListView, $GWL_WNDPROC, $pProc)
Dim $iItem = -1, $iSubitem = -1
_WinAPI_ShowWindow($hComboBox, @SW_HIDE)
_GUICtrlListView_SetExtendedListViewStyle($hListView, BitOR($LVS_EX_DOUBLEBUFFER, $LVS_EX_GRIDLINES))
_GUICtrlListView_SetColumnWidth($hListView, 0, 100)
_GUICtrlListView_SetColumnWidth($hListView, 1, 100)
_GUICtrlListView_SetColumnWidth($hListView, 2, 100)
_GUICtrlListView_BeginUpdate($hListView)
For $i = 1 To 10
Local $iItem = _GUICtrlListView_AddItem($hListView, $i)
_GUICtrlListView_AddSubItem($hListView, $iItem, '', 1)
_GUICtrlListView_AddSubItem($hListView, $iItem, '', 2)
Next
_GUICtrlListView_EndUpdate($hListView)
GUISetOnEvent($GUI_EVENT_CLOSE, '_Close')
GUIRegisterMsg($WM_NOTIFY, 'WM_NOTIFY')
GUISetState()
While 1
Sleep(10)
WEnd
Func _Close()
GUIDelete()
DllCallbackFree($hProc)
Exit
EndFunc
Func WM_NOTIFY($hWnd, $iMsg, $iwParam, $ilParam)
Local $tNM = DllStructCreate($tagNMHDR, $ilParam)
Local $aSubHitTest
Local $aRect
Switch DllStructGetData($tNM, 'hWndFrom')
Case $hListView
If DllStructGetData($tNM, 'Code') = $LVN_HOTTRACK Then
$aSubHitTest = _GUICtrlListView_SubItemHitTest($hListView)
If $aSubHitTest > 0 Then
$aRect = _GUICtrlListView_GetSubItemRect($hListView, $aSubHitTest, $aSubHitTest)
_GUICtrlListView_SetItemText($hListView, $iItem, _GUICtrlComboBox_GetEditText($hComboBox), $iSubitem)
_WinAPI_ShowWindow($hComboBox, @SW_HIDE)
_WinAPI_MoveWindow($hComboBox, $aRect, $aRect, 100, 120)
_GUICtrlComboBox_SetCurSel($hComboBox, _GUICtrlComboBox_FindString($hComboBox, _GUICtrlListView_getItemText($hListView, $aSubHitTest, $aSubHitTest)))
_WinAPI_ShowWindow($hComboBox)
$iItem = $aSubHitTest
$iSubitem = $aSubHitTest
Else
_WinAPI_ShowWindow($hComboBox, @SW_HIDE)
EndIf
EndIf
Case $hHeader
Switch DllStructGetData($tNM, 'Code')
Case $HDN_BEGINTRACK, $HDN_BEGINTRACKW
Return 1
EndSwitch
EndSwitch
Return $GUI_RUNDEFMSG
EndFunc
Func _ListViewHandler($hWnd, $iMsg, $iwParam, $ilParam)
Local $aRect
Switch $iMsg
Case $WM_HSCROLL, $WS_VSCROLL
If BitAND(_WinAPI_GetWindowLong($hComboBox, $GWL_STYLE), $WS_VISIBLE) Then
$aRect = _GUICtrlListView_GetSubItemRect($hListView, $iItem, $iSubitem)
_WinAPI_MoveWindow($hComboBox, $aRect, $aRect, 100, 120)
EndIf
EndSwitch
Return _WinAPI_CallWindowProc($hListViewProc, $hWnd, $iMsg, $iwParam, $ilParam)
EndFunc
嗯,改成$LVN_HOTTRACK比$nm_click好多了 一运行CPU就彪到100%,界面出不来 回复 21# cxm23
我在win7下测试的,很正常 我表示在win7 64bit下面也正常得很!! 刚好有同样问题!
页:
1
[2]