=============
子窗口创建代码:
=============
wnd = new CChildWnd();
wnd->Create(0,NULL,WS_CHILD|WS_VISIBLE|WS_CLIPSIBLINGS,CRect(m_pt1,m_pt2),this,m_id++);
wnd->SetWindowPos(0,m_pt1.x,m_pt1.y,m_pt2.x - m_pt1.x,m_pt2.y - m_pt1.y,SWP_SHOWWINDOW);
========================
子窗口基类OnPaint()中代码:
========================
CPaintDC dc(this);
g_pCW=this;
GetWindowRect(&m_rtWnd);
//背景色
COLORREF clrs[7]={RGB(131,100,108),RGB(255,127,39),RGB(255,240,105),RGB(108,227,145),RGB(0,162,236),RGB(230,230,200),RGB(255,136,162)};
dc.FillSolidRect(0,0,m_rtWnd.Width(),17,RGB(0,0,230));//标题区域
dc.FillSolidRect(0,17,m_rtWnd.Width(),m_rtWnd.Height(),clrs[GetDlgCtrlID()%7]);//子窗口id%7
///窗口标题按钮功能贴图
m_rtClose.SetRect(m_rtWnd.Width()-16,2,m_rtWnd.Width()-2,15);
m_rtBack.SetRect(m_rtWnd.Width()-32,2,m_rtWnd.Width()-18,15);
m_rtMax.SetRect(m_rtWnd.Width()-48,2,m_rtWnd.Width()-34,15);
m_rtEdge.SetRect(m_rtWnd.Width()-64,2,m_rtWnd.Width()-50,15);
m_rtTitle.SetRect(5,2,m_rtWnd.Width()-64,16);//标题区域,用于双击最大化与还原
dc.FillSolidRect(&m_rtEdge,RGB(192,192,192));
dc.MoveTo(m_rtEdge.left+2,m_rtEdge.bottom-2);
dc.LineTo(m_rtEdge.right-2,m_rtEdge.top+1);
dc.FillSolidRect(&m_rtMax,RGB(192,192,192));
dc.Rectangle(m_rtMax.left+2,m_rtMax.top+2,m_rtMax.right-2,m_rtMax.bottom-1);
dc.FillSolidRect(m_rtMax.left+3,m_rtMax.top+3,8,8,RGB(192,192,192));
dc.FillSolidRect(&m_rtBack,RGB(192,192,192));
dc.Rectangle(m_rtBack.left+3,m_rtBack.top+5,m_rtBack.left+13,m_rtBack.top+12);
dc.FillSolidRect(m_rtBack.left+4,m_rtBack.top+6,8,5,RGB(192,192,192));
dc.Rectangle(m_rtBack.left+1,m_rtBack.top+1,m_rtBack.left+11,m_rtBack.top+8);
dc.FillSolidRect(m_rtBack.left+2,m_rtBack.top+2,8,5,RGB(192,192,192));
dc.FillSolidRect(&m_rtClose,RGB(192,192,192));
dc.MoveTo(m_rtClose.left+2,m_rtClose.bottom-2);
dc.LineTo(m_rtClose.right-2,m_rtClose.top+1);
dc.MoveTo(m_rtClose.left+2,m_rtClose.top+2);
dc.LineTo(m_rtClose.right-2,m_rtClose.bottom-1);
CFont font;
font.CreatePointFont(100,"宋体", &dc);
dc.SetBkMode(TRANSPARENT);
dc.SelectObject(&font);
CString str;
for(int i=0;i<g_vecStruChildWnd.size();i++)
if(g_vecStruChildWnd[i].pWnd==this)//找到点击的子窗口
{
str.Format("输入%d",g_vecStruChildWnd[i].nInputSel+1);
SetTextColor(dc,RGB(255,255,255));
dc.TextOut(10,2,str);
SetTextColor(dc,RGB(0,0,0));
str.Format("叠放序号:%d",g_vecStruChildWnd[i].nSeqNum);
dc.TextOut(10,20,str);
}
CBrush *bru=CBrush::FromHandle((HBRUSH)GetStockObject(NULL_BRUSH));
CBrush *pOldBru=dc.SelectObject(bru);
dc.Rectangle(0,0,m_rtWnd.Width(),m_rtWnd.Height());
dc.SelectObject(&font);
dc.SelectObject(pOldBru);