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

分享知識

與大家一起分享知識

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

在利用 VC MFC 編程的時候,我們往往能碰到這種情況:在一個模擬程序中(如有些游戲),需要實時顯示一些屬性的值(文字或者圖形),這個時候我們可以重新打開一個對話框(可以是一個模態(tài)或者非模態(tài)的)來顯示這些信息,本文以模態(tài)對話框為例,簡單實現(xiàn)這個技術(shù)。以下代碼陰影部分是我利用 ClassWizard 加的,藍色部分是我手工加的。其余是用 MFC 向?qū)傻模?br />源代碼下載地址: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 史傳紅 閱讀(3892) 評論(2)  編輯 收藏 引用 所屬分類: C/C++細節(jié)知識

Feedback

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

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

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

青青草原综合久久大伊人导航_色综合久久天天综合_日日噜噜夜夜狠狠久久丁香五月_热久久这里只有精品
  • <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>
            亚洲影院免费| 亚洲图片欧美一区| 国产精品捆绑调教| 欧美黑人一区二区三区| 国产伦精品一区二区三区视频黑人| 老**午夜毛片一区二区三区| 欧美日韩专区| 亚洲国产一区二区三区高清| 国产在线不卡| 一区二区三区视频观看| 亚洲视频一区二区在线观看| 欧美成ee人免费视频| 蜜桃av久久久亚洲精品| 狠狠88综合久久久久综合网| 亚洲一区二区在线免费观看视频| 亚洲特级片在线| 欧美日韩激情小视频| 亚洲黄色性网站| 亚洲人人精品| 欧美电影在线播放| 亚洲三级免费观看| 亚洲乱码视频| 欧美成人精品一区二区| 亚洲国产高清一区| 久久久久久亚洲精品中文字幕 | 欧美激情一二三区| 精品二区视频| 麻豆成人精品| 欧美黄色影院| 亚洲美女区一区| 欧美国产91| 99在线|亚洲一区二区| 一区二区三区三区在线| 欧美三级在线| 亚洲欧美日韩一区在线观看| 亚洲免费在线精品一区| 久久在线观看视频| 在线成人av.com| 国产精品都在这里| 欧美韩国日本综合| 夜夜爽99久久国产综合精品女不卡| 亚洲黄色高清| 国内偷自视频区视频综合| 欧美日精品一区视频| 麻豆成人综合网| 久久av一区二区三区漫画| 一本到12不卡视频在线dvd| 欧美高清在线精品一区| 久久婷婷色综合| 欧美中文字幕视频| 亚洲欧美日韩精品久久久| 日韩视频免费观看| 亚洲盗摄视频| 揄拍成人国产精品视频| 国产日韩专区在线| 国产精品日韩欧美一区二区三区| 欧美伦理a级免费电影| 免费在线观看日韩欧美| 久久久久久夜精品精品免费| 亚洲欧美综合另类中字| 亚洲综合色噜噜狠狠| 中文精品一区二区三区| 99精品99| 99热这里只有精品8| 亚洲免费观看| 亚洲精品少妇| 99在线精品观看| 日韩亚洲欧美中文三级| 亚洲美女诱惑| 一本大道久久a久久综合婷婷| 亚洲日本中文字幕免费在线不卡| 亚洲国产成人精品久久久国产成人一区| 麻豆乱码国产一区二区三区| 久久久蜜桃精品| 久久久午夜电影| 久久夜色精品国产| 美女尤物久久精品| 欧美电影在线播放| 亚洲国产三级| 亚洲精品自在久久| 一区二区三区www| 亚洲性视频h| 西瓜成人精品人成网站| 久久国产一区二区| 欧美电影免费观看| 欧美日韩综合一区| 国产欧美一区二区三区在线老狼| 国产日韩精品一区二区三区在线| 国产亚洲激情视频在线| 影音先锋在线一区| 亚洲毛片一区二区| 亚洲欧美国产va在线影院| 久久精品1区| 亚洲高清在线播放| 亚洲深夜福利在线| 久久久久久穴| 欧美日韩一区在线| 国产亚洲精品资源在线26u| 亚洲国产成人精品女人久久久| 99riav久久精品riav| 亚洲欧美韩国| 欧美大片18| 亚洲午夜在线观看视频在线| 欧美在线一二三| 欧美精品在线极品| 国产欧美在线观看| 最新高清无码专区| 性伦欧美刺激片在线观看| 欧美v日韩v国产v| 一区二区av在线| 久久久久久97三级| 欧美调教视频| 亚洲二区三区四区| 午夜精彩视频在线观看不卡| 欧美91福利在线观看| 亚洲天堂av在线免费| 久久亚洲精品一区二区| 亚洲一区国产| 欧美大尺度在线观看| 国产欧美日韩一级| 99视频一区二区三区| 久久久蜜臀国产一区二区| 亚洲精品一线二线三线无人区| 欧美一区二区三区四区在线观看| 欧美成人综合一区| 国产在线精品二区| 亚洲伊人观看| 亚洲国产精品一区| 久久精品盗摄| 国产精品一区久久久| 一本色道久久88精品综合| 农夫在线精品视频免费观看| 亚洲影院在线观看| 欧美日韩一区二区视频在线| 亚洲国产视频直播| 久久婷婷激情| 欧美淫片网站| 国产精品视频一区二区三区| 一本久道久久综合婷婷鲸鱼| 欧美成人午夜| 久久人91精品久久久久久不卡| 国产精品有限公司| 亚洲综合第一| 一本久久a久久精品亚洲| 欧美国产91| 亚洲精品女av网站| 欧美激情国产高清| 猛男gaygay欧美视频| 黑人一区二区| 葵司免费一区二区三区四区五区| 亚洲欧美在线视频观看| 国产精品视频久久久| 亚洲主播在线观看| 在线亚洲免费| 国产精品久久久久久超碰 | 欧美激情一区二区三区不卡| 亚洲高清av在线| 欧美成人午夜影院| 噜噜噜91成人网| 有坂深雪在线一区| 欧美成人免费网站| 免费日韩av片| 日韩视频一区二区三区在线播放免费观看 | 国内精品久久久久久久果冻传媒| 欧美亚洲免费电影| 亚洲欧洲av一区二区| 国产香蕉久久精品综合网| 久久精品国产亚洲a| 久久精品在线播放| 在线免费观看日本欧美| 欧美国产精品| 欧美精品日韩| 亚洲视频在线二区| 亚洲欧美视频一区| 精品999成人| 亚洲第一页在线| 欧美午夜精品久久久久久人妖| 在线亚洲激情| 亚洲欧美日韩第一区| 国产一区二区中文| 欧美二区乱c少妇| 欧美日韩成人| 欧美一区三区二区在线观看| 久久国产一区二区三区| 亚洲日本中文字幕区| 日韩午夜一区| 国产午夜精品久久久| 欧美大片一区二区| 欧美三级第一页| 久久精品在线| 欧美成人一区二免费视频软件| 在线亚洲精品福利网址导航| 午夜精品美女久久久久av福利| 亚洲国产91| 中文精品一区二区三区| 狠狠综合久久| 一区二区日韩伦理片| 禁断一区二区三区在线| 日韩亚洲国产欧美| 一色屋精品视频在线观看网站|