回复 5# yamakawa
官方 已經有人回覆 有範例在
可是 老實說 我大概懂他在幹嘛 但是我無法改成 可以融入我的 程式
又不好意思 跟 老外問太多 所以只好上來這 找你幫忙 我覺得 你的程式功力應該比我好
呵呵
大概看得出來 他是
; Subclass ListView to receive keyboard/mouse messages
Local $pListViewFunc = DllCallbackGetPtr( DllCallbackRegister( "ListViewFunc", "lresult", "hwnd;uint;wparam;lparam;uint_ptr;dword_ptr" ) )
_WinAPI_SetWindowSubclass( $hListView, $pListViewFunc, 0, 0 ) ; $iSubclassId = 0, $pData = 0
註冊了一個子消息之類的 然後再利用那個 ListViewFunc 去控制
我常用的是 3.3.8 的程式
這個範例我改用 v3.3.8 的主程式 V3.3.14 的API 功能 .... 無法執行成功 畫面會不見 整個程式GUI 都出不來....
也就是說 我如果要用這個方法就得 改用新版的主程式
但是 我的東西太多了 不想改主程式版本
但是要把下面的範例改成 V3.3.8 可以用的 我又改不出來...
所以無法測試 ..........
不知道您是否可以幫忙 改成 3.38 可以RUN 我在測試看看怎麼融入我的程式裡面
唉 一堆的想法 想用英文表達 還真是困難~~~
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <WinAPIShellEx.au3>
;#include <WinAPI.au3>
#include <GuiListView.au3>
Opt( "MustDeclareVars", 1 )
Global $idListView, $idAddSingleSel, $idDelSingleSel
Example()
Func Example()
; Create GUI
GUICreate( "ctrl+single-click --> single-click", 420, 200 )
; Create ListView
$idListView = GUICtrlCreateListView( "", 10, 10, 400, 180, $GUI_SS_DEFAULT_LISTVIEW-$LVS_SINGLESEL, $WS_EX_CLIENTEDGE )
_GUICtrlListView_SetExtendedListViewStyle( $idListView, $LVS_EX_DOUBLEBUFFER+$LVS_EX_FULLROWSELECT )
Local $hListView = GUICtrlGetHandle( $idListView )
; Add columns to ListView
_GUICtrlListView_InsertColumn( $idListView, 0, "Column 1", 94 )
_GUICtrlListView_InsertColumn( $idListView, 1, "Column 2", 94 )
_GUICtrlListView_InsertColumn( $idListView, 2, "Column 3", 94 )
_GUICtrlListView_InsertColumn( $idListView, 3, "Column 4", 94 )
; Fill ListView
Local $iItems = 100
For $i = 0 To $iItems - 1
GUICtrlCreateListViewItem( $i & "/Column 1|" & $i & "/Column 2|" & $i & "/Column 3|" & $i & "/Column 4", $idListView )
Next
; Subclass ListView to receive keyboard/mouse messages
Local $pListViewFunc = DllCallbackGetPtr( DllCallbackRegister( "ListViewFunc", "lresult", "hwnd;uint;wparam;lparam;uint_ptr;dword_ptr" ) )
_WinAPI_SetWindowSubclass( $hListView, $pListViewFunc, 0, 0 ) ; $iSubclassId = 0, $pData = 0
; Add/del single selection
$idAddSingleSel = GUICtrlCreateDummy()
$idDelSingleSel = GUICtrlCreateDummy()
Local $iItem
; Show GUI
GUISetState( @SW_SHOW )
; Message loop
While 1
Switch GUIGetMsg()
Case $idAddSingleSel
$iItem = GUICtrlRead( $idAddSingleSel )
_GUICtrlListView_SetItemSelected( $idListView, $iItem, True )
_GUICtrlListView_SetItemFocused( $idListView, $iItem )
Case $idDelSingleSel
$iItem = GUICtrlRead( $idDelSingleSel )
_GUICtrlListView_SetItemSelected( $idListView, $iItem, False )
_GUICtrlListView_SetItemFocused( $idListView, $iItem )
Case $GUI_EVENT_CLOSE
ExitLoop
EndSwitch
WEnd
; Cleanup
_WinAPI_RemoveWindowSubclass( $hListView, $pListViewFunc, 0 )
GUIDelete()
EndFunc
Func ListViewFunc( $hWnd, $iMsg, $wParam, $lParam, $iSubclassId, $pData )
If $iMsg <> $WM_LBUTTONDOWN Then Return DllCall( "comctl32.dll", "lresult", "DefSubclassProc", "hwnd", $hWnd, "uint", $iMsg, "wparam", $wParam, "lparam", $lParam )[0]
Switch $wParam
Case 0x0001 ; 0x0001 = MK_LBUTTON (LButton down)
If _GUICtrlListView_GetSelectedCount( $idListView ) Then
Local $aHit = _GUICtrlListView_HitTest( GUICtrlGetHandle( $idListView ), BitAND( $lParam, 0xFFFF ), BitShift( $lParam, 16 ) )
If Not ( @error Or $aHit[0] = -1 ) Then
If _GUICtrlListView_GetItemSelected( $idListView, $aHit[0] ) Then
GUICtrlSendToDummy( $idDelSingleSel, $aHit[0] )
Else
GUICtrlSendToDummy( $idAddSingleSel, $aHit[0] )
EndIf
EndIf
Return 0 ; Disable single-click in ListView to prevent resetting selections
EndIf
Case 0x0009 ; 0x0009 = MK_LBUTTON (LButton down) + MK_CONTROL (Ctrl down)
Return 0 ; Disable single selections in ListView with ctrl+single-click
EndSwitch
Return DllCall( "comctl32.dll", "lresult", "DefSubclassProc", "hwnd", $hWnd, "uint", $iMsg, "wparam", $wParam, "lparam", $lParam )[0]
; Call next function in subclass chain (this forwards messages to main GUI)
#forceref $iSubclassId, $pData
EndFunc
|