簡體   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