// TODO: Add extra initialization. m_cMyEdit.SetWindowText("My Name"); // Initialize control values. m_cMyList.ShowWindow(SW_HIDE); // Show or hide a control, etc. return TRUE; // Return TRUE unless you set the focus to a control. // EXCEPTION: OCX Property Pages should return FALSE }
如上:// Return TRUE unless you set the focus to a control.当你要改变默认的控件焦点时,return FALSE;
改成这样: case WM_INITDIALOG: hInst = (HINSTANCE)GetWindowLong(hDlg, GWL_HINSTANCE);
而不是 return TRUE;
case WM_INITDIALOG:
hInst = (HINSTANCE)GetWindowLong(hDlg, GWL_HINSTANCE);
SetFocus(GetDlgItem(hDlg, IDC_CardNum)); // 设置输入焦点
hwndInfo = CreateWindow("STATIC", "", WS_VISIBLE | WS_CHILD, 80, 130, 100, 20,
hDlg, NULL, hInst, NULL);
return FALSE;
#include "MyDialog.h"BOOL CMyDialog::OnInitDialog()
{
CDialog::OnInitDialog();
// TODO: Add extra initialization.
m_cMyEdit.SetWindowText("My Name"); // Initialize control values.
m_cMyList.ShowWindow(SW_HIDE); // Show or hide a control, etc. return TRUE; // Return TRUE unless you set the focus to a control.
// EXCEPTION: OCX Property Pages should return FALSE
}
case WM_INITDIALOG:
hInst = (HINSTANCE)GetWindowLong(hDlg, GWL_HINSTANCE);
hwndInfo = CreateWindow("STATIC", "", WS_VISIBLE | WS_CHILD, 80, 130, 100, 20,
hDlg, NULL, hInst, NULL);
SetFocus(GetDlgItem(hDlg, IDC_CardNum)); // 设置输入焦点
return FALSE;
另外我没用MFC,只用Win API,然后处理窗口消息。有没有可能是什么消息没处理好?
在托盘上加了图标之后,有两个方式打开对话框:
1 直接左键单击图标;
2 右键单击图标弹出菜单,再选择弹出对话框。
如果是第一种方式弹出的对话框Tab键就无效,第二种方式就没问题。为什么会这样呢?
PS:由于一个账号最多只能连续回复3次,所以只能注册一个新的来说明情况~~。