⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 subject_28991.htm

📁 一些关于vc的问答
💻 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>&nbsp;&nbsp;&nbsp;&nbsp;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>&nbsp;&nbsp;&nbsp;&nbsp;RECT stRect;<BR><BR>&nbsp;&nbsp;&nbsp;&nbsp;// Get the coordinates of the window on the screen<BR>&nbsp;&nbsp;&nbsp;&nbsp;::GetWindowRect(hWnd, &amp;stRect);<BR>&nbsp;&nbsp;&nbsp;&nbsp;<BR>&nbsp;&nbsp;&nbsp;&nbsp;// Get a handle to the window's device context<BR>&nbsp;&nbsp;&nbsp;&nbsp;HDC hDC = ::GetWindowDC(hWnd);<BR><BR>&nbsp;&nbsp;&nbsp;&nbsp;HPEN hPen;<BR>&nbsp;&nbsp;&nbsp;&nbsp;hPen = CreatePen(PS_INSIDEFRAME, 2* GetSystemMetrics(SM_CXBORDER), refColor);<BR>&nbsp;&nbsp;&nbsp;&nbsp;<BR>&nbsp;&nbsp;&nbsp;&nbsp;// Draw the rectangle around the window<BR>&nbsp;&nbsp;&nbsp;&nbsp;HPEN&nbsp;&nbsp; hOldPen&nbsp;&nbsp; = (HPEN)SelectObject(hDC, hPen);<BR>&nbsp;&nbsp;&nbsp;&nbsp;HBRUSH hOldBrush = (HBRUSH)SelectObject(hDC, GetStockObject(NULL_BRUSH));<BR>&nbsp;&nbsp;&nbsp;&nbsp;<BR>&nbsp;&nbsp;&nbsp;&nbsp;Rectangle(hDC, 0, 0, (stRect.right - stRect.left), (stRect.bottom - stRect.top));<BR><BR>&nbsp;&nbsp;&nbsp;&nbsp;//Give the window its device context back, and destroy our pen<BR>&nbsp;&nbsp;&nbsp;&nbsp;::ReleaseDC(hWnd, hDC);<BR><BR>&nbsp;&nbsp;&nbsp;&nbsp;SelectObject(hDC, hOldPen);<BR>&nbsp;&nbsp;&nbsp;&nbsp;SelectObject(hDC, hOldBrush);<BR><BR>&nbsp;&nbsp;&nbsp;&nbsp;DeleteObject(hPen);<BR>&nbsp;&nbsp;&nbsp;&nbsp;DeleteObject(hDC);<BR>}<BR><BR>2.2重载OnDraw<BR>void CSDIFrameColorView::OnDraw(CDC* pDC)<BR>{<BR>&nbsp;&nbsp;&nbsp;&nbsp;CSDIFrameBorderDoc* pDoc = GetDocument();<BR>&nbsp;&nbsp;&nbsp;&nbsp;ASSERT_VALID(pDoc);<BR>&nbsp;&nbsp;&nbsp;&nbsp;// TODO: add draw code for native data here<BR>&nbsp;&nbsp;&nbsp;&nbsp;CWnd* pWnd = GetParent();<BR>&nbsp;&nbsp;&nbsp;&nbsp;if(pWnd)<BR>&nbsp;&nbsp;&nbsp;&nbsp;{<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;DrawFrameColor(pWnd-&gt;m_hWnd,RGB(255,0,0));//红色边框<BR>&nbsp;&nbsp;&nbsp;&nbsp;}<BR><BR>}<BR>2003-1-27 14:09:02

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -