15,979
社区成员
发帖
与我相关
我的任务
分享
void CNetxeditDlg::OnBtn1()
{
// TODO: Add your control notification handler code here
MessageBox("Button1");
}
void CNetxeditDlg::OnOK()
{
GetNextDlgTabItem(GetFocus())->SetFocus();
}
MSG msg = {0};
msg.hwnd = ::GetFocus();
msg.message = WM_KEYDOWN;
msg.wParam = VK_TAB;
IsDialogMessage(&msg);
case WM_KEYDOWN:
// Check for keys that need this processing such as the
// TAB and arrow keys.
if ( (wParam == VK_TAB) ||
(wParam == VK_DOWN) || (wParam == VK_UP) ||
(wParam == VK_RIGHT) || (wParam == VK_LEFT) )
{
// Set the focus to the first control, Button #1
// in this case.
hwndBtn1 = GetDlgItem(hParentDlg,IDBUTTON1);
SetFocus(hwndBtn1);
// Loop through all the controls and remove the
// dark border that the previous default push
// button has.
hwndCtrls = GetWindow(hParentDlg, GW_CHILD);
while (hwndCtrls)
{
wRet = (WORD)(DWORD)SendMessage(hwndCtrls,
WM_GETDLGCODE, 0, 0L);
if (wRet & DLGC_DEFPUSHBUTTON)
SendMessage(hwndCtrls, BM_SETSTYLE,
(WPARAM)BS_PUSHBUTTON, TRUE);
hwndCtrls = GetWindow(hwndCtrls, GW_HWNDNEXT);
}
// Give the hwndBtn1 button the default push button
// border.
SendMessage(hwndBtn1, BM_SETSTYLE,
(WPARAM)BS_DEFPUSHBUTTON, TRUE);
return(0L);
}
break;
if(GetFocus()->GetDlgCtrlID() == IDC_BUTTON1)
{
CButton* pBtn = (CButton*)GetFocus();
pBtn->SetButtonStyle(BS_DEFPUSHBUTTON, TRUE);
}