📄 dispdlg.cpp
字号:
// dispDlg.cpp : implementation file
//
#include "stdafx.h"
#include "disp.h"
#include "dispDlg.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CDispDlg dialog
CDispDlg::CDispDlg(CWnd* pParent /*=NULL*/)
: CDialog(CDispDlg::IDD, pParent)
{
//{{AFX_DATA_INIT(CDispDlg)
// NOTE: the ClassWizard will add member initialization here
//}}AFX_DATA_INIT
// Note that LoadIcon does not require a subsequent DestroyIcon in Win32
m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
}
void CDispDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CDispDlg)
// NOTE: the ClassWizard will add DDX and DDV calls here
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CDispDlg, CDialog)
//{{AFX_MSG_MAP(CDispDlg)
ON_BN_CLICKED(IDC_BUTTON1, OnButton1)
ON_WM_PAINT()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CDispDlg message handlers
BOOL CDispDlg::OnInitDialog()
{
CDialog::OnInitDialog();
// Set the icon for this dialog. The framework does this automatically
// when the application's main window is not a dialog
SetIcon(m_hIcon, TRUE); // Set big icon
SetIcon(m_hIcon, FALSE); // Set small icon
CenterWindow(GetDesktopWindow()); // center to the hpc screen
// TODO: Add extra initialization here
return TRUE; // return TRUE unless you set the focus to a control
}
void CDispDlg::OnButton1()
{
CDC *pdc;
pdc=GetDC();
CRect rect(30,30,100,60);
pdc->DrawText(TEXT("中2国3"), rect, DT_CENTER|DT_SINGLELINE|DT_VCENTER);
CString user_name = "中2国3";
int length = user_name.GetLength();
size_t aLen = length + 1;
LPCSTR lm = (LPCSTR)user_name.GetBuffer(length);
int wLen = MultiByteToWideChar(CP_OEMCP, 0,lm,aLen, NULL,0);
LPOLESTR show = new TCHAR [wLen];
MultiByteToWideChar(CP_OEMCP, 0,lm,aLen,show,wLen);
CRect rect2(130,130,200,160);
pdc->DrawText(show, rect2, DT_CENTER|DT_SINGLELINE|DT_VCENTER);
ReleaseDC(pdc);
}
void CDispDlg::OnPaint()
{
CPaintDC dc(this); // device context for painting
// TODO: Add your message handler code here
// Do not call CDialog::OnPaint() for painting messages
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -