I have a class derived from CPropertySheet
, and i want to insert a "gripper" on the bottom right of the dialog.
my dialog already is resizable, i just can't insert the gripper.
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
回答1:
I don't know if there are any special APIs to do that. One option is to draw it manually, then override ON_WM_NCHITTEST
and return HTBOTTOMRIGHT
for gripper's position. For example:
void CMyDialog::OnPaint()
{
CPaintDC dc(this);
CRect rc;
GetClientRect();
rc.left = rc.right - ::GetSystemMetrics(SM_CXHSCROLL);
rc.top = rc.bottom - ::GetSystemMetrics(SM_CYVSCROLL);
HTHEME ht = OpenThemeData(m_hWnd, L"STATUS");
if (ht)
{
DrawThemeBackground(ht, dc, SP_GRIPPER, 0, &rc, 0);
CloseThemeData(ht);
}
else
{
dc.DrawFrameControl(rc, DFC_SCROLL, DFCS_SCROLLSIZEGRIP);
}
}
LRESULT CMyDialog::OnNcHitTest(CPoint point)
{
CRect rc;
GetWindowRect(rc);
rc.left = rc.right - ::GetSystemMetrics(SM_CXHSCROLL);
rc.top = rc.bottom - ::GetSystemMetrics(SM_CYVSCROLL);
if (rc.PtInRect(point))
return HTBOTTOMRIGHT;
return CDialog::OnNcHitTest(point);
}
void CMyDialog::OnSize(UINT type, int cx, int cy)
{
CDialog::OnSize(type, cx, cy);
Invalidate(TRUE);
}
Add to message map:
ON_WM_PAINT()
ON_WM_NCHITTEST()
ON_WM_SIZE()