繁体   English   中英

CDialog上的可滚动CStatic

[英]Scrollable CStatic on CDialog

我在用于绘制内容的CDialog上有一个CStatic图片控件:

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()中使用它。 滚动时,该控件将绘制空白或具有很多重复的内容。

我基本上是想在CDialog上复制CScrollView的确切行为; 我已经看到了一些与此相关的文章,但是我不想实现CDocument和CView。

我认为使用只读编辑控件要简单得多。

除了滚动之外,这还使用户可以选择和复制部分文本。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM