青青草原综合久久大伊人导航_色综合久久天天综合_日日噜噜夜夜狠狠久久丁香五月_热久久这里只有精品

分享知識

與大家一起分享知識

C++博客 首頁 新隨筆 聯系 聚合 管理
  19 Posts :: 3 Stories :: 45 Comments :: 0 Trackbacks

在利用 VC MFC 編程的時候,我們往往能碰到這種情況:在一個模擬程序中(如有些游戲),需要實時顯示一些屬性的值(文字或者圖形),這個時候我們可以重新打開一個對話框(可以是一個模態或者非模態的)來顯示這些信息,本文以模態對話框為例,簡單實現這個技術。以下代碼陰影部分是我利用 ClassWizard 加的,藍色部分是我手工加的。其余是用 MFC 向導生成的:
源代碼下載地址:http://m.shnenglu.com/Files/sscchh-2000/NotifyDialog.rar?

// NotifyDialogView.h : interface of the CNotifyDialogView class

//

/////////////////////////////////////////////////////////////////////////////

?

#if !defined(AFX_NOTIFYDIALOGVIEW_H__8242946E_9215_46D8_8EAC_DFC7452C8076__INCLUDED_)

#define AFX_NOTIFYDIALOGVIEW_H__8242946E_9215_46D8_8EAC_DFC7452C8076__INCLUDED_

?

#if _MSC_VER > 1000

#pragma once

#endif // _MSC_VER > 1000

?

#include "CountDlg.h"

?

class CNotifyDialogView : public CScrollView

{

protected: // create from serialization only

?????? CNotifyDialogView();

?????? DECLARE_DYNCREATE(CNotifyDialogView)

?

// Attributes

public:

?????? CNotifyDialogDoc* GetDocument();

?

?????? CCountDlg *m_pCountDlg;

// Operations

public:

?

// Overrides

?????? // ClassWizard generated virtual function overrides

?????? //{{AFX_VIRTUAL(CNotifyDialogView)

?????? public:

?????? virtual void OnDraw(CDC* pDC);? // overridden to draw this view

?????? virtual BOOL PreCreateWindow(CREATESTRUCT& cs);

?????? protected:

?????? virtual void OnInitialUpdate(); // called first time after construct

?????? virtual BOOL OnPreparePrinting(CPrintInfo* pInfo);

?????? virtual void OnBeginPrinting(CDC* pDC, CPrintInfo* pInfo);

?????? virtual void OnEndPrinting(CDC* pDC, CPrintInfo* pInfo);

?????? //}}AFX_VIRTUAL

?

// Implementation

public:

?????? virtual ~CNotifyDialogView();

#ifdef _DEBUG

?????? virtual void AssertValid() const;

?????? virtual void Dump(CDumpContext& dc) const;

#endif

?

protected:

?

// Generated message map functions

protected:

?????? //{{AFX_MSG(CNotifyDialogView)

?????? afx_msg void OnTimer(UINT nIDEvent);

?????? afx_msg void OnCountDialog();

?????? afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);

?????? afx_msg void OnDestroy();

?????? //}}AFX_MSG

?????? DECLARE_MESSAGE_MAP()

};

?

#ifndef _DEBUG? // debug version in NotifyDialogView.cpp

inline CNotifyDialogDoc* CNotifyDialogView::GetDocument()

?? { return (CNotifyDialogDoc*)m_pDocument; }

#endif

?

/////////////////////////////////////////////////////////////////////////////

?

//{{AFX_INSERT_LOCATION}}

// Microsoft Visual C++ will insert additional declarations immediately before the previous line.

?

#endif // !defined(AFX_NOTIFYDIALOGVIEW_H__8242946E_9215_46D8_8EAC_DFC7452C8076__INCLUDED_)

?

// NotifyDialogView.cpp : implementation of the CNotifyDialogView class

//

?

#include "stdafx.h"

#include "NotifyDialog.h"

?

#include "NotifyDialogDoc.h"

#include "NotifyDialogView.h"

?

#ifdef _DEBUG

#define new DEBUG_NEW

#undef THIS_FILE

static char THIS_FILE[] = __FILE__;

#endif

?

/////////////////////////////////////////////////////////////////////////////

// CNotifyDialogView

?

IMPLEMENT_DYNCREATE(CNotifyDialogView, CScrollView)

?

BEGIN_MESSAGE_MAP(CNotifyDialogView, CScrollView)

?????? //{{AFX_MSG_MAP(CNotifyDialogView)

?????? ON_WM_TIMER()

?????? ON_COMMAND(ID_COUNT_DIALOG, OnCountDialog)

?????? ON_WM_CREATE()

?????? ON_WM_DESTROY()

?????? //}}AFX_MSG_MAP

?????? // Standard printing commands

?????? ON_COMMAND(ID_FILE_PRINT, CScrollView::OnFilePrint)

?????? ON_COMMAND(ID_FILE_PRINT_DIRECT, CScrollView::OnFilePrint)

?????? ON_COMMAND(ID_FILE_PRINT_PREVIEW, CScrollView::OnFilePrintPreview)

END_MESSAGE_MAP()

?

/////////////////////////////////////////////////////////////////////////////

// CNotifyDialogView construction/destruction

?

CNotifyDialogView::CNotifyDialogView()

{

?????? // TODO: add construction code here

?????? m_pCountDlg = NULL;

}

?

CNotifyDialogView::~CNotifyDialogView()

{

}

?

BOOL CNotifyDialogView::PreCreateWindow(CREATESTRUCT& cs)

{

?????? // TODO: Modify the Window class or styles here by modifying

?????? //? the CREATESTRUCT cs

?

?????? return CScrollView::PreCreateWindow(cs);

}

?

/////////////////////////////////////////////////////////////////////////////

// CNotifyDialogView drawing

?

void CNotifyDialogView::OnDraw(CDC* pDC)

{

?????? CNotifyDialogDoc* pDoc = GetDocument();

?????? ASSERT_VALID(pDoc);

?????? // TODO: add draw code for native data here

}

?

void CNotifyDialogView::OnInitialUpdate()

{

?????? CScrollView::OnInitialUpdate();

?

?????? CSize sizeTotal;

?????? // TODO: calculate the total size of this view

?????? sizeTotal.cx = sizeTotal.cy = 100;

?????? SetScrollSizes(MM_TEXT, sizeTotal);

}

?

/////////////////////////////////////////////////////////////////////////////

// CNotifyDialogView printing

?

BOOL CNotifyDialogView::OnPreparePrinting(CPrintInfo* pInfo)

{

?????? // default preparation

?????? return DoPreparePrinting(pInfo);

}

?

void CNotifyDialogView::OnBeginPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)

{

?????? // TODO: add extra initialization before printing

}

?

void CNotifyDialogView::OnEndPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)

{

?????? // TODO: add cleanup after printing

}

?

/////////////////////////////////////////////////////////////////////////////

// CNotifyDialogView diagnostics

?

#ifdef _DEBUG

void CNotifyDialogView::AssertValid() const

{

?????? CScrollView::AssertValid();

}

?

void CNotifyDialogView::Dump(CDumpContext& dc) const

{

?????? CScrollView::Dump(dc);

}

?

CNotifyDialogDoc* CNotifyDialogView::GetDocument() // non-debug version is inline

{

?????? ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CNotifyDialogDoc)));

?????? return (CNotifyDialogDoc*)m_pDocument;

}

#endif //_DEBUG

?

/////////////////////////////////////////////////////////////////////////////

// CNotifyDialogView message handlers

?

void CNotifyDialogView::OnTimer(UINT nIDEvent)

{

?????? // TODO: Add your message handler code here and/or call default

?????? if(m_pCountDlg)

?????? {

????????????? m_pCountDlg->m_dwCount++;

????????????? m_pCountDlg->ShowValue();

?????? }

?

?????? CScrollView::OnTimer(nIDEvent);

}

?

void CNotifyDialogView::OnCountDialog()

{

?????? // TODO: Add your command handler code here

?????? CCountDlg countDlg(this);

?????? countDlg.DoModal();

}

?

int CNotifyDialogView::OnCreate(LPCREATESTRUCT lpCreateStruct)

{

?????? if (CScrollView::OnCreate(lpCreateStruct) == -1)

????????????? return -1;

??????

?????? // TODO: Add your specialized creation code here

?????? SetTimer(1,100,NULL);

?

?????? return 0;

}

?

void CNotifyDialogView::OnDestroy()

{

?????? CScrollView::OnDestroy();

??????

?????? // TODO: Add your message handler code here

?????? KillTimer(1);

}

?

#if !defined(AFX_COUNTDLG_H__C5A72F95_781F_47DC_95D1_A0E9A8473756__INCLUDED_)

#define AFX_COUNTDLG_H__C5A72F95_781F_47DC_95D1_A0E9A8473756__INCLUDED_

?

#if _MSC_VER > 1000

#pragma once

#endif // _MSC_VER > 1000

// CountDlg.h : header file

//

#include "stdafx.h"

?

/////////////////////////////////////////////////////////////////////////////

// CCountDlg dialog

?

class CCountDlg : public CDialog

{

// Construction

public:

?????? CCountDlg(CWnd* pParent = NULL);?? // standard constructor

?

// Dialog Data

?????? //{{AFX_DATA(CCountDlg)

?????? enum { IDD = IDD_DIALOG_COUNT };

?????? DWORDm_dwCount;

?????? //}}AFX_DATA

?

public:

?????? CView *m_pView;

?

// Overrides

?????? // ClassWizard generated virtual function overrides

?????? //{{AFX_VIRTUAL(CCountDlg)

?????? protected:

?????? virtual void DoDataExchange(CDataExchange* pDX);??? // DDX/DDV support

?????? //}}AFX_VIRTUAL

public:????

?????? void ShowValue();

??????

?

// Implementation

protected:

?????? void ReleaseViewPointer();

?????? // Generated message map functions

?????? //{{AFX_MSG(CCountDlg)

?????? afx_msg void OnDestroy();

?????? //}}AFX_MSG

?????? DECLARE_MESSAGE_MAP()

};

?

//{{AFX_INSERT_LOCATION}}

// Microsoft Visual C++ will insert additional declarations immediately before the previous line.

?

#endif // !defined(AFX_COUNTDLG_H__C5A72F95_781F_47DC_95D1_A0E9A8473756__INCLUDED_)

?

// CountDlg.cpp : implementation file

//

?

#include "stdafx.h"

#include "NotifyDialog.h"

#include "CountDlg.h"

?

#include "MainFrm.h"

#include "ChildFrm.h"

#include "NotifyDialogDoc.h"

#include "NotifyDialogView.h"

#ifdef _DEBUG

#define new DEBUG_NEW

#undef THIS_FILE

static char THIS_FILE[] = __FILE__;

#endif

?

/////////////////////////////////////////////////////////////////////////////

// CCountDlg dialog

?

?

CCountDlg::CCountDlg(CWnd* pParent /*=NULL*/)

?????? : CDialog(CCountDlg::IDD, pParent)

{

?????? //{{AFX_DATA_INIT(CCountDlg)

?????? m_dwCount = 0;

?????? //}}AFX_DATA_INIT

?????? m_pView = (CNotifyDialogView*)pParent;

?????? ((CNotifyDialogView*)m_pView)->m_pCountDlg = this;

}

?

?

void CCountDlg::DoDataExchange(CDataExchange* pDX)

{

?????? CDialog::DoDataExchange(pDX);

?????? //{{AFX_DATA_MAP(CCountDlg)

?????? DDX_Text(pDX, IDC_EDIT_COUNT, m_dwCount);

?????? //}}AFX_DATA_MAP

}

?

?

BEGIN_MESSAGE_MAP(CCountDlg, CDialog)

?????? //{{AFX_MSG_MAP(CCountDlg)

?????? ON_WM_DESTROY()

?????? //}}AFX_MSG_MAP

END_MESSAGE_MAP()

?

/////////////////////////////////////////////////////////////////////////////

// CCountDlg message handlers

?

void CCountDlg::ShowValue()

{

?????? UpdateData(FALSE);

}

?

void CCountDlg::ReleaseViewPointer()

{

?????? ((CNotifyDialogView*)m_pView)->m_pCountDlg = NULL;

}

void CCountDlg::OnDestroy()

{

?????? CDialog::OnDestroy();

??????

?????? // TODO: Add your message handler code here

?????? ReleaseViewPointer();

}

posted on 2006-04-28 21:47 史傳紅 閱讀(3881) 評論(2)  編輯 收藏 引用 所屬分類: C/C++細節知識

Feedback

# re: VC中視圖(View)通知對話框(Dialog)的方法 2006-04-28 23:11 flyingxu
其實可以用簡潔的語言代替所有的代碼
而且,如果真的想在一個對話框中顯示實時的值,現在的程序結構上不好。  回復  更多評論
  

# re: VC中視圖(View)通知對話框(Dialog)的方法 2006-04-29 20:15 史傳紅
@flyingxu

由于我以前遇到這個問題沒有解決,現在看了深入淺出MFC這本書,總結出來的,你能給出一個好的結構嗎?我的意思是說把文檔的數據在一個對話框中實時表現出來,謝謝。
  回復  更多評論
  

青青草原综合久久大伊人导航_色综合久久天天综合_日日噜噜夜夜狠狠久久丁香五月_热久久这里只有精品
  • <ins id="pjuwb"></ins>
    <blockquote id="pjuwb"><pre id="pjuwb"></pre></blockquote>
    <noscript id="pjuwb"></noscript>
          <sup id="pjuwb"><pre id="pjuwb"></pre></sup>
            <dd id="pjuwb"></dd>
            <abbr id="pjuwb"></abbr>
            亚洲一区三区在线观看| 亚洲欧美另类中文字幕| 99国产精品私拍| 国产综合自拍| 国产一区视频在线看| 国产有码一区二区| 国产综合婷婷| 一区二区三区在线观看视频| 国色天香一区二区| 在线精品国产欧美| 亚洲人成绝费网站色www| 日韩亚洲欧美一区二区三区| 一区二区激情| 新片速递亚洲合集欧美合集| 欧美在线观看一区二区| 久久久噜噜噜久噜久久| 免费中文日韩| 日韩一级不卡| 久久riav二区三区| 欧美成人精品1314www| 欧美日韩国产免费| 国产亚洲成精品久久| 亚洲国产精品久久久久秋霞影院| 一本色道久久综合亚洲精品婷婷| 亚洲一区二区精品在线观看| 久久9热精品视频| 亚洲国产片色| 亚洲电影免费在线| 一本色道久久综合亚洲二区三区 | 欧美一区二区三区四区视频| 久久九九精品99国产精品| 欧美h视频在线| 国产精品嫩草影院一区二区| 亚洲精品在线免费| 久久精品盗摄| 99re国产精品| 久久99伊人| 欧美三级电影一区| 国产精品久久久久三级| 国产精品最新自拍| 亚洲精品国精品久久99热| 久久久www免费人成黑人精品| 最新日韩在线视频| 欧美亚洲综合另类| 欧美日韩 国产精品| 一区精品久久| 久久国产夜色精品鲁鲁99| 久久久久五月天| 欧美影院一区| 日韩亚洲欧美在线观看| 亚洲图片自拍偷拍| 尤物yw午夜国产精品视频| 亚洲国内精品在线| 国产在线欧美日韩| 免费视频一区| 日韩网站免费观看| 国产欧美欧美| 美女网站在线免费欧美精品| 免费久久久一本精品久久区| 亚洲一级网站| 久久男女视频| 亚洲图片欧美日产| 久久一区欧美| 欧美一区二区视频在线观看| 亚洲伦理在线观看| 亚洲一区二区三区中文字幕在线 | 夜夜嗨av一区二区三区中文字幕| 亚洲一区影音先锋| 久久久噜噜噜久噜久久| 一区二区三区欧美日韩| 午夜亚洲性色视频| 免播放器亚洲一区| 久久国产欧美精品| 欧美日韩国产电影| 久久亚洲私人国产精品va媚药| 欧美人与性禽动交情品| 免费一级欧美在线大片| 国产精品久久久久毛片大屁完整版| 欧美激情精品久久久久久变态| 欧美区一区二区三区| 六月丁香综合| 国产亚洲欧美另类中文| 日韩天堂在线观看| 亚洲欧洲精品一区| 久久免费视频网| 亚洲国产成人一区| 欧美在线免费视频| 午夜激情亚洲| 国产精品免费一区豆花| 中国成人在线视频| 日韩视频一区二区在线观看| 美女脱光内衣内裤视频久久网站| 久久久久久精| 国产欧美视频一区二区| 在线视频欧美一区| 亚洲日本激情| 欧美高清视频一区二区| 欧美二区在线播放| 一本高清dvd不卡在线观看| 亚洲第一久久影院| 久久不见久久见免费视频1| 午夜精品在线看| 国产精品一区二区黑丝| 午夜精品视频| 欧美一区二区三区视频在线观看| 国产精品久久久久999| 亚洲网址在线| 欧美在线www| 樱花yy私人影院亚洲| 美女精品国产| 亚洲免费av片| 亚洲欧美日本国产有色| 国产精品午夜在线| 性做久久久久久| 蜜桃久久精品乱码一区二区| 亚洲精选在线观看| 国产精品v日韩精品| 午夜伦欧美伦电影理论片| 国产精品久久久久久模特| 亚洲欧美另类在线| 久久亚洲色图| 亚洲精品国产精品乱码不99按摩| 欧美日韩mp4| 亚洲图片自拍偷拍| 美女久久网站| aaa亚洲精品一二三区| 国产精品一区二区久久| 久久婷婷av| 日韩视频在线观看免费| 久久电影一区| 亚洲精品在线免费观看视频| 国产精品chinese| 欧美在线资源| 一本久久综合亚洲鲁鲁五月天| 久久国产精品久久久久久久久久| 亚洲狠狠婷婷| 国产欧美日韩精品在线| 噜噜噜久久亚洲精品国产品小说| 亚洲久久视频| 麻豆成人综合网| 亚洲午夜精品一区二区三区他趣 | 久久婷婷影院| 亚洲精品一级| 国产女人18毛片水18精品| 欧美电影免费观看| 欧美在线观看一区二区三区| 一本一本a久久| 免费日韩av片| 久久久天天操| 性xx色xx综合久久久xx| 99国产精品视频免费观看一公开| 韩国女主播一区二区三区| 欧美三级午夜理伦三级中视频| 模特精品裸拍一区| 欧美一区二区精美| 亚洲午夜精品一区二区三区他趣| 欧美激情aaaa| 久久免费精品日本久久中文字幕| 亚洲视频中文| 亚洲精品在线观看视频| 亚洲国产高清aⅴ视频| 国产欧美精品国产国产专区| 欧美午夜片在线观看| 免费中文字幕日韩欧美| 久久久噜噜噜久久中文字幕色伊伊| 亚洲在线网站| 亚洲三级电影全部在线观看高清| 美女精品国产| 久久综合中文色婷婷| 久久精品首页| 亚欧美中日韩视频| 亚洲欧美国产高清va在线播| 国产亚洲精品激情久久| 亚洲欧美综合精品久久成人| 亚洲精品社区| 亚洲承认在线| 亚洲盗摄视频| 欧美电影在线观看| 欧美国产视频在线| 欧美韩日一区二区| 亚洲成人资源网| 亚洲第一网站| 亚洲青涩在线| 日韩午夜三级在线| 在线亚洲自拍| 亚洲一区免费看| 一区二区三区欧美在线| 美女视频黄免费的久久| 久久久久一区二区三区四区| 久久久夜精品| 日韩视频免费观看高清完整版| 欧美日韩国产综合久久| 亚洲美女福利视频网站| 亚洲欧洲日产国产网站| 国产亚洲精品激情久久| 久久久久综合网| 亚洲人成在线观看一区二区| 亚洲国产日韩在线一区模特| 亚洲精品久久久久久久久| 亚洲欧洲日产国产网站|