📄 movewnd.cpp
字号:
// MoveWnd.cpp : implementation file
//
#include "stdafx.h"
#include "MoveWnd.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CMoveWnd
//设置与窗口相关的静态Control.
CMoveWnd::CMoveWnd(int IDC)
{
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_ResetWnd = TRUE;
}
//按相关静态Control设置窗口大小,创立窗口。
BOOL CMoveWnd::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);
pParentWnd->ScreenToClient(&Origin_Rect);
m_Rect_Width = Origin_Rect.Width();
m_Rect_Heigh = Origin_Rect.Height();
return CWnd::Create(lpszClassName, lpszWindowName, dwStyle,
Origin_Rect, pParentWnd, nID, pContext);
}
void CMoveWnd::SetMoveWnd(int *A, int *temp, int Array_Num)
{
CPaintDC dc(this); // device context for painting
CSize Size;
int i;
Size = dc.GetOutputTextExtent(" ");
m_Blank_Width = Size.cx/10;
m_Blank_Heigh = Size.cy + 1;
m_Brush = dc.GetCurrentBrush();
m_pA = new int[Array_Num];
m_ptemp = new int[Array_Num];
m_Array_Num = Array_Num;
for(i=0; i<m_Array_Num; i++)
{
m_pA[i] = A[i];
m_ptemp[i] = temp[i];
}
m_Move_Flag = FALSE;
}
CMoveWnd::~CMoveWnd()
{
m_Blank_String.Empty();
}
BEGIN_MESSAGE_MAP(CMoveWnd, CWnd)
//{{AFX_MSG_MAP(CMoveWnd)
ON_WM_PAINT()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CMoveWnd message handlers
void CMoveWnd::OnPaint()
{
CPaintDC dc(this); // device context for painting
// TODO: Add your message handler code here
/* int i=0, j, length;
CString str;
dc.SetBkColor(m_HI_TColor);
dc.SetTextColor(m_Text_Color);
for(i=0; i<m_Array_Num; i++)
{
str.Format("A[%d] ", i);
dc.TextOut(i*54+18, 0, str);
str.Format("temp[%d]", i);
dc.TextOut(i*54+8, m_Rect_Heigh-m_Blank_Heigh-1, str);
}
dc.SetBkColor(m_Text_Color);
dc.SetTextColor(m_HI_BColor);
for(i=0; i<m_Array_Num; i++)
{
str.Format(" %2d ", m_pA[i]);
dc.TextOut(i*54+5, m_Blank_Heigh, str);
str.Format(" %02d ", m_ptemp[i]);
dc.TextOut(i*54+5, m_Rect_Heigh-2*m_Blank_Heigh-1, str);
}
if(m_Move_Flag)
{
length = m_Blank_Heigh;
if(m_FromA_Flag)
{
dc.SetBkColor(m_Text_Color);
dc.SetTextColor(m_HI_BColor);
str.Format(" %02d ", m_pA[m_from]);
dc.TextOut(m_from*54+5, m_Blank_Heigh*2+1, str);
Sleep(100);
length = m_Blank_Heigh/2;
for(i=m_Blank_Heigh*2+1+length; i<(m_Rect_Heigh-m_Blank_Heigh)/2; i+=length)
{
dc.SetBkColor(m_HI_TColor);
dc.TextOut(m_from*54+5, i-length, " ");
Sleep(100);
dc.SetBkColor(m_Text_Color);
dc.TextOut(m_from*54+5, i, str);
Sleep(100);
}
dc.SetBkColor(m_HI_TColor);
dc.TextOut(m_from*54+5, i-length, " ");
Sleep(100);
dc.SetBkColor(m_Text_Color);
dc.TextOut(m_from*54+5, (m_Rect_Heigh-m_Blank_Heigh)/2, str);
Sleep(100);
}
else
{
dc.SetBkColor(m_Text_Color);
dc.SetTextColor(m_HI_BColor);
str.Format(" %02d ", m_ptemp[m_from]);
dc.TextOut(m_from*54+5, m_Rect_Heigh-3*m_Blank_Heigh-1, str);
Sleep(100);
for(i=m_Rect_Heigh-3*m_Blank_Heigh-1-length; i>(m_Rect_Heigh-m_Blank_Heigh)/2; i-=length)
{
dc.SetBkColor(m_HI_TColor);
dc.TextOut(m_from*54+5, i+length, " ");
Sleep(100);
dc.SetBkColor(m_Text_Color);
dc.TextOut(m_from*54+5, i, str);
Sleep(100);
}
dc.SetBkColor(m_HI_TColor);
dc.TextOut(m_from*54+5, i+length, " ");
Sleep(100);
dc.SetBkColor(m_Text_Color);
dc.TextOut(m_from*54+5, (m_Rect_Heigh-m_Blank_Heigh)/2, str);
Sleep(100);
}
length = m_Blank_Width*4;
if(m_from < m_to)
{
for(i=m_from*54+5+length; i<m_to*54+5; i+=length)
{
dc.SetBkColor(m_HI_TColor);
dc.TextOut(i-length, (m_Rect_Heigh-m_Blank_Heigh)/2, " ");
Sleep(100);
dc.SetBkColor(m_Text_Color);
dc.TextOut(i, (m_Rect_Heigh-m_Blank_Heigh)/2, str);
Sleep(100);
}
dc.SetBkColor(m_HI_TColor);
dc.TextOut(i-length, (m_Rect_Heigh-m_Blank_Heigh)/2, " ");
Sleep(100);
dc.SetBkColor(m_Text_Color);
dc.TextOut(m_to*54+5, (m_Rect_Heigh-m_Blank_Heigh)/2, str);
Sleep(100);
}
else
{
for(i=m_from*54+5-length; i>m_to*54+5; i-=length)
{
dc.SetBkColor(m_HI_TColor);
dc.TextOut(i+length, (m_Rect_Heigh-m_Blank_Heigh)/2, " ");
Sleep(100);
dc.SetBkColor(m_Text_Color);
dc.TextOut(i, (m_Rect_Heigh-m_Blank_Heigh)/2, str);
Sleep(100);
}
dc.SetBkColor(m_HI_TColor);
dc.TextOut(i+length, (m_Rect_Heigh-m_Blank_Heigh)/2, " ");
Sleep(100);
dc.SetBkColor(m_Text_Color);
dc.TextOut(m_to*54+5, (m_Rect_Heigh-m_Blank_Heigh)/2, str);
Sleep(100);
}
length = m_Blank_Heigh;
if(m_ToA_Flag)
{
for(i=(m_Rect_Heigh-m_Blank_Heigh)/2-length; i>m_Blank_Heigh+1; i-=length)
{
dc.SetBkColor(m_HI_TColor);
dc.TextOut(m_to*54+5, i+length, " ");
Sleep(100);
dc.SetBkColor(m_Text_Color);
dc.TextOut(m_to*54+5, i, str);
Sleep(100);
}
dc.SetBkColor(m_HI_TColor);
dc.TextOut(m_to*54+5, i+length, " ");
Sleep(100);
dc.SetBkColor(m_Text_Color);
dc.TextOut(m_to*54+5, m_Blank_Heigh+1, str);
Sleep(100);
}
else
{
for(i=(m_Rect_Heigh-m_Blank_Heigh)/2+length; i<m_Rect_Heigh-2*m_Blank_Heigh-1; i+=length)
{
dc.SetBkColor(m_HI_TColor);
dc.TextOut(m_to*54+5, i-length, " ");
Sleep(100);
dc.SetBkColor(m_Text_Color);
dc.TextOut(m_to*54+5, i, str);
Sleep(100);
}
dc.SetBkColor(m_HI_TColor);
dc.TextOut(m_to*54+5, i-length, " ");
Sleep(100);
dc.SetBkColor(m_Text_Color);
dc.TextOut(m_to*54+5, m_Rect_Heigh-2*m_Blank_Heigh-1, str);
Sleep(100);
}
}*/
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -