Code/Resource
Windows Develop
Linux-Unix program
Internet-Socket-Network
Web Server
Browser Client
Ftp Server
Ftp Client
Browser Plugins
Proxy Server
Email Server
Email Client
WEB Mail
Firewall-Security
Telnet Server
Telnet Client
ICQ-IM-Chat
Search Engine
Sniffer Package capture
Remote Control
xml-soap-webservice
P2P
WEB(ASP,PHP,...)
TCP/IP Stack
SNMP
Grid Computing
SilverLight
DNS
Cluster Service
Network Security
Communication-Mobile
Game Program
Editor
Multimedia program
Graph program
Compiler program
Compress-Decompress algrithms
Crypt_Decrypt algrithms
Mathimatics-Numerical algorithms
MultiLanguage
Disk/Storage
Java Develop
assembly language
Applications
Other systems
Database system
Embeded-SCM Develop
FlashMX/Flex
source in ebook
Delphi VCL
OS Develop
MiddleWare
MPI
MacOS develop
LabView
ELanguage
Software/Tools
E-Books
Artical/Document
mainDoc.cpp
Package: ebd_src.zip [view]
Upload User: kelijie
Upload Date: 2007-01-01
Package Size: 123k
Code Size: 6k
Category:
Graph program
Development Platform:
Visual C++
- // mainDoc.cpp : implementation of the CMainDoc class
- //
- #include "stdafx.h"
- #include "main.h"
- #include "mainDoc.h"
- #include "MdDlg.h"
- #ifdef _DEBUG
- #define new DEBUG_NEW
- #undef THIS_FILE
- static char THIS_FILE[] = __FILE__;
- #endif
- /////////////////////////////////////////////////////////////////////////////
- // CMainDoc
- IMPLEMENT_DYNCREATE(CMainDoc, CDocument)
- BEGIN_MESSAGE_MAP(CMainDoc, CDocument)
- //{{AFX_MSG_MAP(CMainDoc)
- ON_COMMAND(IDM_WINDOWLIST, OnWindowlist)
- ON_UPDATE_COMMAND_UI(IDM_WINDOWLIST, OnUpdateWindowlist)
- //}}AFX_MSG_MAP
- END_MESSAGE_MAP()
- /////////////////////////////////////////////////////////////////////////////
- // CMainDoc construction/destruction
- CMainDoc::CMainDoc()
- {
- // TODO: add one-time construction code here
- m_iWndNum = 0;
- }
- CMainDoc::~CMainDoc()
- {
- }
- BOOL CMainDoc::OnNewDocument()
- {
- if (!CDocument::OnNewDocument())
- return FALSE;
- // TODO: add reinitialization code here
- // (SDI documents will reuse this document)
- CFile file;
- char f_name[20];
- int inum;
- static HINSTANCE hinstLib;
- static int uTypeIDD;
- static CString nickname;
- GetModuleInfo* GetInfo;
- CLibInfo* tempInfo;
- if(!file.Open("plugin.sys", CFile::modeRead))
- {
- AfxMessageBox("Can't find plug-in setting");
- return TRUE;
- }
- file.Read(&inum, sizeof(int));
- tempInfo = new CLibInfo[inum];
- for(int i = 0; i < inum; i++)
- {
- file.Read(&f_name, 20*sizeof(char));
- hinstLib = LoadLibrary(f_name);
- GetInfo = (GetModuleInfo*)GetProcAddress(hinstLib,
- _T("GetModuleData"));
- (*GetInfo)(&uTypeIDD, &nickname);
- tempInfo[i].m_hinstLib = hinstLib;
- tempInfo[i].m_uTypeIDD = uTypeIDD;
- tempInfo[i].m_nickName = nickname;
- m_ListLibInfo.Add(&tempInfo[i]);
- }
- file.Close();
- return TRUE;
- }
- /////////////////////////////////////////////////////////////////////////////
- // CMainDoc serialization
- void CMainDoc::Serialize(CArchive& ar)
- {
- if (ar.IsStoring())
- {
- // TODO: add storing code here
- }
- else
- {
- // TODO: add loading code here
- }
- }
- /////////////////////////////////////////////////////////////////////////////
- // CMainDoc diagnostics
- #ifdef _DEBUG
- void CMainDoc::AssertValid() const
- {
- CDocument::AssertValid();
- }
- void CMainDoc::Dump(CDumpContext& dc) const
- {
- CDocument::Dump(dc);
- }
- #endif //_DEBUG
- /////////////////////////////////////////////////////////////////////////////
- // CMainDoc commands
- void CMainDoc::GetMsgFromView(int ID, int pin, CString msg)
- {
- CString str;
- char sid[10];
- char spin[10];
- itoa(ID,sid, 10);
- itoa(pin,spin, 10);
- str = "Type ID:";
- str += sid;
- str += ". Pin:";
- str += spin;
- for(int i = 0; i < m_ListChildFrame.GetSize(); i++)
- {
- CStandardView* pView = (CStandardView*)m_ListChildFrame[i]->GetActiveView();
- if(pView->GetViewID() == ID &&
- pView->GetPinNumber() == pin)
- {
- CString name;
- pView->GetName(&name);
- CString text;
- text = "The main frame get a message from ";
- text += name;
- text += " , which is ";
- text += msg;
- text += " !";
- text += "The child module information is: ";
- text += str;
- str += " Your message is ";
- str += msg;
- pView->GetMsgFromDocument(str);
- }
- }
- return;
- }
- void CMainDoc::ReleaseChildWindow(int ID, int pin)
- {
- for(int i = 0; i < m_ListChildFrame.GetSize(); i++)
- {
- if(m_ListChildFrame[i]->GetTypeID() == ID &&
- m_ListChildFrame[i]->GetIndex() == pin)
- {
- m_ListChildFrame.RemoveAt(i);
- return;
- }
- }
- return;
- }
- void CMainDoc::OnWindowlist()
- {
- // TODO: Add your command handler code here
- WNDINFO wInfo;
- CString name;
- CModuleDlg dlg;
- char str[10];
- for(int i = 0; i < m_ListChildFrame.GetSize(); i++)
- {
- wInfo.m_iID = m_ListChildFrame[i]->GetTypeID();
- wInfo.m_iPin = m_ListChildFrame[i]->GetIndex();
- for(int j = 0; j < m_ListLibInfo.GetSize(); j++)
- {
- if(m_ListLibInfo[j]->m_uTypeIDD == wInfo.m_iID)
- name = m_ListLibInfo[j]->m_nickName;
- }
- name += " : ";
- itoa(wInfo.m_iID, str, 10);
- name += str;
- name += "--";
- itoa(wInfo.m_iPin, str, 10);
- name += str;
- dlg.SetListData(name, wInfo);
- }
- if(dlg.DoModal() == IDOK)
- {
- wInfo.m_iID = dlg.m_wInfo.m_iID;
- wInfo.m_iPin = dlg.m_wInfo.m_iPin;
- UpdateAllViews(NULL, UPDATE_ONE, (CObject*)&wInfo);
- }
- }
- void CMainDoc::OnUpdateWindowlist(CCmdUI* pCmdUI)
- {
- // TODO: Add your command update UI handler code here
- int num = m_ListChildFrame.GetSize();
- pCmdUI->Enable(num > 0);
- }
- void CMainDoc::PopModule(int nID)
- {
- // TODO: Add your command handler code here
- TemplateFunc* SetTemplate;
- HINSTANCE hinstLib;
- int libnum = m_ListLibInfo.GetSize();
- if(libnum == 0 || nID >= libnum || nID < 0)
- return;
- hinstLib = m_ListLibInfo[nID]->m_hinstLib;
- SetTemplate = (TemplateFunc*)GetProcAddress(hinstLib,
- _T("InitTemplate"));
- static CDocTemplate* ChildTemplate;
- static CChildFrame* ChildFrame;
- CChildFrame* TempChildFrame;
- CDocTemplate* TempChildTemplate;
- if(!(*SetTemplate)(&TempChildTemplate))
- {
- AfxMessageBox("Create Template Error!!!");
- return;
- }
- TempChildFrame = (CChildFrame*) TempChildTemplate->CreateNewFrame(this, NULL);
- if(TempChildFrame == NULL)
- {
- AfxMessageBox("Create Frame Error!!!");
- return;
- }
- m_iWndNum++;
- TempChildTemplate->InitialUpdateFrame(TempChildFrame, this, TRUE);
- ChildTemplate = TempChildTemplate;
- ChildFrame = TempChildFrame;
- ChildFrame->SetTypeID(m_ListLibInfo[nID]->m_uTypeIDD);
- ChildFrame->SetIndex(m_iWndNum);
- CStandardView* pView = (CStandardView*)ChildFrame->GetActiveView();
- pView->SetPinNumber(m_iWndNum);
- pView->OnInitialUpdate();
- m_ListChildFrame.Add(ChildFrame);
- }