窗口绘制边框及更新

转载请注明来源:https://www.cnblogs.com/hookjc/

#define ZOU_PROCESS_ERROR(condition)   if(!(condition)) goto Exit0;
#define ZOU_PROCESS_SUCCESS(condition) if(condition) goto Exit1;

int RedrawWindowFrame(HWND hWnd)
{
int nResult = false;
int nRetCode = false;
CRgn rgMaxFrameRgn;
CRgn rgMinFrameRgn;
CRgn rgInvalidateFrameRgn;
CRect rtWinRect;
CWnd *pWndParent = NULL;
CDC *pDC = NULL;
HWND hWndParent = NULL;
ZOU_PROCESS_ERROR(IsWindow(hWnd));
::GetWindowRect(hWnd, &rtWinRect);
::RedrawWindow(hWnd,
NULL, NULL, 
RDW_INTERNALPAINT | RDW_INVALIDATE | RDW_ERASENOW | 
RDW_UPDATENOW | RDW_ERASE | RDW_FRAME | RDW_ALLCHILDREN
);
hWndParent = GetParent(hWnd);
if(hWndParent)
{
::RedrawWindow(
hWndParent,
NULL, NULL, 
RDW_INTERNALPAINT | RDW_INVALIDATE | RDW_ERASENOW | 
RDW_UPDATENOW | RDW_ERASE | RDW_FRAME | RDW_ALLCHILDREN
);
};
nResult = true;
Exit0:
return nResult;
}

int DrawWindowFrame(HWND hWnd)
{
int nResult = false;
int nRetCode = false;
static CRect rtWinRect;
static CDC DC;
static CPen     pen(PS_SOLID, 3, RGB(255,0,0));
static CPen *pOldPen = NULL;
static HDC hDC = NULL;
ZOU_PROCESS_ERROR(IsWindow(hWnd));
::GetWindowRect(hWnd, &rtWinRect);
hDC = ::GetWindowDC(hWnd);
ZOU_PROCESS_ERROR(hDC);
DC.Attach(hDC);
pOldPen = DC.SelectObject(&pen);
DC.MoveTo(0, 0);
DC.LineTo(rtWinRect.Width(), 0);
DC.LineTo(rtWinRect.Width(), rtWinRect.Height());
DC.LineTo(0, rtWinRect.Height());
DC.LineTo(0, 0);
DC.SelectObject(pOldPen);
DC.DeleteDC();
::ReleaseDC(hWnd, hDC);
nResult = false;
Exit0:
return nResult;
}

来源:python脚本自动迁移

posted @ 2020-06-24 11:23  jiangcheng_15  阅读(238)  评论(0编辑  收藏  举报