📄 dialogex.cpp
字号:
// DialogEx.cpp : implementation file
////////////////////////////////////////////////////////////////////
#include "stdafx.h"
#include "DialogEx.h"
////////////////////////////////////////////////////////////////////
// CDialogEx dialog
CDialogEx::CDialogEx() : CDialog()
{
m_bEditReturn = TRUE;
}
CDialogEx::CDialogEx(UINT nTemplate, CWnd * lpParent)
: CDialog(nTemplate, lpParent)
{
m_bEditReturn = TRUE;
}
CDialogEx::CDialogEx(LPCTSTR lpTemplate, CWnd * lpParent)
: CDialog(lpTemplate, lpParent)
{
m_bEditReturn = TRUE;
}
BEGIN_MESSAGE_MAP(CDialogEx, CDialog)
//{{AFX_MSG_MAP(CDialogEx)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
//////////////////////////////////////////////////////////////////
// CDialogEx message handler
BOOL CDialogEx::PreTranslateMessage(MSG * lpMsg)
{
// 处理一下KeyDown消息
if(lpMsg->message == WM_KEYDOWN)
{
if(lpMsg->wParam == VK_RETURN)
{
char lpClass[8];
GetClassName(lpMsg->hwnd, lpClass, 8);
if(strcmpi(lpClass, "EDIT") == 0)
{
if( GetWindowLong(lpMsg->hwnd,
GWL_STYLE) & ES_MULTILINE )
{
if( m_bEditReturn ||
(GetKeyState(VK_CONTROL) & 0x00f000) )
{
// 直接将换行符送入
::SendMessage(lpMsg->hwnd,
WM_CHAR, 0x0a, 0x001c0001);
return TRUE;
}
}
// 下一个子项
lpMsg->wParam = 0x09;
}
else if(strcmpi(lpClass, "BUTTON") != 0)
lpMsg->wParam = 0x09;
}
else if(lpMsg->wParam == VK_ESCAPE ||
lpMsg->wParam == VK_CANCEL)
{
// 不要退出
return TRUE;
}
}
// 默认的CWnd消息
if( CWnd::PreTranslateMessage(lpMsg) )
return TRUE;
// 鼠标与键盘处理
return IsDialogMessage(lpMsg);
}
// 创建一个空的对话框
BOOL CDialogEx::CreateEmpty(
CWnd * lpParent,
long ftSize, LPCWSTR ftName,
DWORD dwStyle, LPRECT lpRect
)
{
char lpBuffer[128];
LPDLGTEMPLATE lpTemp = (LPDLGTEMPLATE)lpBuffer;
// 模板的基本属性
lpTemp->style = dwStyle | DS_SETFONT;
lpTemp->dwExtendedStyle = 0;
lpTemp->cdit = 0;
// 窗口的位置
if(lpRect == NULL)
{
lpTemp->x = 0;
lpTemp->y = 0;
lpTemp->cx = 1;
lpTemp->cy = 1;
}
else
{
lpTemp->y = (short)lpRect->top;
lpTemp->x = (short)lpRect->left;
lpTemp->cx = (short)(lpRect->right - lpRect->left);
lpTemp->cy = (short)(lpRect->bottom - lpRect->top);
}
// 模板后面的元素
WORD * lpWord = (WORD *)(lpTemp + 1);
lpWord[0] = lpWord[1] = lpWord[2] = 0x0000;
// 设置对话框模板字体
lstrcpyW(lpWord + 4, ftName);
lpWord[3] = (short)ftSize;
// 创建对话框
return CreateIndirect(lpTemp, lpParent);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -