How to add a gripper to a PropertySheet?(如何将夹具添加到 PropertySheet?)
问题描述
我有一个派生自 CPropertySheet
的类,我想在对话框的右下角插入一个夹具".
我的对话框已经可以调整大小了,我只是无法插入抓手.
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.
推荐答案
我不知道有没有什么特殊的 API 可以做到这一点.一种选择是手动绘制,然后覆盖 ON_WM_NCHITTEST
并返回 HTBOTTOMRIGHT
以获取夹具的位置.例如:
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);
}
添加到消息映射:
ON_WM_PAINT()
ON_WM_NCHITTEST()
ON_WM_SIZE()
这篇关于如何将夹具添加到 PropertySheet?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:如何将夹具添加到 PropertySheet?
基础教程推荐
- 为 C/C++ 中的项目的 makefile 生成依赖项 2022-01-01
- Windows Media Foundation 录制音频 2021-01-01
- 在 C++ 中循环遍历所有 Lua 全局变量 2021-01-01
- 为什么语句不能出现在命名空间范围内? 2021-01-01
- 如何“在 Finder 中显示"或“在资源管理器中显 2021-01-01
- 管理共享内存应该分配多少内存?(助推) 2022-12-07
- 如何在不破坏 vtbl 的情况下做相当于 memset(this, ...) 的操作? 2022-01-01
- 从 std::cin 读取密码 2021-01-01
- 使用从字符串中提取的参数调用函数 2022-01-01
- 如何使图像调整大小以在 Qt 中缩放? 2021-01-01