标签:create getc client awt info include tcl nbsp 技术
#include<afxwin.h> class myapp:public CWinApp { virtual BOOL InitInstance(); }; class mywnd:public CFrameWnd { public: mywnd(); //protected: //DECLARE_MESSAGE_MAP(); };
#include "anotherapp.h" //myapp cpc; BOOL myapp::InitInstance() { this->m_pMainWnd=new mywnd(); this->m_pMainWnd->ShowWindow(this->m_nCmdShow); this->m_pMainWnd->UpdateWindow(); return TRUE; }; /*BEGIN_MESSAGE_MAP(mywnd,CFrameWnd) ON_WM_PAINT() END_MESSAGE_MAP()*/ mywnd::mywnd() { this->Create(NULL,TEXT("喜欢小松鼠")); }
#include "anotherapp.h" myapp cpc;//调用写好的窗体类
输出结果:
#include<afxwin.h> class myapp:public CWinApp { virtual BOOL InitInstance(); }; class mywnd:public CFrameWnd { public: mywnd(); protected: afx_msg void OnPaint();//固定语法,onpaint类 DECLARE_MESSAGE_MAP();//固定语法---消息映射 };
#include "anotherapp.h" //myapp cpc; BOOL myapp::InitInstance() { this->m_pMainWnd=new mywnd(); this->m_pMainWnd->ShowWindow(this->m_nCmdShow); this->m_pMainWnd->UpdateWindow(); return TRUE; }; BEGIN_MESSAGE_MAP(mywnd,CFrameWnd)//消息映射函数 ON_WM_PAINT() END_MESSAGE_MAP()//消息映射函数 mywnd::mywnd() { this->Create(NULL,TEXT("喜欢小松鼠"),WS_OVERLAPPEDWINDOW|WS_VSCROLL,CRect(100,100,380,300)); } void mywnd::OnPaint()//实现的wm_paint消息映射函数 { CPaintDC cp(this);//设备上下文 CRect rect;//窗体上空白的部分 this->GetClientRect(&rect); cp.DrawText(TEXT("想和小松鼠一起看徐黑冬的MMA比赛"),-1,&rect,DT_SINGLELINE|DT_CENTER|DT_VCENTER); }
#include "anotherapp.h" myapp cpc;
运行结果:
标签:create getc client awt info include tcl nbsp 技术
原文地址:https://www.cnblogs.com/saintdingspage/p/12117412.html