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

分享知識

與大家一起分享知識

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

在利用 VC MFC 編程的時候,我們往往能碰到這種情況:在一個模擬程序中(如有些游戲),需要實時顯示一些屬性的值(文字或者圖形),這個時候我們可以重新打開一個對話框(可以是一個模態或者非模態的)來顯示這些信息,本文以模態對話框為例,簡單實現這個技術。以下代碼陰影部分是我利用 ClassWizard 加的,藍色部分是我手工加的。其余是用 MFC 向導生成的:
源代碼下載地址:http://www.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 史傳紅 閱讀(3886) 評論(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>
            欧美成人综合网站| 亚洲国产成人av| 中日韩视频在线观看| 欧美日韩国产成人高清视频| 一区二区免费在线播放| 夜久久久久久| 国产精品入口尤物| 久久网站免费| 免费亚洲一区| 中文一区二区在线观看| 亚洲一区视频在线| 国模一区二区三区| 欧美大秀在线观看| 欧美午夜精品| 麻豆精品91| 欧美日本高清视频| 欧美一区二区免费| 久久午夜激情| 亚洲永久免费观看| 久久精品欧美日韩| 在线亚洲美日韩| 久久久av网站| 亚洲美女少妇无套啪啪呻吟| 亚洲综合丁香| 亚洲精品日韩综合观看成人91| 夜夜嗨av一区二区三区四区| 国产在线日韩| 一区二区三区产品免费精品久久75 | 欧美韩国在线| 欧美精品福利| 一本色道久久99精品综合| 午夜久久资源| 日韩视频免费大全中文字幕| 午夜精品久久久久久久久| 亚洲免费黄色| 久久久国产精彩视频美女艺术照福利| 99视频在线观看一区三区| 午夜国产欧美理论在线播放 | 欧美日韩精品免费观看视一区二区| 亚洲欧美电影院| 欧美大片免费久久精品三p | 99re66热这里只有精品4| 午夜精品三级视频福利| 在线视频免费在线观看一区二区| 久久久久国产精品麻豆ai换脸| 一本色道久久综合一区| 可以看av的网站久久看| 欧美在线视频观看免费网站| 欧美另类一区二区三区| 欧美波霸影院| 黄色国产精品| 久久av一区二区三区| 亚洲欧美日韩精品久久奇米色影视| 欧美.www| 亚洲高清免费在线| 91久久久亚洲精品| 久久久99精品免费观看不卡| 久久国产精品毛片| 国产精品揄拍一区二区| 亚洲一区欧美一区| 亚洲夜间福利| 国产精品白丝jk黑袜喷水| 日韩亚洲一区在线播放| 日韩亚洲精品电影| 欧美理论视频| 日韩一级不卡| 亚洲一区日韩在线| 国产精品美女一区二区| 亚洲女同在线| 久久精品国产综合精品| 国产一区二区在线观看免费播放| 亚洲欧美激情精品一区二区| 久久aⅴ国产欧美74aaa| 国产一区视频网站| 欧美综合77777色婷婷| 免费观看成人| 亚洲看片一区| 欧美日一区二区三区在线观看国产免| 亚洲精品中文字幕在线| 中文亚洲免费| 国产日韩欧美高清免费| 久久久99国产精品免费| 欧美国产精品v| av成人毛片| 国产精品最新自拍| 久久精品国内一区二区三区| 欧美国产日韩一区二区三区| av不卡免费看| 国产女主播在线一区二区| 久久久久久久91| 91久久精品www人人做人人爽| 亚洲视频一区二区在线观看| 国产精一区二区三区| 久久全国免费视频| 亚洲精品日产精品乱码不卡| 午夜一区不卡| 亚洲第一精品影视| 欧美三级在线视频| 久久国产精品毛片| 亚洲美女色禁图| 久久精品主播| 一区二区三区国产精华| 国产中文一区二区| 欧美日韩性生活视频| 久久er99精品| 一区二区三区黄色| 欧美成人免费在线| 午夜精品久久久久久久久久久久久| 激情文学一区| 国产精品一区二区男女羞羞无遮挡| 久久精品91久久香蕉加勒比| 亚洲精选中文字幕| 免播放器亚洲一区| 欧美亚洲一区二区三区| 亚洲精品一区二区三区福利| 国产日韩欧美在线看| 欧美激情中文字幕在线| 久久久久久久综合狠狠综合| 宅男噜噜噜66一区二区| 亚洲激情第一区| 久久综合国产精品| 欧美呦呦网站| 亚洲女女做受ⅹxx高潮| 日韩一级不卡| 91久久精品www人人做人人爽| 国产色产综合产在线视频| 欧美日韩在线三区| 欧美激情精品久久久| 久久久亚洲综合| 欧美在线一二三四区| 亚洲一区久久| 一区二区精品在线观看| 亚洲美女一区| 亚洲日本在线观看| 亚洲国产一区二区在线| 模特精品在线| 欧美aaa级| 欧美成人精品在线播放| 蜜月aⅴ免费一区二区三区| 久久一二三四| 久久尤物视频| 久久精品人人| 久久久欧美精品| 久久久亚洲一区| 久久网站免费| 欧美成人情趣视频| 欧美激情自拍| 亚洲激情视频| 99视频在线精品国自产拍免费观看| 亚洲国产一区二区三区高清| 亚洲大胆美女视频| 亚洲理伦在线| 亚洲午夜av电影| 亚洲免费在线播放| 久久福利一区| 欧美成ee人免费视频| 欧美精品免费在线观看| 欧美日韩精品一区二区三区四区| 欧美精品网站| 国产精品一区二区在线观看| 国产日产亚洲精品| 在线激情影院一区| 亚洲另类视频| 亚洲一区不卡| 久久夜色精品国产欧美乱| 欧美sm视频| 亚洲毛片一区| 亚洲欧洲99久久| 免费h精品视频在线播放| 欧美精品成人| 国产一级揄自揄精品视频| 18成人免费观看视频| 夜夜嗨av色一区二区不卡| 亚洲欧美视频一区| 久久综合给合久久狠狠狠97色69| 欧美激情一区在线观看| 在线中文字幕日韩| 久久久人成影片一区二区三区| 欧美精品国产精品日韩精品| 国产精品久线观看视频| 在线观看欧美亚洲| 亚洲综合激情| 欧美激情一区| 欧美一级片久久久久久久| 欧美高潮视频| 国产主播一区二区| 亚洲一级黄色av| 亚洲第一久久影院| 先锋影音一区二区三区| 欧美精品激情在线| 狠狠久久亚洲欧美专区| 亚洲在线成人精品| 亚洲国产成人av在线| 欧美亚洲在线观看| 欧美午夜免费| 亚洲精品韩国| 欧美aa在线视频| 欧美一级片久久久久久久| 欧美三区免费完整视频在线观看| 亚洲电影在线看|