HDC hdc = ::GetDC(m_hWnd); RECT rect = { 10,10,100,100 }; RECT rect1 = {50,50,150,150}; RECT rect2; HBRUSH hbr; hbr = CreateSolidBrush(RGB(0, 0, 255)); SelectObject(hdc, hbr); int f = FrameRect(hdc, &rect, hbr); f = FrameRect(hdc, &rect1, hbr); BOOL b= UnionRect(&rect2,&rect1,&rect); //获得两个矩形的并集部分 /* 参数1:LPCRECT lprcDst 指向两个源矩形并集的矩形 参数2:LPCRECT lpRect1 源矩形 参数3:LPCRECT lpRect2 源矩形 返回值:如果交不为空,则返回非零值;否则,如果交为空则返回0 */ Sleep(2000); hbr = CreateSolidBrush(RGB(255, 0, 0)); SelectObject(hdc, hbr); f = FrameRect(hdc, &rect2, hbr); DeleteObject(hbr); ::ReleaseDC(m_hWnd, hdc);
标签:LPCRECT,MFC,hdc,rect2,UnionRect,矩形,RECT,hbr From: https://www.cnblogs.com/liming19680104/p/17322500.html