📄 uisupport.cpp
字号:
// UISupport.cpp: implementation of the CUISupport class.
//
//////////////////////////////////////////////////////////////////////
#include "stdafx.h"
#include "UISupport.h"
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
CUISupport::CUISupport()
{
}
CUISupport::~CUISupport()
{
}
int CUISupport::GetRealWindow(HWND &hWnd, POINT ptPoint)
{
HWND hWndTop = NULL;
HWND hWndChild = NULL;
POINT ptCooChild = {0};
LONG lWindowStyle = 0;
hWndTop = ::WindowFromPoint(ptPoint);
if(!hWndTop)
{
return -10;
}
ptCooChild = ptPoint;
lWindowStyle = GetWindowLong(hWndTop, GWL_STYLE);
if(
!GetParent(hWndTop) ||
GetDesktopWindow() == GetParent(hWndTop) ||
!(lWindowStyle & WS_CHILDWINDOW)
)
{
hWnd = hWndTop;
}
else
{
hWnd = GetParent(hWndTop);
}
::ScreenToClient(hWnd, &ptCooChild);
typedef HWND (WINAPI *PFN_RealChildWindowFromPoint)(
HWND hwndParent,
POINT ptParentClientCoords
);
PFN_RealChildWindowFromPoint pfnRealChildWindowFromPoint=
(PFN_RealChildWindowFromPoint)GetProcAddress(GetModuleHandle("USER32"),"RealChildWindowFromPoint");
while (true)
{
if(pfnRealChildWindowFromPoint)
{
hWndChild = pfnRealChildWindowFromPoint(hWnd, ptCooChild);
}
else
{
hWndChild = ChildWindowFromPointEx(hWnd, ptCooChild,CWP_SKIPINVISIBLE|CWP_SKIPDISABLED|CWP_SKIPTRANSPARENT);
}
if (hWndChild && (hWndChild != hWnd))
hWnd = hWndChild;
else
break;
}
return 0;
}
HWND CUISupport::GetCurrentWndUnderCursor()
{
HWND hWnd=0;
POINT ptCursorPos={0,};
GetCursorPos(&ptCursorPos);
int nRetCode=CUISupport::GetRealWindow(hWnd,ptCursorPos);
if(nRetCode<0)
{
return 0;
}
return hWnd;
}
int CUISupport::DrawWindowFrame(HWND hWnd)
{
static CRect rtWinRect;
static CDC DC;
static CPen pen(PS_SOLID, 3, RGB(255,0,0));
static CPen *pOldPen = NULL;
static HDC hDC = NULL;
if(!IsWindow(hWnd))
{
return -10;
};
::GetWindowRect(hWnd, &rtWinRect);
hDC = ::GetWindowDC(hWnd);
if(!hDC)
{
return -20;
};
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);
return 0;
}
int CUISupport::RedrawWindowFrame(HWND hWnd)
{
CRgn rgMaxFrameRgn;
CRgn rgMinFrameRgn;
CRgn rgInvalidateFrameRgn;
CRect rtWinRect;
CWnd *pWndParent = NULL;
CDC *pDC = NULL;
HWND hWndParent = NULL;
if(!IsWindow(hWnd))
{
return -10;
};
::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
);
};
return 0;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -