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.
Asked
Active
Viewed 249 times
3

Penachia
- 389
- 4
- 18
1 Answers
2
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()

Barmak Shemirani
- 30,904
- 6
- 40
- 77
-
Thanks its working. but i commented the first if (Linker problems). Why do i need the first if? – Penachia Apr 26 '16 at 18:20
-
1Yes you can remove `OpenThemeData` and other theme functions if you don't want it. The two methods draw the gripper image slightly differently. `DrawThemeBackground` draws it the same way as Notepad's gripper, as seen when Visual Style is enabled. – Barmak Shemirani Apr 26 '16 at 18:34
-
I like to use `m_bmpResize.LoadOEMBitmap(OBM_SIZE);` and then assign it to a `CStatic` but I can't get the rendering correct when resizing. – Andrew Truckle Jun 20 '18 at 22:23
-
@AndrewTruckle `DrawThemeBackground` draws a themed gripper, like in OpenSaveDialog. Comment that out and use `DrawFrameControl` if you want the old look. – Barmak Shemirani Jun 20 '18 at 22:27
-
I will look tomorrow. Start new question if needed. – Andrew Truckle Jun 20 '18 at 22:48
-
@BarmakShemirani Look here: https://stackoverflow.com/questions/50965899/adding-a-resize-anchor-to-derived-cmfcpropertysheet-class – Andrew Truckle Jun 21 '18 at 10:09
-
I also tried your exact code and I still get rendering issues. – Andrew Truckle Jun 21 '18 at 14:41