📄 subject_28991.htm
字号:
<p>
序号:28991 发表者:风情 发表日期:2003-01-27 13:20:26
<br>主题:各位大虾,预祝大家新年快乐,顺便请教一个问题。
<br>内容:请问如何改变SDI生成界面的边框的颜色?
<br><a href="javascript:history.go(-1)">返回上页</a><br><a href=http://www.copathway.com/cndevforum/>访问论坛</a></p>
<hr size=1>
<blockquote><p>
<font color=red>答案被接受</font><br>回复者:upstream 回复日期:2003-01-27 13:56:12
<br>内容:这个问题应该给200分才对,呵呵.<BR><BR>假设你的SDI工程所生成的view类为:CSDIFrameColorView,从CView派生.<BR><BR>1:在SDIFrameColorView.h中,增加成员函数:<BR><BR>public:<BR> void DrawFrameColor(HWND hWnd,COLORREF refColor);<BR><BR>2:在SDIFrameColorView.cpp中<BR><BR>2.1实现DrawFrameColor函数<BR>void CSDIFrameColorView::DrawFrameColor(HWND hWnd,COLORREF refColor)<BR>{<BR> RECT stRect;<BR><BR> // Get the coordinates of the window on the screen<BR> ::GetWindowRect(hWnd, &stRect);<BR> <BR> // Get a handle to the window's device context<BR> HDC hDC = ::GetWindowDC(hWnd);<BR><BR> HPEN hPen;<BR> hPen = CreatePen(PS_INSIDEFRAME, 2* GetSystemMetrics(SM_CXBORDER), refColor);<BR> <BR> // Draw the rectangle around the window<BR> HPEN hOldPen = (HPEN)SelectObject(hDC, hPen);<BR> HBRUSH hOldBrush = (HBRUSH)SelectObject(hDC, GetStockObject(NULL_BRUSH));<BR> <BR> Rectangle(hDC, 0, 0, (stRect.right - stRect.left), (stRect.bottom - stRect.top));<BR><BR> //Give the window its device context back, and destroy our pen<BR> ::ReleaseDC(hWnd, hDC);<BR><BR> SelectObject(hDC, hOldPen);<BR> SelectObject(hDC, hOldBrush);<BR><BR> DeleteObject(hPen);<BR> DeleteObject(hDC);<BR>}<BR><BR>2.2重载OnDraw<BR>void CSDIFrameColorView::OnDraw(CDC* pDC)<BR>{<BR> CSDIFrameBorderDoc* pDoc = GetDocument();<BR> ASSERT_VALID(pDoc);<BR> // TODO: add draw code for native data here<BR> CWnd* pWnd = GetParent();<BR> if(pWnd)<BR> {<BR> DrawFrameColor(pWnd->m_hWnd,RGB(255,0,0));//红色边框<BR> }<BR><BR>}<BR>2003-1-27 14:09:02
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -