📄 statussubwnd.cpp
字号:
// StatusSubWnd.cpp : implementation file
//
#include "stdafx.h"
#include "btwnd.h"
#include "StatusSubWnd.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CStatusSubWnd
extern CRect rect_num_dsplywindow ;
extern HWND hwnd_num_dsplywindow ;
extern BYTE dial_num[20];
extern unsigned int first_to_paint;
extern unsigned char dial_index;
CStatusSubWnd::CStatusSubWnd()
{
}
CStatusSubWnd::~CStatusSubWnd()
{
}
BEGIN_MESSAGE_MAP(CStatusSubWnd, CWnd)
//{{AFX_MSG_MAP(CStatusSubWnd)
ON_WM_PAINT()
ON_WM_CREATE()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CSrnDispWindow message handlers
void CStatusSubWnd::CreateDispWin(const RECT& rect, CWnd* pParentWnd, UINT cmd)
{
// HCURSOR hcursor;
HBRUSH hbrush;
CString str;
HCURSOR hcursor;
hcursor=AfxGetApp()->LoadCursor(IDC_ARROW);
hbrush=(HBRUSH) ::GetStockObject(BLACK_BRUSH);
str=::AfxRegisterWndClass(CS_VREDRAW | CS_HREDRAW,hcursor,hbrush);
// CWnd* pWnd = new CStatic;
this->Create(str,_T("dsplay"),WS_CHILD|WS_VISIBLE|WS_BORDER,rect,pParentWnd,cmd);
}
/////////////////////////////////////////////////////////////////////////////
// CStatusSubWnd message handlers
void CStatusSubWnd::OnPaint()
{
CPaintDC dc(this); // device context for painting
//////////界面////////////////////////
this->GetClientRect(&rect_status_subwnd);
this->ScreenToClient (&rect_status_subwnd);
//////////////选择字体/////////////////////////
CSize size1,size2;
CString str,str1,str2;
if(dial_index <=19)
{
str=dial_num;
str1=str.Right(10);
if(str.GetLength()>10)
{
str2=str.Left(str.GetLength()-10);
}
CFont font;
font.CreateFontIndirect(&lf1);
dc.SelectObject(&font);
size1=dc.GetTextExtent(str1);
size2=dc.GetTextExtent(str2);
dc.SetBkColor(TRANSPARENT);
dc.SetTextColor(RGB(135,206,235));
dc.DrawText(str2,CRect(350-size2.cx, 0, 404,68),DT_CENTER |DT_BOTTOM |DT_SINGLELINE );
dc.DrawText(str1,CRect(350-size1.cx,68,404,136),DT_CENTER |DT_BOTTOM |DT_SINGLELINE );
}
else
{
dial_index--;
dial_num[dial_index]=NULL;
::SendMessage(hwnd_num_dsplywindow,WM_PAINT,0,0);
::InvalidateRect(hwnd_num_dsplywindow,rect_num_dsplywindow,TRUE);
::UpdateWindow(hwnd_num_dsplywindow);
}
this->GetClientRect(rect_num_dsplywindow); //为向读取线程的刷新函数提供rect
hwnd_num_dsplywindow=this->GetSafeHwnd(); ////为向读取线程的刷新函数提供句柄
}
int CStatusSubWnd::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
if (CWnd::OnCreate(lpCreateStruct) == -1)
return -1;
ZeroMemory(&lf1,sizeof(lf1));
lf1.lfHeight=80;
lf1.lfWeight=FW_BOLD;
lf1.lfItalic=TRUE;
::lstrcpy(lf1.lfFaceName,_T("Times New Roman"));
// TODO: Add your specialized creation code here
return 0;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -