?? textwnd.cpp
字號:
// TextWnd.cpp : implementation file
//
#include "stdafx.h"
#include "TextWnd.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CTextWnd
//設置與窗口相關的靜態Control.
CTextWnd::CTextWnd(int IDC)
{
int i;
m_IDC=IDC;
m_BK_Color = RGB(192, 192, 192);
m_HI_BColor = RGB(255, 0, 0);
m_Text_Color= RGB( 0, 128, 0);
m_HI_TColor = RGB(255, 255, 255);
m_X_Blank = 0;
m_Sentence_num = 0;
for(i=0; i<50; i++)
m_Sentence_Flag[i] = 'A';
memset(m_Pos_Flag, 0, 6);
m_ResetWnd = FALSE;
}
//按相關靜態Control設置窗口大小,創立窗口。
BOOL CTextWnd::Create(LPCTSTR lpszClassName, LPCTSTR lpszWindowName,
DWORD dwStyle, const RECT& rect, CWnd* pParentWnd,
UINT nID, CCreateContext* pContext)
{
// TODO: Add your specialized code here and/or call the base class
CWnd *TextReg;
CRect Origin_Rect;
TextReg=pParentWnd->GetDlgItem(m_IDC);
if(TextReg==NULL)throw(0);
TextReg->GetWindowRect(&Origin_Rect);
Origin_Rect.DeflateRect(5,5);
m_Origin_Rect = Origin_Rect;
pParentWnd->ScreenToClient(&Origin_Rect);
m_Width = Origin_Rect.Width();
m_Heigh = Origin_Rect.Height();
return CWnd::Create(lpszClassName, lpszWindowName, dwStyle,
Origin_Rect, pParentWnd, nID, pContext);
}
void CTextWnd::SetTextWnd()
{
CPaintDC dc(this); // device context for painting
CSize Size;
Size = dc.GetOutputTextExtent(" ");
m_X_Blank = Size.cx/10;
m_Y = Size.cy + 1;
m_Blank_Num = m_Width/m_X_Blank;
m_X_Start = m_X_Blank * 10;
m_Blank_String.Empty();
for(int i=0; i<m_Blank_Num-10; i++)
m_Blank_String += ' ';
m_Brush = dc.GetCurrentBrush();
}
CTextWnd::~CTextWnd()
{
for(int i=0; i<50; i++)
{
if(!m_Sentence[i].IsEmpty())
m_Sentence[i].Empty();
}
m_Blank_String.Empty();
}
BEGIN_MESSAGE_MAP(CTextWnd, CWnd)
//{{AFX_MSG_MAP(CTextWnd)
ON_WM_PAINT()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CTextWnd message handlers
void CTextWnd::OnPaint()
{
CPaintDC dc(this); // device context for painting
// TODO: Add your message handler code here
int i, j;
if(m_ResetWnd)
{
for(i=0,j=1; i<50; i++)
{
dc.TextOut(m_X_Blank, j, m_Blank_String);
dc.TextOut(m_X_Start, j, m_Blank_String);
j += m_Y;
}
m_ResetWnd = FALSE;
}
for(i=0,j=1; i<m_Sentence_num; i++)
{
if(m_Sentence_Flag[i]=='L')
{
dc.SetBkColor(m_HI_BColor);
dc.TextOut(m_X_Blank, j, m_Pos_Flag, 4); //" ● " or "===>"
dc.TextOut(m_X_Start, j, m_Blank_String);
dc.TextOut(m_X_Start, j, m_Sentence[i]);
}
else if(m_Sentence_Flag[i]=='A')
{
dc.SetBkColor(m_HI_TColor);
dc.SetTextColor(m_HI_TColor);
dc.TextOut(m_X_Blank, j, m_Pos_Flag, 4); //" ● " or "===>"
dc.SetBkColor(m_BK_Color);
dc.SetTextColor(m_Text_Color);
dc.TextOut(m_X_Start, j, m_Blank_String);
dc.TextOut(m_X_Start, j, m_Sentence[i]);
}
j += m_Y;
}
dc.SetBkColor(m_HI_TColor);
dc.SetTextColor(m_HI_TColor);
dc.TextOut(m_X_Blank, j, m_Pos_Flag, 4); //" ● " or "===>"
dc.TextOut(m_X_Start, j, m_Blank_String);
// Do not call CWnd::OnPaint() for painting messages
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -