📄 dialogwm.cpp
字号:
// DialogWM.cpp : 实现文件
//
#include "stdafx.h"
#include "DartScore.h"
#include "DialogWM.h"
#include <tpcshell.h> // for SHSendBackToFocusWindow()
// CDialogWM 对话框
IMPLEMENT_DYNAMIC(CDialogWM, CDialog)
CDialogWM::CDialogWM ( UINT nDialogID, UINT nMenuID, CWnd* pParent /*=NULL*/)
: CDialog(nDialogID, pParent)
, m_nMenuID ( nMenuID )
, m_bInited ( FALSE )
{
SetWaitCursor ();
}
CDialogWM::~CDialogWM()
{
}
void CDialogWM::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
}
BEGIN_MESSAGE_MAP(CDialogWM, CDialog)
ON_WM_TIMER()
END_MESSAGE_MAP()
// CDialogWM 消息处理程序
BOOL CDialogWM::OnInitDialog()
{
CDialog::OnInitDialog();
#ifdef WIN32_PLATFORM_WFSP
if (!m_dlgCommandBar.Create(this) ||
!m_dlgCommandBar.InsertMenuBar(m_nMenuID))
{
TRACE0("Failed to create CommandBar\n");
return FALSE; // fail to create
}
#endif // WIN32_PLATFORM_WFSP
SetTimer ( CDialogWM_TIMERID_INITED, 10, NULL );
return TRUE; // return TRUE unless you set the focus to a control
// 异常: OCX 属性页应返回 FALSE
}
void CDialogWM::OnTimer(UINT_PTR nIDEvent)
{
switch ( nIDEvent )
{
case CDialogWM_TIMERID_INITED:
{
KillTimer ( nIDEvent );
CenterWindow ();
OnInit ();
break;
}
}
CDialog::OnTimer(nIDEvent);
}
void CDialogWM::OnInit(void)
{
RestoreCursor ();
SetCtrlValue ();
m_bInited = TRUE;
}
void CDialogWM::SetCtrlValue(void)
{
}
BOOL CDialogWM::GetCtrlValue(void)
{
return TRUE;
}
void CDialogWM::OnOK(void)
{
if ( !GetCtrlValue() ) return;
CDialog::OnOK ();
}
BOOL CDialogWM::PreTranslateMessage(MSG* pMsg)
{
// 以下代码是让编辑框能响应 BACK 按键,删除输入的字符
if ( pMsg->message == WM_HOTKEY )
{
if ( HIWORD(pMsg->lParam) == VK_TBACK )
{
SHSendBackToFocusWindow ( WM_HOTKEY, pMsg->wParam, pMsg->lParam );
return TRUE;
}
}
// 处理回车键,如果是 Edit、ListBox、ComboBox 等 控件上按回车键直接跳到下一个控件
else if ( (pMsg->message == WM_KEYDOWN) && pMsg->wParam == 0x0d && m_bInited )
{
CWnd *pWndFocus = GetFocus ();
TCHAR szClassName[256] = {0};
GetClassName ( pWndFocus->GetSafeHwnd(), szClassName, 256 );
if ( lstrcmpi(szClassName, _T("Edit")) == 0 || lstrcmpi(szClassName, _T("ListBox")) == 0 ||
lstrcmpi(szClassName, _T("ComboBox")) == 0 || lstrcmpi(szClassName, _T("SysListView32")) == 0 )
{
CWnd *pWndNext = GetNextDlgTabItem ( pWndFocus );
if ( pWndNext ) pWndNext->SetFocus ();
return TRUE;
}
}
return CDialog::PreTranslateMessage(pMsg);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -