我遇到了与下面列出的帖子中描述的相同的问题。也就是说,当我在组合框中键入某些键时,它们根本不起作用,直到我第一次按下空格键。其中一个键是“.”,另一个是字母“Q”,还有其他的:“$”、“%”。
http://forums.microsoft.com/msdn/ShowPost.aspx?PostID=659716&SiteID=1
http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=2909173&SiteID=1&pageid=0
http://bytes。 com/forum/thread548399.html
到目前为止,我已经尝试了很多东西。我最近的失败是基于 DataGridView 可能使用 WIN32 API wndproc 子类化来拦截消息的理论,所以我编写了逻辑来保存旧的 wndproc 并在将其添加到 DataGridView 的控件集合后恢复它。那没有用。
墨西拿 - 感谢您提醒我有关 Spy++ 的信息。对于字母“A”,编辑窗口向其父组合框发送一个 EN_UPDATE。但是,不适用于“Q”。这太奇怪了。
我已经说服自己 DataGridView 不是组合和编辑的子类,因为我在创建之后和将它们添加到网格集合之前检查了 wndprocs 的地址,然后在我绘制时检查。除非网格安装某种全局钩子..
我在想,也许我可以子类化编辑控件,然后按照我在这里看到编辑控件的方式将通知发送到组合框?
编辑:更多信息在这里。来自 Spy++ 的网格、组合框和编辑控件的 Windows 消息:
HWNDs: 122064e < 网格 010d0674 < 组合框 01360696 < 组合框的编辑控件
<01402> 01360696 P WM_KEYDOWN nVirtKey:'A' cRepeat:1 ScanCode:1E fExtended:0 fAltDown:0 fRepeat:0 fUp:0
<01403> 010D0674 S WM_GETDLGCODE
<01404> 010D0674 R WM_GETDLGCODE fuDlgCode:DLGC_WANTARROWS | DLGC_WANTCHARS
<01405> 010D0674 S WM_GETDLGCODE
<01406> 010D0674 R WM_GETDLGCODE fuDlgCode:DLGC_WANTARROWS | DLGC_WANTCHARS
<01407> 010D0674 S WM_GETDLGCODE
<01408> 010D0674 R WM_GETDLGCODE fuDlgCode:DLGC_WANTARROWS | DLGC_WANTCHARS
<01409> 010D0674 S WM_GETDLGCODE
<01410> 010D0674 R WM_GETDLGCODE fuDlgCode:DLGC_WANTARROWS | DLGC_WANTCHARS
<01411> 01360696 P WM_CHAR chCharCode:'0061' (97) cRepeat:1 ScanCode:1E fExtended:0 fAltDown:0 fRepeat:0 fUp:0
<01412> 010D0674 S WM_GETDLGCODE
<01413> 010D0674 R WM_GETDLGCODE fuDlgCode:DLGC_WANTARROWS | DLGC_WANTCHARS
<01414> 010D0674 S WM_GETDLGCODE
<01415> 010D0674 R WM_GETDLGCODE fuDlgCode:DLGC_WANTARROWS | DLGC_WANTCHARS
<01416> 010D0674 S WM_COMMAND wNotifyCode:EN_UPDATE wID:1001 hwndCtl:01360696 <<< edit control sends to combobox
<01417> 010D0674 S message:0x2111 [User-defined:WM_USER+7441] wParam:00060674 lParam:010D0674 What do these do?
<01418> 010D0674 R message:0x2111 [User-defined:WM_USER+7441] lResult:00000000
<01419> 010D0674 R WM_COMMAND
<01420> 010D0674 S WM_CTLCOLOREDIT hdcEdit:C7011AA6 hwndEdit:01360696
<01421> 010D0674 R WM_CTLCOLOREDIT hBrush:F0103EB0
<01422> 010D0674 S WM_COMMAND wNotifyCode:EN_CHANGE wID:1001 hwndCtl:01360696 << edit control sends to combobox
<01423> 010D0674 S message:0x2111 [User-defined:WM_USER+7441] wParam:00050674 lParam:010D0674
<01424> 0122064E S WM_PAINT hdc:00000000 <<< grid is told to paint
<01425> 0122064E S WM_ERASEBKGND hdc:94011D4E
<01426> 0122064E R WM_ERASEBKGND fErased:True
<01427> 0122064E S WM_GETTEXTLENGTH
<01428> 0122064E R WM_GETTEXTLENGTH cch:0
<01429> 0122064E S WM_GETTEXT cchTextMax:2 lpszText:0012D0C0
<01430> 0122064E R WM_GETTEXT cchCopied:0 lpszText:0012D0C0 ("")
<01431> 0122064E S WM_GETTEXTLENGTH
<01432> 0122064E R WM_GETTEXTLENGTH cch:0
<01433> 0122064E S WM_GETTEXT cchTextMax:2 lpszText:0012D0C0
<01434> 0122064E R WM_GETTEXT cchCopied:0 lpszText:0012D0C0 ("")
<01435> 010D0674 S WM_WINDOWPOSCHANGING lpwp:0012D4B0
<01436> 010D0674 R WM_WINDOWPOSCHANGING
<01437> 010D0674 S CB_GETCURSEL
<01438> 010D0674 R CB_GETCURSEL index:CB_ERR
<01439> 010D0674 S WM_GETTEXTLENGTH
<01440> 01360696 S WM_GETTEXTLENGTH
<01441> 01360696 R WM_GETTEXTLENGTH cch:2
<01442> 010D0674 R WM_GETTEXTLENGTH cch:2
<01443> 010D0674 S WM_GETTEXT cchTextMax:6 lpszText:0012CC44
<01444> 01360696 S WM_GETTEXT cchTextMax:6 lpszText:0012BE64
<01445> 01360696 R WM_GETTEXT cchCopied:2 lpszText:0012BE64 ("a")
<01446> 010D0674 R WM_GETTEXT cchCopied:2 lpszText:0012CC44 ("a")
<01447> 010D0674 S CB_GETCURSEL
<01448> 010D0674 R CB_GETCURSEL index:CB_ERR
<01449> 010D0674 S WM_GETTEXTLENGTH
<01450> 01360696 S WM_GETTEXTLENGTH
<01451> 01360696 R WM_GETTEXTLENGTH cch:2
<01452> 010D0674 R WM_GETTEXTLENGTH cch:2
<01453> 010D0674 S WM_GETTEXT cchTextMax:6 lpszText:0012CC44
<01454> 01360696 S WM_GETTEXT cchTextMax:6 lpszText:0012BE64
<01455> 01360696 R WM_GETTEXT cchCopied:2 lpszText:0012BE64 ("a")
<01456> 010D0674 R WM_GETTEXT cchCopied:2 lpszText:0012CC44 ("a")
<01457> 010D0674 S CB_GETCURSEL
<01458> 010D0674 R CB_GETCURSEL index:CB_ERR
<01531> 0122064E R WM_PAINT
<01532> 010D0674 S WM_PAINT hdc:00000000
<01533> 010D0674 S WM_NCPAINT hrgn:00000001
<01534> 010D0674 R WM_NCPAINT
<01535> 010D0674 S WM_ERASEBKGND hdc:0F0141ED
<01536> 010D0674 R WM_ERASEBKGND fErased:True
<01537> 0122064E S WM_CTLCOLOREDIT hdcEdit:840137F1 hwndEdit:010D0674
<01538> 0122064E R WM_CTLCOLOREDIT hBrush:F0103EB0
<01539> 010D0674 R WM_PAINT
<01540> 01360696 S WM_PAINT hdc:00000000
<01541> 01360696 S WM_NCPAINT hrgn:00000001
<01542> 01360696 R WM_NCPAINT
<01543> 01360696 S WM_ERASEBKGND hdc:C7011AA6
<01544> 01360696 R WM_ERASEBKGND fErased:True
<01545> 010D0674 S WM_CTLCOLOREDIT hdcEdit:870137F1 hwndEdit:01360696
<01546> 010D0674 R WM_CTLCOLOREDIT hBrush:F0103EB0
<01547> 010D0674 S WM_CTLCOLOREDIT hdcEdit:870137F1 hwndEdit:01360696
<01548> 010D0674 R WM_CTLCOLOREDIT hBrush:F0103EB0
<01549> 01360696 R WM_PAINT
<01555> 0122064E S WM_CTLCOLOREDIT hdcEdit:8A0137F1 hwndEdit:010306AC
<01556> 0122064E R WM_CTLCOLOREDIT hBrush:78103C5B
<01568> 010D0674 S CB_GETCURSEL
<01569> 010D0674 R CB_GETCURSEL index:CB_ERR
<01570> 010D0674 S WM_GETTEXTLENGTH
<01571> 01360696 S WM_GETTEXTLENGTH
<01572> 01360696 R WM_GETTEXTLENGTH cch:2
<01573> 010D0674 R WM_GETTEXTLENGTH cch:2
<01574> 010D0674 S WM_GETTEXT cchTextMax:6 lpszText:0012D7A4
<01575> 01360696 S WM_GETTEXT cchTextMax:6 lpszText:0012C9C4
<01576> 01360696 R WM_GETTEXT cchCopied:2 lpszText:0012C9C4 ("a")
<01577> 010D0674 R WM_GETTEXT cchCopied:2 lpszText:0012D7A4 ("a")
<01578> 010D0674 S CB_GETCURSEL
<01579> 010D0674 R CB_GETCURSEL index:CB_ERR
<01580> 010D0674 S WM_GETTEXTLENGTH
<01581> 01360696 S WM_GETTEXTLENGTH
<01582> 01360696 R WM_GETTEXTLENGTH cch:2
<01583> 010D0674 R WM_GETTEXTLENGTH cch:2
<01584> 010D0674 S WM_GETTEXT cchTextMax:6 lpszText:0012D6E0
<01585> 01360696 S WM_GETTEXT cchTextMax:6 lpszText:0012C900
<01586> 01360696 R WM_GETTEXT cchCopied:2 lpszText:0012C900 ("a")
<01587> 010D0674 R WM_GETTEXT cchCopied:2 lpszText:0012D6E0 ("a")
<01588> 010D0674 S CB_GETCURSEL
<01589> 010D0674 R CB_GETCURSEL index:CB_ERR
<01590> 010D0674 S WM_GETTEXTLENGTH
<01591> 01360696 S WM_GETTEXTLENGTH
<01592> 01360696 R WM_GETTEXTLENGTH cch:2
<01593> 010D0674 R WM_GETTEXTLENGTH cch:2
<01594> 010D0674 S WM_GETTEXT cchTextMax:6 lpszText:0012D6E0
<01595> 01360696 S WM_GETTEXT cchTextMax:6 lpszText:0012C900
<01596> 01360696 R WM_GETTEXT cchCopied:2 lpszText:0012C900 ("a")
<01597> 010D0674 R WM_GETTEXT cchCopied:2 lpszText:0012D6E0 ("a")
<01598> 010D0674 R message:0x2111 [User-defined:WM_USER+7441] lResult:00000000
<01599> 01360696 S WM_GETTEXTLENGTH
<01600> 01360696 R WM_GETTEXTLENGTH cch:2
<01601> 01360696 S WM_GETTEXT cchTextMax:6 lpszText:0012DF8C
<01602> 01360696 R WM_GETTEXT cchCopied:2 lpszText:0012DF8C ("a")
<01603> 010D0674 R WM_COMMAND
<01604> 01360696 P WM_KEYUP nVirtKey:'A' cRepeat:1 ScanCode:1E fExtended:0 fAltDown:0 fRepeat:1 fUp:1
字母 q
<01625> 01360696 P WM_KEYDOWN nVirtKey:'Q' cRepeat:1 ScanCode:10 fExtended:0 fAltDown:0 fRepeat:0 fUp:0
<01626> 010D0674 S WM_GETDLGCODE
<01627> 010D0674 R WM_GETDLGCODE fuDlgCode:DLGC_WANTARROWS | DLGC_WANTCHARS
<01628> 010D0674 S WM_GETDLGCODE
<01629> 010D0674 R WM_GETDLGCODE fuDlgCode:DLGC_WANTARROWS | DLGC_WANTCHARS
<01630> 010D0674 S WM_GETDLGCODE
<01631> 010D0674 R WM_GETDLGCODE fuDlgCode:DLGC_WANTARROWS | DLGC_WANTCHARS
<01632> 010D0674 S WM_GETDLGCODE
<01633> 010D0674 R WM_GETDLGCODE fuDlgCode:DLGC_WANTARROWS | DLGC_WANTCHARS
<01634> 01360696 P WM_CHAR chCharCode:'0071' (113) cRepeat:1 ScanCode:10 fExtended:0 fAltDown:0 fRepeat:0 fUp:0
<01635> 010D0674 S WM_GETDLGCODE
<01636> 010D0674 R WM_GETDLGCODE fuDlgCode:DLGC_WANTARROWS | DLGC_WANTCHARS
<01637> 010D0674 S WM_GETDLGCODE
<01638> 010D0674 R WM_GETDLGCODE fuDlgCode:DLGC_WANTARROWS | DLGC_WANTCHARS
<01640> 01360696 P WM_KEYUP nVirtKey:'Q' cRepeat:1 ScanCode:10 fExtended:0 fAltDown:0 fRepeat:1 fUp:1