本帖最后由 Ycxw2008 于 2013-12-1 23:00 编辑
给个子类化的例子,
应该有更好的方法.#include <WinAPIEx.au3>
#include <APIConstants.au3>
#include <GuiTreeView.au3>
Local $hWnd = GUICreate('', 222, 222, 111, 111, $WS_VISIBLE + $WS_POPUP)
Local $tree = GUICtrlCreateTreeView(0, 0, 222, 222), $hTree = GUICtrlGetHandle($tree)
For $i = 97 To 122
GUICtrlCreateTreeViewItem('_' & Chr($i), $tree)
Next
Global $wProcNew = DllCallbackRegister("_MyWindowProc", "ptr", "hwnd;uint;long;ptr")
Global $wProcOld = _WinAPI_SetWindowLong($hTree, $GWL_WNDPROC, DllCallbackGetPtr($wProcNew))
GUISetState()
While GUIGetMsg() <> -3
Sleep(10)
WEnd
Func _MyWindowProc($hWnd, $Msg, $wParam, $lParam)
Switch $Msg
Case $WM_CHAR
Local $hItem = _GUICtrlTreeView_FindItem($hWnd, '_' & Chr($wParam))
ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $hItem = ' & $hItem & @CRLF) ;### Debug Console
If $hItem Then _GUICtrlTreeView_SelectItem($hWnd, $hItem, $TVGN_CARET)
EndSwitch
Return _WinAPI_CallWindowProc($wProcOld, $hWnd, $Msg, $wParam, $lParam)
EndFunc ;==>_MyWindowProc
|