日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁 > 人文社科 > 生活经验 >内容正文

生活经验

在对话框中应用CScrollView显示图像

發(fā)布時間:2023/11/27 生活经验 33 豆豆
生活随笔 收集整理的這篇文章主要介紹了 在对话框中应用CScrollView显示图像 小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.

1、用vs2008創(chuàng)建一個基于對話框的工程DialogView;
2、添加一個新類CMyDocument,基類為CDocument;
3、添加一個新類CMyView,基類為CScrollView;
4、修改CMyDocument的頭文件:
#pragma once

// CMyDocument document
class CDialogView;

class CMyDocument : public CDocument
{
?//DECLARE_DYNCREATE(CMyDocument)
?friend class CDialogView;

public:
?CMyDocument();
?DECLARE_DYNCREATE(CMyDocument)
public:
?virtual ~CMyDocument();
#ifndef _WIN32_WCE
?virtual void Serialize(CArchive& ar);?? // overridden for document i/o
#endif
#ifdef _DEBUG
?virtual void AssertValid() const;
#ifndef _WIN32_WCE
?virtual void Dump(CDumpContext& dc) const;
#endif
#endif

protected:
?virtual BOOL OnNewDocument();

?DECLARE_MESSAGE_MAP()
};

5、修改CMyView的頭文件:
#pragma once

?

// CMyView view
class CDialogView;

class CMyView : public CScrollView
{
?//DECLARE_DYNCREATE(CMyView)
?friend class CDialogView;
protected:
?CMyView();?????????? // protected constructor used by dynamic creation
?DECLARE_DYNCREATE(CMyView)
?virtual ~CMyView();

public:
#ifdef _DEBUG
?virtual void AssertValid() const;
#ifndef _WIN32_WCE
?virtual void Dump(CDumpContext& dc) const;
#endif
#endif

protected:
?virtual void OnDraw(CDC* pDC);????? // overridden to draw this view
?virtual void OnInitialUpdate();???? // first time after construct

?DECLARE_MESSAGE_MAP()
};
6、修改DialogView執(zhí)行文件:
?在文件中加入 #include "MyScroll.h"
????????????? #include "MyDocument.h"

BOOL CDialogView::OnInitDialog()
{
?CDialog::OnInitDialog();

?// Add "About..." menu item to system menu.

?// IDM_ABOUTBOX must be in the system command range.
?ASSERT((IDM_ABOUTBOX & 0xFFF0) == IDM_ABOUTBOX);
?ASSERT(IDM_ABOUTBOX < 0xF000);

?CMenu* pSysMenu = GetSystemMenu(FALSE);
?if (pSysMenu != NULL)
?{
??CString strAboutMenu;
??strAboutMenu.LoadString(IDS_ABOUTBOX);
??if (!strAboutMenu.IsEmpty())
??{
???pSysMenu->AppendMenu(MF_SEPARATOR);
???pSysMenu->AppendMenu(MF_STRING, IDM_ABOUTBOX, strAboutMenu);
??}
?}

?// Set the icon for this dialog.? The framework does this automatically
?//? when the application's main window is not a dialog
?SetIcon(m_hIcon, TRUE);???// Set big icon
?SetIcon(m_hIcon, FALSE);??// Set small icon

?// TODO: Add extra initialization here
?CCreateContext pContext;
?CWnd* pFrameWnd = this;
?pContext.m_pCurrentDoc = new CMyDocument;
?pContext.m_pNewViewClass = RUNTIME_CLASS(CMyView);
?CMyView* pView = (CMyView *)((CFrameWnd*)pFrameWnd)->CreateView(&pContext);
?ASSERT(pView);
?pView->m_nMapMode = MM_TEXT;
?pView->ShowWindow(SW_NORMAL);
?CRect rectWindow;
?GetWindowRect(rectWindow);
?rectWindow.right -= 30;
?rectWindow.bottom?? -= 100;
?pView->MoveWindow(rectWindow);

?return TRUE;? // return TRUE? unless you set the focus to a control
}

7、在CMyView的OnDraw函數(shù)中添加代碼:
void CMyView::OnDraw(CDC* pDC)
{
?//CDocument* pDoc = GetDocument();
?// TODO: add draw code here
?CBitmap BK;
?BK.LoadBitmap(IDB_BITMAP1);//需要添加一位圖用于顯示
?CDC MemDC;
?MemDC.CreateCompatibleDC(pDC);
?MemDC.SelectObject(&BK);
?BITMAP bm;
?BK.GetBitmap(&bm);

?pDC->BitBlt(0, 0, bm.bmWidth, bm.bmHeight, &MemDC, 0, 0, SRCCOPY);

?CRect m_Rect;
?GetClientRect(&m_Rect);
?m_Rect.bottom += 100;
?CSize sizeTotal;
?// TODO: calculate the total size of this view
?sizeTotal.cx = bm.bmWidth;
?sizeTotal.cy = bm.bmHeight;
?SetScrollSizes(MM_TEXT, sizeTotal);
}

?參考:http://download.csdn.net/down/610747/jia_xiaoxin
??????????? http://www.codeguru.com/Cpp/W-D/dislog/article.php/c5009/

總結(jié)

以上是生活随笔為你收集整理的在对话框中应用CScrollView显示图像的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯,歡迎將生活随笔推薦給好友。

歡迎分享!

轉(zhuǎn)載請說明來源于"生活随笔",并保留原作者的名字。

本文地址:在对话框中应用CScrollView显示图像