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
Solidgraph.cpp
Package: solidgraph_sources.zip [view]
Upload User: kairuinn
Upload Date: 2009-02-07
Package Size: 2922k
Code Size: 15k
Category:
Graph program
Development Platform:
Visual C++
- // Solidgraph.cpp : Defines the class behaviors for the application.
- //
- #include "stdafx.h"
- #include <shlwapi.h>
- #include "Solidgraph.h"
- #include "MainFrm.h"
- #include "DocManagerEx.h"
- #include "OneDocTemplate.h"
- #include "ChildFrm.h"
- #include "SolidgraphDoc.h"
- #include "SolidgraphView.h"
- #include "ReportChildFrame.h"
- #include "ReportCreatorDoc.h"
- #include "ReportCreatorView.h"
- #ifdef _DEBUG
- #define new DEBUG_NEW
- #endif
- // CSolidgraphApp
- BEGIN_MESSAGE_MAP(CSolidgraphApp, CWinApp)
- ON_COMMAND(ID_APP_ABOUT, OnAppAbout)
- // Standard file based document commands
- ON_COMMAND(ID_FILE_NEW, CWinApp::OnFileNew)
- ON_COMMAND(ID_FILE_OPEN, CWinApp::OnFileOpen)
- ON_COMMAND(ID_FILE_PRINT_SETUP, CWinApp::OnFilePrintSetup)
- ON_COMMAND(ID_REPORT_FILE_NEW, CWinApp::OnFileNew)
- ON_COMMAND(ID_REPORT_FILE_OPEN, CWinApp::OnFileOpen)
- // Standard print setup command
- END_MESSAGE_MAP()
- // CSolidgraphApp construction
- CSolidgraphApp::CSolidgraphApp()
- {
- EnableHtmlHelp();
- //m_main_tree_control = new CGlobalTree;
- m_main_pluginer = new CPluginLoader;
- m_reg_manager = NULL;
- }
- CSolidgraphApp::~CSolidgraphApp()
- {
- if (m_main_pluginer)
- delete m_main_pluginer;
- if (m_main_tree_control)
- delete m_main_tree_control;
- if (m_reg_manager)
- delete m_reg_manager;
- }
- // The one and only CSolidgraphApp object
- CSolidgraphApp theApp;
- bool translate_messages_through_app = false;
- static UINT menuIDs[] =
- {
- 1, // STUB
- ID_FILE_OPEN,
- NULL
- };
- BOOL CSolidgraphApp::InitInstance()
- {
- typedef void(*LPDLLFUNC_START_SPLASH)();
- LPDLLFUNC_START_SPLASH lpfnDllFuncStartSplash = NULL;
- typedef void(*LPDLLFUNC_END_SPLASH)(HWND);
- LPDLLFUNC_END_SPLASH lpfnDllFuncEndSplash = NULL;
- HINSTANCE hDLL = NULL;
- hDLL = AfxLoadLibrary("SplashLib.dll");
- if(hDLL)
- {
- lpfnDllFuncStartSplash = (LPDLLFUNC_START_SPLASH)::GetProcAddress(hDLL,"StartSplash");
- if (!lpfnDllFuncStartSplash)
- {
- AfxFreeLibrary(hDLL);
- hDLL = NULL;
- }
- lpfnDllFuncEndSplash = (LPDLLFUNC_END_SPLASH)::GetProcAddress(hDLL,"EndSplash");
- if (!lpfnDllFuncEndSplash)
- {
- AfxFreeLibrary(hDLL);
- hDLL = NULL;
- }
- lpfnDllFuncStartSplash();
- }
- // InitCommonControls() is required on Windows XP if an application
- // manifest specifies use of ComCtl32.dll version 6 or later to enable
- // visual styles. Otherwise, any window creation will fail.
- InitCommonControls();
- CWinApp::InitInstance();
- m_main_tree_control = new CGlobalTree;
- // Initialize OLE libraries
- if (!AfxOleInit())
- {
- AfxMessageBox(IDP_OLE_INIT_FAILED);
- if(hDLL)
- {
- if (lpfnDllFuncEndSplash)
- lpfnDllFuncEndSplash(NULL);
- AfxFreeLibrary(hDLL);
- hDLL = NULL;
- }
- return FALSE;
- }
- AfxInitRichEdit();
- AfxEnableControlContainer();
- // Standard initialization
- // If you are not using these features and wish to reduce the size
- // of your final executable, you should remove from the following
- // the specific initialization routines you do not need
- // Change the registry key under which our settings are stored
- // TODO: You should modify this string to be something appropriate
- // such as the name of your company or organization
- SetRegistryKey(COMPANY_NAME_FOR_REGISTER);
- m_reg_manager = new CRegisterManager(this);
- LoadStdProfileSettings(4); // Load standard INI file options (including MRU)
- // Register the application's document templates. Document templates
- // serve as the connection between documents, frame windows and views
- m_reg_manager->LoadSettings();
- CEGMenu::SetMenuDrawMode( m_reg_manager->m_register_settings.interface_theme );
- CEGMenu::SetXpBlending(FALSE);
- CEGMenu::SetAcceleratorsDraw(TRUE);
- HMODULE h = ::GetModuleHandle( NULL );
- TCHAR szPath[MAX_PATH];
- GetModuleFileName( h, szPath, MAX_PATH );
- PathRemoveFileSpec(szPath);
- CString tmpStr(szPath);
- tmpStr += "\";
- m_application_Path = tmpStr;
- m_FontsPathsArray.clear();
- sgInitKernel();
- sgC3DObject::AutoTriangulate(true, SG_DELAUNAY_TRIANGULATION);
- LuaRegister();
- sgSetApplicationInterface(this);
- GetFontFiles("");
- /*
- Only in register version
- */
- if (m_main_pluginer)
- m_main_pluginer->LoadAllPlugins();
- m_pDocManager = new CDocManagerEx; // we replace the default doc manager
- COneDocTemplate* pDocTemplateGeometry;
- pDocTemplateGeometry = new COneDocTemplate(IDR_GEOMETRY_TYPE,
- RUNTIME_CLASS(CSolidgraphDoc),
- RUNTIME_CLASS(CChildFrame),
- RUNTIME_CLASS(CSolidgraphView));
- if (!pDocTemplateGeometry)
- {
- if(hDLL)
- {
- if (lpfnDllFuncEndSplash)
- lpfnDllFuncEndSplash(NULL);
- AfxFreeLibrary(hDLL);
- hDLL = NULL;
- }
- return FALSE;
- }
- AddDocTemplate(pDocTemplateGeometry);
- COneDocTemplate* pDocTemplateReport;
- pDocTemplateReport = new COneDocTemplate(IDR_REPORT_TYPE,
- RUNTIME_CLASS(CReportCreatorDoc),
- RUNTIME_CLASS(CReportChildFrame),
- RUNTIME_CLASS(CReportCreatorView));
- if (!pDocTemplateReport)
- {
- if(hDLL)
- {
- if (lpfnDllFuncEndSplash)
- lpfnDllFuncEndSplash(NULL);
- AfxFreeLibrary(hDLL);
- hDLL = NULL;
- }
- return FALSE;
- }
- AddDocTemplate(pDocTemplateReport);
- HBITMAP hBmp = CombineResources( 16, IDB_GEOMETRY_TOOLBAR_TC, NULL );
- BITMAPINFO bi;
- memset( &bi, 0, sizeof(BITMAPINFO) );
- GetBitmapInfo( hBmp, &bi );
- pDocTemplateGeometry->m_NewMenuShared.LoadToolBar( hBmp, CSize( bi.bmiHeader.biWidth, 16 ), menuIDs, CLR_NONE );
- pDocTemplateGeometry->m_NewMenuShared.SetMenuItemBitmap(ID_FILE_OPEN,IDB_DEL_OBJ_TC,AfxGetResourceHandle());
- DeleteObject(hBmp);
- // create main MDI Frame window
- CMainFrame* pMainFrame = new CMainFrame;
- if (!pMainFrame || !pMainFrame->LoadFrame(IDR_MAINFRAME))
- {
- if(hDLL)
- {
- if (lpfnDllFuncEndSplash)
- lpfnDllFuncEndSplash(NULL);
- AfxFreeLibrary(hDLL);
- hDLL = NULL;
- }
- return FALSE;
- }
- m_pMainWnd = pMainFrame;
- // call DragAcceptFiles only if there's a suffix
- // In an MDI app, this should occur immediately after setting m_pMainWnd
- // Enable drag/drop open
- m_pMainWnd->DragAcceptFiles();
- // Enable DDE Execute open
- EnableShellOpen();
- RegisterShellFileTypes();
- // Parse command line for standard shell commands, DDE, file open
- CCommandLineInfo cmdInfo;
- ParseCommandLine(cmdInfo);
- // Dispatch commands specified on the command line. Will return FALSE if
- // app was launched with /RegServer, /Register, /Unregserver or /Unregister.
- //if (cmdInfo.m_strFileName.IsEmpty())
- // cmdInfo.m_nShellCommand = CCommandLineInfo::FileNothing;
- ((CDocManagerEx*)m_pDocManager)->StartApplication(cmdInfo);
- if(hDLL)
- {
- if (lpfnDllFuncEndSplash)
- lpfnDllFuncEndSplash(pMainFrame->m_hWnd);
- AfxFreeLibrary(hDLL);
- hDLL = NULL;
- }
- // The main window has been initialized, so show and update it
- pMainFrame->ShowWindow(SW_SHOWMAXIMIZED);
- pMainFrame->UpdateWindow();
- return TRUE;
- }
- IProgresser* CSolidgraphApp::GetProgresser()
- {return static_cast<CMainFrame*>(m_pMainWnd);}
- ISceneTreeControl* CSolidgraphApp::GetSceneTreeControl()
- {return m_main_tree_control;}
- void CSolidgraphApp::GetFontFiles(CString sPath)
- {
- if (m_FontsPathsArray.size()>=512)
- return;
- CString sStr;
- CString sCurFullPath=m_application_Path;
- sCurFullPath+=sPath;
- sCurFullPath+="*";
- WIN32_FIND_DATA FindData;
- HANDLE hFindFiles=FindFirstFile(sCurFullPath,&FindData);
- if (hFindFiles==INVALID_HANDLE_VALUE) return;
- for(;;)
- {
- if ((strcmp(FindData.cFileName,".")!=0) && (strcmp(FindData.cFileName,"..")!=0))
- {
- if (FindData.dwFileAttributes&FILE_ATTRIBUTE_DIRECTORY)
- {
- sStr=sPath;
- sStr+=FindData.cFileName;
- sStr+="\";
- GetFontFiles(sStr);
- }
- else
- {
- char *ptr=strrchr(FindData.cFileName,'.');
- if (ptr)
- {
- if (strlen(ptr)==4)
- {
- if ((ptr[1]=='s' && ptr[2]=='h' && ptr[3]=='x') ||
- (ptr[1]=='S' && ptr[2]=='H' && ptr[3]=='X')) //镳钼屦赅 疣聒桊屙