📄 progwnd.cpp
字号:
// ProgWnd.cpp : implementation file
//
#include "stdafx.h"
#include "ProgWnd.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CProgWnd
CProgWnd::CProgWnd()
{
}
CProgWnd::~CProgWnd()
{
}
BEGIN_MESSAGE_MAP(CProgWnd, CWnd)
//{{AFX_MSG_MAP(CProgWnd)
ON_WM_CREATE()
ON_WM_DESTROY()
ON_WM_PAINT()
ON_WM_SHOWWINDOW()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CProgWnd message handlers
int CProgWnd::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
if (CWnd::OnCreate(lpCreateStruct) == -1)
return -1;
// TODO: Add your specialized creation code here
CDC dc;
dc.CreateDC("DISPLAY", NULL, NULL, NULL);
int iw = dc.GetDeviceCaps(HORZRES);
int ih = dc.GetDeviceCaps(VERTRES);
dc.DeleteDC();
CRect rt;
rt.left = 0;
rt.top = 0;
rt.right = 300;
rt.bottom = 65;
SetWindowPos(&CWnd::wndTopMost, iw/2-rt.Width()/2, ih/2-rt.Height()/2, rt.Width(), rt.Height(), SWP_HIDEWINDOW);
GetClientRect(&rt);
rt.DeflateRect(6, 20, 6, 6);
m_cProg.Create(PBS_SMOOTH|WS_CHILD|WS_VISIBLE, rt, this, 1);
//create font
LOGFONT lf;
CFont font;
memset(&lf,0,sizeof(LOGFONT));
lf.lfHeight = -12;
lf.lfWeight = FW_LIGHT ;
lf.lfCharSet = ANSI_CHARSET ;
lf.lfOutPrecision = OUT_DEFAULT_PRECIS ;
lf.lfClipPrecision = CLIP_DEFAULT_PRECIS ;
lf.lfQuality = DEFAULT_QUALITY ;
lf.lfPitchAndFamily = FF_DONTCARE|DEFAULT_PITCH;
lstrcpy (lf.lfFaceName, "宋体") ;
m_font.CreateFontIndirect(&lf);
return 0;
}
void CProgWnd::SetMessage(CString csMess)
{
m_csMess = csMess;
RedrawWindow();
}
void CProgWnd::SetRange(int range)
{
m_cProg.SetRange(0, range);
}
void CProgWnd::SetStep(int step)
{
m_cProg.SetStep(1);
}
void CProgWnd::StepIt()
{
m_cProg.StepIt();
}
void CProgWnd::OnDestroy()
{
CWnd::OnDestroy();
m_cProg.DestroyWindow();
m_font.DeleteObject();
// TODO: Add your message handler code here
}
void CProgWnd::OnPaint()
{
CPaintDC dc(this); // device context for painting
// TODO: Add your message handler code here
CRect rt;
CBrush brush(GetSysColor(COLOR_BTNFACE));
GetClientRect(rt);
dc.FillRect(&rt, &brush);
dc.SetBkColor(GetSysColor(COLOR_BTNFACE));
dc.SelectObject(&m_font);
dc.TextOut(5, 5, m_csMess);
brush.DeleteObject();
// Do not call CWnd::OnPaint() for painting messages
}
void CProgWnd::OnShowWindow(BOOL bShow, UINT nStatus)
{
CWnd::OnShowWindow(bShow, nStatus);
// TODO: Add your message handler code here
//RedrawWindow(); //not work, why ???
}
void CProgWnd::Show()
{
ShowWindow(SW_SHOW);
RedrawWindow();
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -