WM_NOTIFY里面的Send导致键盘上的大写键失效 求解[已解决]
本帖最后由 kk_lee69 于 2018-3-13 21:57 编辑一个 LISTVIEW控件 与一个 INPUT控件,焦点切换时会触发 WM_NOTIFY里面的 $NM_SETFOCUS与 $NM_KILLFOCUS
在$NM_SETFOCUS与 $NM_KILLFOCUS 里面 分别放入 Send("{CTRLDOWN}")与Send("{CTRLUP}") 运作上本来没啥问题,但是最近发现会导致 键盘原本的大写灯号熄灭变成小写
测试 方法 请 将 键盘大写灯号打开然后 执行程序切换焦点
你就会发现 灯号熄灭 但是 从程序代码来看 应该不会导致这样的结果才对
求解但是 要求 Send("{CTRLDOWN}")与Send("{CTRLUP}") 程序代码位置不能更动 只能放在 $NM_SETFOCUS与 $NM_KILLFOCUS 里面
不知道 是否有高手 愿意协助解决!!
程式碼 如下:
#include <GUIConstantsEx.au3>
#include <ListViewConstants.au3>
#include <WindowsConstants.au3>
#Include <GuiListView.au3>
$Debug_LV = False ;<<<<<<<<<+++
Global $ListView, $B_DESCENDING
_Example1()
Func _Example1()
Local $iExWindowStyle = BitOR($WS_EX_DLGMODALFRAME, $WS_EX_CLIENTEDGE);<<<<<<<<<+++
Local $iExListViewStyle = BitOR($LVS_EX_FULLROWSELECT, $LVS_EX_SUBITEMIMAGES, $LVS_EX_GRIDLINES, $LVS_EX_CHECKBOXES, $LVS_EX_DOUBLEBUFFER);<<<<<<<<<+++
GUICreate('升?或降序', 633, 454, 192, 114)
$ListView = GUICtrlCreateListView("", 10,10, 430, 300)
GUICtrlSendMsg($ListView, $LVM_SETEXTENDEDLISTVIEWSTYLE, $LVS_EX_GRIDLINES, $LVS_EX_GRIDLINES);<<<<<<<<<+++
GUICtrlSendMsg($ListView, $LVM_SETEXTENDEDLISTVIEWSTYLE, $LVS_EX_FULLROWSELECT, $LVS_EX_FULLROWSELECT);<<<<<<<<<+++
_GUICtrlListView_AddColumn($ListView, "A", 100)
_GUICtrlListView_AddColumn($ListView, "B", 100)
_GUICtrlListView_AddColumn($ListView, "C", 100)
_GUICtrlListView_AddColumn($ListView, "D", 100)
_GUICtrlListView_JustifyColumn($ListView, 0, 2)
_GUICtrlListView_JustifyColumn($ListView, 1, 2)
_GUICtrlListView_JustifyColumn($ListView, 2, 2)
_GUICtrlListView_JustifyColumn($ListView, 3, 2)
GUICtrlCreateListViewItem("1|5|e|", $ListView)
GUICtrlCreateListViewItem("2|3|ee|", $ListView)
GUICtrlCreateListViewItem("3|8|eg|", $ListView)
GUICtrlCreateListViewItem("4|7|eg|", $ListView)
GUICtrlCreateListViewItem("5|6|ej|", $ListView)
GUICtrlCreateListViewItem("6|5|ek|", $ListView)
GUICtrlCreateListViewItem("7|2|le|", $ListView)
GUICtrlCreateListViewItem("8|1|je|", $ListView)
GUICtrlCreateInput("", 10, 320, 300, 20)
GUISetState()
GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY");<<<<<<<<<+++
Global $B_DESCENDING;<<<<<<<<<+++
Do;<<<<<<<<<+++
Until GUIGetMsg() = $GUI_EVENT_CLOSE
GUIDelete()
EndFunc
Func WM_NOTIFY($hWnd, $iMsg, $iwParam, $ilParam);<<<<<<<<<+++
#forceref $hWnd, $iMsg, $iwParam
Local $hWndFrom, $iIDFrom, $iCode, $tNMHDR, $hWndListView, $tInfo
$hWndListView = $ListView
If Not IsHWnd($ListView) Then $hWndListView = GUICtrlGetHandle($ListView)
$tNMHDR = DllStructCreate($tagNMHDR, $ilParam)
$hWndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom"))
$iIDFrom = DllStructGetData($tNMHDR, "IDFrom")
$iCode = DllStructGetData($tNMHDR, "Code")
Switch $hWndFrom
Case $hWndListView
Switch $iCode
Case $LVN_COLUMNCLICK ; A column was clicked
$tInfo = DllStructCreate($tagNMLISTVIEW, $ilParam)
Case $NM_SETFOCUS ; The control has received the input focus
ConsoleWrite("按下"&@CRLF)
Send("{CTRLDOWN}") ;保持 A 鍵按下
; No return value
Case $NM_KILLFOCUS ; The control has lost the input focus
ConsoleWrite("放開"&@CRLF)
Send("{CTRLUP}") ;釋放 A 鍵
; No return value
EndSwitch
EndSwitch
Return $GUI_RUNDEFMSG
EndFunc ;==>WM_NOTIFY Opt('SendCapslockMode',0) 回复 2# haijie1223
這樣就解決了嗎?? 放在 一開始嗎?? 回复 2# haijie1223
果然是高手~~
页:
[1]