如何修改CMainFrame可调边框的颜色?也就是非客户区的颜色. 如题 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 在WM_NCPAINT中先调用默认处理,再自绘边框 最间单的方法是改变WINDOWS的主题风格. ZT假设你的SDI工程所生成的view类为:CSDIFrameColorView,从CView派生.1:在SDIFrameColorView.h中,增加成员函数:public: void DrawFrameColor(HWND hWnd,COLORREF refColor);2:在SDIFrameColorView.cpp中2.1实现DrawFrameColor函数void CSDIFrameColorView::DrawFrameColor(HWND hWnd,COLORREF refColor){ RECT stRect; // Get the coordinates of the window on the screen ::GetWindowRect(hWnd, &stRect); // Get a handle to the window's device context HDC hDC = ::GetWindowDC(hWnd); HPEN hPen; hPen = CreatePen(PS_INSIDEFRAME, 2* GetSystemMetrics(SM_CXBORDER), refColor); // Draw the rectangle around the window HPEN hOldPen = (HPEN)SelectObject(hDC, hPen); HBRUSH hOldBrush = (HBRUSH)SelectObject(hDC, GetStockObject(NULL_BRUSH)); Rectangle(hDC, 0, 0, (stRect.right - stRect.left), (stRect.bottom - stRect.top)); //Give the window its device context back, and destroy our pen ::ReleaseDC(hWnd, hDC); SelectObject(hDC, hOldPen); SelectObject(hDC, hOldBrush); DeleteObject(hPen); DeleteObject(hDC);}2.2重载OnDrawvoid CSDIFrameColorView::OnDraw(CDC* pDC){ CSDIFrameBorderDoc* pDoc = GetDocument(); ASSERT_VALID(pDoc); // TODO: add draw code for native data here CWnd* pWnd = GetParent(); if(pWnd) { DrawFrameColor(pWnd->m_hWnd,RGB(255,0,0));//红色边框 }} Excel是如何实现让子窗口显示在任务栏上的? 怎么使用MSDN查所要的信息? 谁说说这是什么意思?? 怎样在一个对话框中接收拖放? 如何获取当前机器上安装的modem及其占用端口 紧急求救,在线等待,解决后马上结贴 小问题怎么在工程里导入一个没有注册的,ocx控件,送30分 如何使用动态添加的菜单 一个奇怪的delete语句的问题 关于菜单的问题,我要在按钮响应时弹出一个菜单,但却不行大家可以试一下,以下是代码。 求助高手,如何切换多个不同文档模板? 关于CPropertyPage的问题。
假设你的SDI工程所生成的view类为:CSDIFrameColorView,从CView派生.
1:在SDIFrameColorView.h中,增加成员函数:
public:
void DrawFrameColor(HWND hWnd,COLORREF refColor);
2:在SDIFrameColorView.cpp中
2.1实现DrawFrameColor函数
void CSDIFrameColorView::DrawFrameColor(HWND hWnd,COLORREF refColor)
{ RECT stRect;
// Get the coordinates of the window on the screen
::GetWindowRect(hWnd, &stRect);
// Get a handle to the window's device context
HDC hDC = ::GetWindowDC(hWnd);
HPEN hPen;
hPen = CreatePen(PS_INSIDEFRAME, 2* GetSystemMetrics(SM_CXBORDER), refColor);
// Draw the rectangle around the window
HPEN hOldPen = (HPEN)SelectObject(hDC, hPen);
HBRUSH hOldBrush = (HBRUSH)SelectObject(hDC, GetStockObject(NULL_BRUSH));
Rectangle(hDC, 0, 0, (stRect.right - stRect.left), (stRect.bottom - stRect.top));
//Give the window its device context back, and destroy our pen
::ReleaseDC(hWnd, hDC);
SelectObject(hDC, hOldPen);
SelectObject(hDC, hOldBrush);
DeleteObject(hPen);
DeleteObject(hDC);
}
2.2重载OnDraw
void CSDIFrameColorView::OnDraw(CDC* pDC)
{
CSDIFrameBorderDoc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
// TODO: add draw code for native data here
CWnd* pWnd = GetParent();
if(pWnd)
{ DrawFrameColor(pWnd->m_hWnd,RGB(255,0,0));//红色边框
}
}