MdiForm窗体,Combo,DataCombo和DTPicker焦点

1.MdiForm窗体有菜单,MdiForm窗体打开时,将焦点移到菜单上!  

在要顶层菜单中定义一个访问键(或热键)的按键,如常见的情况:

文件(&F)
    打开
    保存
    ...

然后写入下面的代码:
Private Sub MDIForm_Activate()
    SendKeys "%F"
End Sub

在菜单没有设置访问键时,可以这样:

Private Sub MDIForm_Load()
    SendKeys "{F10}"                '主菜单激活
    SendKeys "{F10}{DOWN}"  '主菜单激活,并显示下列菜单

End Sub

2.Combo,DataCombo和DTPicker得到焦点,自动出现下拉菜单!  

Private Const CB_SHOWDROPDOWN As Long = &H14F
Private Declare Function SendMessage Lib "user32.dll" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByRef lParam As Any) As Long

Private Sub Combo1_GotFocus()
    SendMessage Combo1.hwnd, CB_SHOWDROPDOWN, 1, 0&
End Sub

Private Sub DTPicker1_GotFocus()
    SendKeys "%{DOWN}"
End Sub

Private Sub DataCombo1_GotFocus()
    SendKeys "%{DOWN}"
End Sub

©️2020 CSDN 皮肤主题: 大白 设计师:CSDN官方博客 返回首页