CDialog上的可滚动CStatic
Scrollable CStatic on CDialog
我有一个CStatic图片控件在一个CDialog,我用它来绘制内容:
CMyDrawingControl.h
CMyDrawingControl : CStatic
{
//Constructor, Destructor, other items
//End Constructor, Destructor, other items
public:
void DrawStuff(CDC *dc);
protected:
afx_msg void OnPaint();
afx_msg void OnVScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar)
}
CMyDrawingControl.cpp
CMyDrawingControl::CMyDrawingControl
{
}
BEGIN_MESSAGE_MAP(CMyDrawingControl, CStatic)
//{{AFX_MSG_MAP(CMyDrawingControl)
ON_WM_VSCROLL()
ON_WM_PAINT()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
void CMyDrawingControl::OnVScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar)
{
//determine delta
ScrollWindow(0, -delta);
Invalidate();
UpdateWindow();
}
void CMyDrawingControl::OnPaint()
{
CPaint dc(this);
DrawStuff(&dc);
}
void CMyDrawingControl::DrawStuff(CDC *dc)
{
dc->SetMapMode(MM_LOMETRIC);
//draw on dc
//text, lines, shapes, etc
}
然而,内容通常比控件大,所以我需要能够滚动内容。CScrollView通过在OnDraw中绘制视图自动处理,但我似乎无法让它在OnPaint()中工作。滚动时,控件要么绘制空白,要么有很多重复的内容。
我基本上试图复制CScrollView对CDialog的确切行为;我看到过一些帖子接近这个,但我不想实现一个CDocument和一个CView。
我认为使用只读编辑控件要简单得多。
除了滚动,这也使得用户可以选择和复制部分文本。
相关文章:
- 使用一个考虑到std::map中键值的滚动或换行的键
- QScrollArea:由垂直滚动条引起的水平滚动条
- 跟踪滚动条上的鼠标事件
- 如何在不使用滚动条的情况下使视图更改
- 如何为对象生成滚动效果?
- 如何模拟不同边数的骰子滚动?
- 如何初始化升压滚动窗口累加器?
- 实现包含多个 QQuickPaintedItems 的 QQuickView 的滚动
- 通过水平滚动条更改标签
- 如何防止 Windows 控制台上的回车键自动滚动
- Qt:无法直接为带有子项的小部件添加滚动条
- OnVScroll : 从 CSpinButtonCtrl 或垂直滚动条调用?
- win32 滚动条在 C/C++ 程序中不起作用
- 为什么玩家控制器"own"偏航俯仰和滚动,但角色"owns"它的位置?
- 外观 MFC 滚动条
- 我在QChartView中找不到缩放图形的鼠标滚轮滚动事件
- 如何使用C++获取/设置OBS中的垂直滚动过滤器属性?
- 停止 QTextCursor::insertText() 修改 QTextDocument 滚动条范围
- 如何在控制台应用程序中添加滚动功能以显示更大的输入
- CDialog上的可滚动CStatic