1个回答
展开全部
#include<afxwin.h>
class CMyFrameWnd : public CFrameWnd
{
private:
int m_width;
public:
CMyFrameWnd()
{
m_width = 0;
Create(NULL,"我的窗口");
this->UpdateWindow();
this->ShowWindow(SW_MAXIMIZE);
this->SetTimer(1,100, NULL);
}
afx_msg void OnPaint();
afx_msg void OnTimer(UINT nIDEvent);
DECLARE_MESSAGE_MAP()
};
void CMyFrameWnd::OnPaint()
{
m_width = m_width + 10;
CPaintDC dc(this);
dc.TextOut(m_width,0,"欢迎使用Visual C++");
CRect rect;
this->GetClientRect(&rect);
if (m_width >= rect.Width()) {
m_width = 0;
}
}
void CMyFrameWnd::OnTimer(UINT nIDEvent)
{
this->Invalidate();
}
BEGIN_MESSAGE_MAP(CMyFrameWnd,CFrameWnd)
ON_WM_PAINT()
ON_WM_TIMER()
END_MESSAGE_MAP()
class CMyWinApp: public CWinApp
{
public:
virtual BOOL InitInstance()
{
m_pMainWnd = new CMyFrameWnd();
return TRUE;
}
};
CMyWinApp theapp;
class CMyFrameWnd : public CFrameWnd
{
private:
int m_width;
public:
CMyFrameWnd()
{
m_width = 0;
Create(NULL,"我的窗口");
this->UpdateWindow();
this->ShowWindow(SW_MAXIMIZE);
this->SetTimer(1,100, NULL);
}
afx_msg void OnPaint();
afx_msg void OnTimer(UINT nIDEvent);
DECLARE_MESSAGE_MAP()
};
void CMyFrameWnd::OnPaint()
{
m_width = m_width + 10;
CPaintDC dc(this);
dc.TextOut(m_width,0,"欢迎使用Visual C++");
CRect rect;
this->GetClientRect(&rect);
if (m_width >= rect.Width()) {
m_width = 0;
}
}
void CMyFrameWnd::OnTimer(UINT nIDEvent)
{
this->Invalidate();
}
BEGIN_MESSAGE_MAP(CMyFrameWnd,CFrameWnd)
ON_WM_PAINT()
ON_WM_TIMER()
END_MESSAGE_MAP()
class CMyWinApp: public CWinApp
{
public:
virtual BOOL InitInstance()
{
m_pMainWnd = new CMyFrameWnd();
return TRUE;
}
};
CMyWinApp theapp;
本回答被网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询