给你一个函数:
void MyDrawFocusRect(HWND hwnd)
{
//在窗口hwnd的边框上画一个虚线框
RECT rt;
GetWindowRect(hwnd,&rt);
OffsetRect(&rt,-rt.left,-rt.top);
HDC dc=GetWindowDC(hwnd);
DrawFocusRect(dc,&rt);
InflateRect(&rt,-1,-1);
DrawFocusRect(dc,&rt);
InflateRect(&rt,-1,-1);
DrawFocusRect(dc,&rt);
InflateRect(&rt,-1,-1);
DrawFocusRect(dc,&rt);
ReleaseDC(hwnd,dc);
}该函数使用了api函数DrawFocusRect(),画出的捕获框非常标准,因为DrawFocusRect()函数内部使用了xor方式,因此在同一位置第二次绘制就会把第一次画的捕获框擦除。
void MyDrawFocusRect(HWND hwnd)
{
//在窗口hwnd的边框上画一个虚线框
RECT rt;
GetWindowRect(hwnd,&rt);
OffsetRect(&rt,-rt.left,-rt.top);
HDC dc=GetWindowDC(hwnd);
DrawFocusRect(dc,&rt);
InflateRect(&rt,-1,-1);
DrawFocusRect(dc,&rt);
InflateRect(&rt,-1,-1);
DrawFocusRect(dc,&rt);
InflateRect(&rt,-1,-1);
DrawFocusRect(dc,&rt);
ReleaseDC(hwnd,dc);
}该函数使用了api函数DrawFocusRect(),画出的捕获框非常标准,因为DrawFocusRect()函数内部使用了xor方式,因此在同一位置第二次绘制就会把第一次画的捕获框擦除。
解决方案 »
- mfc 对话框程序,开机自启动出现的错误!
- JavaScript 在网页中使用的问题? 在线等! :)
- CRichEditView的OnCommand()方法
- 请大家帮我看看MFC SOCKCORE.CPP中这部分代码的真实含义
- 近来开发一车载系统,利用的是征求界面方案!
- 如何在局域网上找计算机(已知该计算机的名字),而后得到其ip地址。。。
- 呜呜,那位大大发个BCGControlBar里的TrayMenu的Sample给小弟吧..
- 200分,寻找Active 专家,Active的发布,下载,服务器端调用,客户端浏览器的调用!
- vc 中的数据库开发,about dbgrid 和 msflexgrid!
- 串口的同步操作、重叠操作、异步操作、双工通信、单工通信
- 基于对话框的MFC程序中,OnPaint()函数里面的语句起什么作用?
- socket api
{
TRect rect;
HDC dc;
GetWindowRect(hWnds, &rect);
dc= GetDC(0);
Form1->Label5->Caption="X:"+IntToStr(rect.Width());
Form1->Label6->Caption="Y:"+IntToStr(rect.Height());
SetROP2(dc, R2_NOT);
MoveToEx(dc, rect.left + 1, rect.top + 1, NULL);
LineTo(dc, rect.right + 1, rect.top + 1);
MoveToEx(dc, rect.right - 1, rect.top + 1, NULL);
LineTo(dc, rect.right - 1, rect.bottom - 1);
MoveToEx(dc, rect.right - 1, rect.bottom -1 , NULL);
LineTo(dc, rect.left + 1, rect.bottom - 1);
MoveToEx(dc, rect.left + 1, rect.bottom - 1, NULL);
LineTo(dc, rect.left + 1, rect.top + 1); MoveToEx(dc, rect.left + 2, rect.top + 2, NULL);
LineTo(dc, rect.right + 2, rect.top + 2);
MoveToEx(dc, rect.right - 2, rect.top + 2, NULL);
LineTo(dc, rect.right - 2, rect.bottom - 2);
MoveToEx(dc, rect.right - 2, rect.bottom -2 , NULL);
LineTo(dc, rect.left + 2, rect.bottom - 2);
MoveToEx(dc, rect.left + 2, rect.bottom - 2, NULL);
LineTo(dc, rect.left + 2, rect.top + 2);
}