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

分享知識

與大家一起分享知識

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 史傳紅 閱讀(3878) 評論(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>
            亚洲国产精品久久91精品| 性欧美1819性猛交| 蜜臀va亚洲va欧美va天堂| 男女精品网站| 99日韩精品| 久久精品日韩一区二区三区| 亚洲国产精品va| 亚洲国产日韩在线一区模特| 国产精品国产自产拍高清av王其 | 亚洲精品一区二区在线| 欧美日韩精品一区二区三区| 伊大人香蕉综合8在线视| 欧美日韩一区视频| 久久婷婷人人澡人人喊人人爽| 日韩视频在线永久播放| 巨乳诱惑日韩免费av| 欧美一二三区精品| 久久久综合精品| 欧美一区二区三区婷婷月色| 在线视频亚洲一区| 亚洲精品国产精品国自产在线| 国产日韩精品电影| 久久激五月天综合精品| 亚洲一区二区在线免费观看| 亚洲精品在线观看免费| 亚洲女女做受ⅹxx高潮| 亚洲欧美日韩精品| 亚洲免费在线播放| 久久综合色婷婷| 久久久久久久精| 久久久久88色偷偷免费| 欧美亚洲一区二区三区| 性欧美超级视频| 久久国产精品电影| 欧美视频日韩| 国产精品狠色婷| 一区二区三区在线免费视频| 伊人久久大香线| 亚洲欧美日韩一区二区在线| 亚洲欧美欧美一区二区三区| 久久综合中文| 亚洲免费网址| 欧美视频福利| 夜夜嗨网站十八久久| 一区二区三区鲁丝不卡| 久久久综合网站| 亚洲欧美国产高清| 欧美三日本三级少妇三2023| 亚洲欧洲日韩综合二区| 亚洲免费观看高清完整版在线观看熊| 亚洲欧洲精品一区二区三区| 欧美一级专区| 99在线精品视频在线观看| 女同一区二区| 亚洲高清一区二| 免播放器亚洲一区| 久久动漫亚洲| 狠狠色丁香婷综合久久| 91久久精品美女| 欧美国产日本在线| 亚洲视频二区| 久久亚洲综合| 亚洲电影在线免费观看| 久久中文精品| 一本色道婷婷久久欧美| 国内成人在线| 欧美肥婆在线| 在线一区二区视频| 欧美午夜在线观看| 国内偷自视频区视频综合| 欧美中文字幕不卡| 91久久精品美女| aa级大片欧美| 亚洲国产精品嫩草影院| 亚洲一区二区在线视频| 国产精品久久久久毛片大屁完整版| 国产偷久久久精品专区| 亚洲精品久久| 亚洲美女av黄| 国产精品成人在线| 久久成人精品视频| 久久夜色精品国产亚洲aⅴ| 亚洲电影在线看| 亚洲伦理在线| 国产日韩欧美综合一区| 免费人成精品欧美精品| 欧美福利视频在线| 在线播放国产一区中文字幕剧情欧美| 久久综合五月| 欧美激情亚洲综合一区| 永久免费毛片在线播放不卡| 免费成人黄色| 欧美日韩在线三区| 久久久久久久一区二区| 亚洲欧美激情视频| 亚洲第一成人在线| 噜噜噜久久亚洲精品国产品小说| 毛片基地黄久久久久久天堂| 国精品一区二区三区| 欧美高清免费| 国产精品久久久久久久久久ktv| 久久久精品网| 欧美日韩你懂的| 久久深夜福利免费观看| 欧美日韩三区四区| 免费久久99精品国产自| 欧美午夜免费影院| 欧美韩国日本综合| 国产日韩一区二区三区在线播放| 亚洲激情中文1区| 国产婷婷色一区二区三区| 亚洲精品自在久久| 亚洲国产精品精华液网站| 亚洲欧美日韩国产中文| 在线亚洲国产精品网站| 免费一级欧美片在线观看| 久久国产综合精品| 国产精品国产三级国产| 亚洲人www| 国产精品家教| 亚洲激情在线观看| 亚洲观看高清完整版在线观看| 亚洲视频在线视频| 韩国女主播一区| 亚洲欧美日韩一区二区在线| 在线综合+亚洲+欧美中文字幕| 麻豆国产精品777777在线| 久久久999精品| 久久午夜视频| 国产区在线观看成人精品| 99国产精品99久久久久久粉嫩| 亚洲国产天堂久久综合| 久久最新视频| 欧美不卡视频一区发布| 欧美激情第六页| 免费视频亚洲| 在线观看一区二区视频| 欧美综合二区| 99热在这里有精品免费| 一区二区国产精品| 一本到12不卡视频在线dvd| 欧美激情在线免费观看| 亚洲欧洲日本专区| 在线午夜精品自拍| 国产精品第13页| 亚洲欧美一区二区三区在线| 亚洲欧美日韩系列| 国产欧美 在线欧美| 欧美一区二区三区免费视频| 久久综合九色综合久99| 亚洲国产欧美一区二区三区同亚洲 | 免费亚洲电影在线| 亚洲国产日韩欧美在线动漫| 亚洲肉体裸体xxxx137| 欧美日韩国产麻豆| 亚洲天堂偷拍| 美女国产一区| 亚洲精品小视频| 国产精品久久777777毛茸茸| 亚洲免费在线观看| 欧美成人一区二区三区在线观看| 亚洲国产婷婷香蕉久久久久久99| 欧美女同在线视频| 欧美国产日韩一区二区在线观看| 亚洲国产精品一区制服丝袜 | 欧美国产在线电影| 亚洲一区二区三区午夜| 欧美成人一区二区三区在线观看| 久久精品视频亚洲| 亚洲国产专区校园欧美| 欧美女主播在线| 亚洲男女自偷自拍| 欧美成年人视频网站| 亚洲免费视频观看| 在线国产精品播放| 国产精品久久久999| 久久精品亚洲一区二区| av成人天堂| 欧美国产日韩二区| 欧美一级艳片视频免费观看| 亚洲人成绝费网站色www| 国产欧美69| 欧美日韩一区二区三区视频 | 久久久噜噜噜| 亚洲免费中文字幕| 亚洲免费观看高清完整版在线观看熊 | 亚洲三级影院| 久久国产夜色精品鲁鲁99| 亚洲精一区二区三区| 国产午夜一区二区三区| 欧美日本不卡| 免费高清在线一区| 亚洲欧美电影院| 99视频在线观看一区三区| 欧美成人中文字幕| 久久亚洲视频| 欧美在线网站| 香蕉成人伊视频在线观看| 亚洲无线观看| 宅男噜噜噜66国产日韩在线观看|