[Sphere-axis-commits] CVS: Utilities/CCWizard CCWizard.cpp,NONE,1.1 CCWizard.h,NONE,1.1 CCWizard.rc,
Brought to you by:
pesterle
Update of /cvsroot/sphere-axis/Utilities/CCWizard In directory sc8-pr-cvs1:/tmp/cvs-serv5884 Added Files: CCWizard.cpp CCWizard.h CCWizard.rc CCWizard.vcproj CCWizardDlg.cpp CCWizardDlg.h resource.h stdafx.cpp stdafx.h Log Message: Initial check-in of CCWizard code --- NEW FILE: CCWizard.cpp --- // CCWizard.cpp : Defines the class behaviors for the application. // #include "stdafx.h" #include "CCWizard.h" #include "CCWizardDlg.h" #ifdef _DEBUG #define new DEBUG_NEW #endif // CCCWizardApp BEGIN_MESSAGE_MAP(CCCWizardApp, CWinApp) ON_COMMAND(ID_HELP, CWinApp::OnHelp) END_MESSAGE_MAP() // CCCWizardApp construction CCCWizardApp::CCCWizardApp() { // TODO: add construction code here, // Place all significant initialization in InitInstance } // The one and only CCCWizardApp object CCCWizardApp theApp; // CCCWizardApp initialization BOOL CCCWizardApp::InitInstance() { // 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(); AfxEnableControlContainer(); CCCWizardDlg dlg; m_pMainWnd = &dlg; INT_PTR nResponse = dlg.DoModal(); if (nResponse == IDOK) { // TODO: Place code here to handle when the dialog is // dismissed with OK } else if (nResponse == IDCANCEL) { // TODO: Place code here to handle when the dialog is // dismissed with Cancel } // Since the dialog has been closed, return FALSE so that we exit the // application, rather than start the application's message pump. return FALSE; } --- NEW FILE: CCWizard.h --- // CCWizard.h : main header file for the PROJECT_NAME application // #pragma once #ifndef __AFXWIN_H__ #error include 'stdafx.h' before including this file for PCH #endif #include "resource.h" // main symbols // CCCWizardApp: // See CCWizard.cpp for the implementation of this class // class CCCWizardApp : public CWinApp { public: CCCWizardApp(); // Overrides public: virtual BOOL InitInstance(); // Implementation DECLARE_MESSAGE_MAP() }; extern CCCWizardApp theApp; --- NEW FILE: CCWizard.rc --- // Microsoft Visual C++ generated resource script. // #include "resource.h" #define APSTUDIO_READONLY_SYMBOLS ///////////////////////////////////////////////////////////////////////////// // // Generated from the TEXTINCLUDE 2 resource. // #include "afxres.h" ///////////////////////////////////////////////////////////////////////////// #undef APSTUDIO_READONLY_SYMBOLS ///////////////////////////////////////////////////////////////////////////// // English (U.S.) resources #if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU) #ifdef _WIN32 LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US #pragma code_page(1252) #endif //_WIN32 #ifdef APSTUDIO_INVOKED ///////////////////////////////////////////////////////////////////////////// // // TEXTINCLUDE // 1 TEXTINCLUDE BEGIN "resource.h\0" END 2 TEXTINCLUDE BEGIN "#include ""afxres.h""\r\n" "\0" END 3 TEXTINCLUDE BEGIN "#define _AFX_NO_SPLITTER_RESOURCES\r\n" "#define _AFX_NO_OLE_RESOURCES\r\n" "#define _AFX_NO_TRACKER_RESOURCES\r\n" "#define _AFX_NO_PROPERTY_RESOURCES\r\n" "\r\n" "#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)\r\n" "LANGUAGE 9, 1\r\n" "#pragma code_page(1252)\r\n" "#include ""res\\CCWizard.rc2"" // non-Microsoft Visual C++ edited resources\r\n" "#include ""afxres.rc"" // Standard components\r\n" "#endif\r\n" "\0" END #endif // APSTUDIO_INVOKED ///////////////////////////////////////////////////////////////////////////// // // Icon // // Icon with lowest ID value placed first to ensure application icon // remains consistent on all systems. IDR_MAINFRAME ICON "res\\CCWizard.ico" ///////////////////////////////////////////////////////////////////////////// // // Dialog // IDD_ABOUTBOX DIALOGEX 0, 0, 235, 55 STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_CAPTION | WS_SYSMENU CAPTION "About CCWizard" FONT 8, "MS Shell Dlg", 0, 0, 0x1 BEGIN ICON IDR_MAINFRAME,IDC_STATIC,11,17,20,20 LTEXT "CCWizard Version 1.0",IDC_STATIC,40,10,119,8, SS_NOPREFIX LTEXT "Copyright (C) 2003 Philip A. Esterle",IDC_STATIC,40,25, 188,8 DEFPUSHBUTTON "OK",IDOK,178,7,50,16,WS_GROUP END IDD_CCWIZARD_DIALOG DIALOGEX 0, 0, 320, 200 STYLE DS_SETFONT | DS_FIXEDSYS | WS_MINIMIZEBOX | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU | WS_THICKFRAME EXSTYLE WS_EX_APPWINDOW CAPTION "CCWizard" FONT 8, "MS Shell Dlg", 0, 0, 0x1 BEGIN EDITTEXT IDC_OUTPUTPATH,55,15,145,14,ES_AUTOHSCROLL PUSHBUTTON "Browse",IDC_BROWSEPATH,205,16,45,12 EDITTEXT IDC_LIBRARYNAME,56,41,97,13,ES_AUTOHSCROLL EDITTEXT IDC_CLASSNAME,56,56,98,14,ES_AUTOHSCROLL CONTROL "C++",IDC_RADIO1,"Button",BS_AUTORADIOBUTTON | WS_GROUP, 29,84,31,10 CONTROL "C#",IDC_RADIO2,"Button",BS_AUTORADIOBUTTON,67,84,26,10 CONTROL "VB",IDC_RADIO3,"Button",BS_AUTORADIOBUTTON,105,84,24,10 PUSHBUTTON "Create Files",IDC_CREATEFILES,161,82,57,15 PUSHBUTTON "Finished",IDOK,263,7,50,16 LTEXT "Library Name",IDC_STATIC,12,43,44,8 LTEXT "Class Name",IDC_STATIC,18,59,38,8 GROUPBOX "Static",IDC_STATIC,7,32,151,41 GROUPBOX "Language Properties",IDC_STATIC,7,73,151,26 EDITTEXT IDC_STATUS,7,101,306,92,ES_MULTILINE | ES_AUTOHSCROLL | ES_READONLY GROUPBOX "Output",IDC_STATIC,7,7,249,26 LTEXT "Output Path",IDC_STATIC,13,18,40,8 END ///////////////////////////////////////////////////////////////////////////// // // Version // VS_VERSION_INFO VERSIONINFO FILEVERSION 1,0,0,1 PRODUCTVERSION 1,0,0,1 FILEFLAGSMASK 0x3fL #ifdef _DEBUG FILEFLAGS 0x1L #else FILEFLAGS 0x0L #endif FILEOS 0x4L FILETYPE 0x1L FILESUBTYPE 0x0L BEGIN BLOCK "StringFileInfo" BEGIN BLOCK "040904e4" BEGIN VALUE "CompanyName", "TODO: <Company name>" VALUE "FileDescription", "TODO: <File description>" VALUE "FileVersion", "1.0.0.1" VALUE "InternalName", "CCWizard.exe" VALUE "LegalCopyright", "TODO: (c) <Company name>. All rights reserved." VALUE "OriginalFilename", "CCWizard.exe" VALUE "ProductName", "TODO: <Product name>" VALUE "ProductVersion", "1.0.0.1" END END BLOCK "VarFileInfo" BEGIN VALUE "Translation", 0x409, 1252 END END ///////////////////////////////////////////////////////////////////////////// // // DESIGNINFO // #ifdef APSTUDIO_INVOKED GUIDELINES DESIGNINFO BEGIN IDD_ABOUTBOX, DIALOG BEGIN LEFTMARGIN, 7 RIGHTMARGIN, 228 TOPMARGIN, 7 BOTTOMMARGIN, 48 END IDD_CCWIZARD_DIALOG, DIALOG BEGIN LEFTMARGIN, 7 RIGHTMARGIN, 313 TOPMARGIN, 7 BOTTOMMARGIN, 193 END END #endif // APSTUDIO_INVOKED ///////////////////////////////////////////////////////////////////////////// // // RT_MANIFEST // IDR_MANIFEST RT_MANIFEST "res\\CCWizard.manifest" ///////////////////////////////////////////////////////////////////////////// // // String Table // STRINGTABLE BEGIN IDS_ABOUTBOX "&About CCWizard..." END #endif // English (U.S.) resources ///////////////////////////////////////////////////////////////////////////// #ifndef APSTUDIO_INVOKED ///////////////////////////////////////////////////////////////////////////// // // Generated from the TEXTINCLUDE 3 resource. // #define _AFX_NO_SPLITTER_RESOURCES #define _AFX_NO_OLE_RESOURCES #define _AFX_NO_TRACKER_RESOURCES #define _AFX_NO_PROPERTY_RESOURCES #if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU) LANGUAGE 9, 1 #pragma code_page(1252) #include "res\CCWizard.rc2" // non-Microsoft Visual C++ edited resources #include "afxres.rc" // Standard components #endif ///////////////////////////////////////////////////////////////////////////// #endif // not APSTUDIO_INVOKED --- NEW FILE: CCWizard.vcproj --- <?xml version="1.0" encoding = "Windows-1252"?> <VisualStudioProject ProjectType="Visual C++" Version="7.00" Name="CCWizard" ProjectGUID="{D87556C2-D080-4D6D-B2DA-5EDFACA64397}" Keyword="MFCProj"> <Platforms> <Platform Name="Win32"/> </Platforms> <Configurations> <Configuration Name="Debug|Win32" OutputDirectory="Debug" IntermediateDirectory="Debug" ConfigurationType="1" UseOfMFC="1" CharacterSet="2"> <Tool Name="VCCLCompilerTool" Optimization="0" PreprocessorDefinitions="WIN32;_WINDOWS;_DEBUG" MinimalRebuild="TRUE" BasicRuntimeChecks="3" RuntimeLibrary="1" TreatWChar_tAsBuiltInType="TRUE" UsePrecompiledHeader="3" WarningLevel="3" Detect64BitPortabilityProblems="TRUE" DebugInformationFormat="4"/> <Tool Name="VCCustomBuildTool"/> <Tool Name="VCLinkerTool" AdditionalDependencies="rpcrt4.lib" LinkIncremental="2" GenerateDebugInformation="TRUE" SubSystem="2" TargetMachine="1"/> <Tool Name="VCMIDLTool" PreprocessorDefinitions="_DEBUG" MkTypLibCompatible="FALSE"/> <Tool Name="VCPostBuildEventTool"/> <Tool Name="VCPreBuildEventTool"/> <Tool Name="VCPreLinkEventTool"/> <Tool Name="VCResourceCompilerTool" PreprocessorDefinitions="_DEBUG" Culture="1033" AdditionalIncludeDirectories="$(IntDir)"/> <Tool Name="VCWebServiceProxyGeneratorTool"/> <Tool Name="VCWebDeploymentTool"/> </Configuration> <Configuration Name="Release|Win32" OutputDirectory="Release" IntermediateDirectory="Release" ConfigurationType="1" UseOfMFC="1" CharacterSet="2"> <Tool Name="VCCLCompilerTool" Optimization="2" InlineFunctionExpansion="1" OmitFramePointers="TRUE" PreprocessorDefinitions="WIN32;_WINDOWS;NDEBUG" StringPooling="TRUE" MinimalRebuild="FALSE" RuntimeLibrary="0" EnableFunctionLevelLinking="TRUE" TreatWChar_tAsBuiltInType="TRUE" UsePrecompiledHeader="3" WarningLevel="3" Detect64BitPortabilityProblems="TRUE" DebugInformationFormat="3"/> <Tool Name="VCCustomBuildTool"/> <Tool Name="VCLinkerTool" AdditionalDependencies="rpcrt4.lib" LinkIncremental="1" GenerateDebugInformation="TRUE" SubSystem="2" OptimizeReferences="2" EnableCOMDATFolding="2" TargetMachine="1"/> <Tool Name="VCMIDLTool" PreprocessorDefinitions="NDEBUG" MkTypLibCompatible="FALSE"/> <Tool Name="VCPostBuildEventTool"/> <Tool Name="VCPreBuildEventTool"/> <Tool Name="VCPreLinkEventTool"/> <Tool Name="VCResourceCompilerTool" PreprocessorDefinitions="NDEBUG" Culture="1033" AdditionalIncludeDirectories="$(IntDir)"/> <Tool Name="VCWebServiceProxyGeneratorTool"/> <Tool Name="VCWebDeploymentTool"/> </Configuration> </Configurations> <Files> <Filter Name="Source Files" Filter="cpp;c;cxx;def;odl;idl;hpj;bat;asm"> <File RelativePath="CCWizard.cpp"> </File> <File RelativePath="CCWizardDlg.cpp"> </File> <File RelativePath="stdafx.cpp"> <FileConfiguration Name="Debug|Win32"> <Tool Name="VCCLCompilerTool" UsePrecompiledHeader="1"/> </FileConfiguration> <FileConfiguration Name="Release|Win32"> <Tool Name="VCCLCompilerTool" UsePrecompiledHeader="1"/> </FileConfiguration> </File> </Filter> <Filter Name="Header Files" Filter="h;hpp;hxx;hm;inl;inc"> <File RelativePath="CCWizard.h"> </File> <File RelativePath="CCWizardDlg.h"> </File> <File RelativePath="Resource.h"> </File> <File RelativePath="stdafx.h"> </File> </Filter> <Filter Name="Resource Files" Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;jpg;jpeg;jpe;manifest"> <File RelativePath="res\CCWizard.ico"> </File> <File RelativePath="res\CCWizard.manifest"> </File> <File RelativePath="CCWizard.rc"> </File> <File RelativePath="res\CCWizard.rc2"> </File> </Filter> <File RelativePath="ReadMe.txt"> </File> </Files> <Globals> </Globals> </VisualStudioProject> --- NEW FILE: CCWizardDlg.cpp --- // CCWizardDlg.cpp : implementation file // #include "stdafx.h" #include "CCWizard.h" #include "CCWizardDlg.h" #ifdef _DEBUG #define new DEBUG_NEW #endif // CAboutDlg dialog used for App About class CAboutDlg : public CDialog { public: CAboutDlg(); // Dialog Data enum { IDD = IDD_ABOUTBOX }; protected: virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support // Implementation protected: DECLARE_MESSAGE_MAP() }; CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD) { } void CAboutDlg::DoDataExchange(CDataExchange* pDX) { CDialog::DoDataExchange(pDX); } BEGIN_MESSAGE_MAP(CAboutDlg, CDialog) END_MESSAGE_MAP() // CCCWizardDlg dialog CCCWizardDlg::CCCWizardDlg(CWnd* pParent /*=NULL*/) : CDialog(CCCWizardDlg::IDD, pParent) { m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME); } void CCCWizardDlg::DoDataExchange(CDataExchange* pDX) { CDialog::DoDataExchange(pDX); DDX_Control(pDX, IDC_OUTPUTPATH, m_eOutput); DDX_Control(pDX, IDC_LIBRARYNAME, m_eLibraryName); DDX_Control(pDX, IDC_CLASSNAME, m_eClassName); DDX_Control(pDX, IDC_STATUS, m_eStatus); } BEGIN_MESSAGE_MAP(CCCWizardDlg, CDialog) ON_WM_SYSCOMMAND() ON_WM_PAINT() ON_WM_QUERYDRAGICON() //}}AFX_MSG_MAP ON_BN_CLICKED(IDC_BROWSEPATH, OnBnClickedBrowsepath) ON_BN_CLICKED(IDC_CREATEFILES, OnBnClickedCreatefiles) END_MESSAGE_MAP() // CCCWizardDlg message handlers BOOL CCCWizardDlg::OnInitDialog() { CDialog::OnInitDialog(); // Add "About..." menu item to system menu. // IDM_ABOUTBOX must be in the system command range. ASSERT((IDM_ABOUTBOX & 0xFFF0) == IDM_ABOUTBOX); ASSERT(IDM_ABOUTBOX < 0xF000); CMenu* pSysMenu = GetSystemMenu(FALSE); if (pSysMenu != NULL) { CString strAboutMenu; strAboutMenu.LoadString(IDS_ABOUTBOX); if (!strAboutMenu.IsEmpty()) { pSysMenu->AppendMenu(MF_SEPARATOR); pSysMenu->AppendMenu(MF_STRING, IDM_ABOUTBOX, strAboutMenu); } } // Set the icon for this dialog. The framework does this automatically // when the application's main window is not a dialog SetIcon(m_hIcon, TRUE); // Set big icon SetIcon(m_hIcon, FALSE); // Set small icon CheckRadioButton(IDC_RADIO1, IDC_RADIO3, IDC_RADIO1); m_eLibraryName.SetWindowText(_T("CC_Custom")); m_eClassName.SetWindowText(_T("Commands")); return TRUE; } void CCCWizardDlg::OnSysCommand(UINT nID, LPARAM lParam) { if ((nID & 0xFFF0) == IDM_ABOUTBOX) { CAboutDlg dlgAbout; dlgAbout.DoModal(); } else { CDialog::OnSysCommand(nID, lParam); } } // If you add a minimize button to your dialog, you will need the code below // to draw the icon. For MFC applications using the document/view model, // this is automatically done for you by the framework. void CCCWizardDlg::OnPaint() { if (IsIconic()) { CPaintDC dc(this); // device context for painting SendMessage(WM_ICONERASEBKGND, reinterpret_cast<WPARAM>(dc.GetSafeHdc()), 0); // Center icon in client rectangle int cxIcon = GetSystemMetrics(SM_CXICON); int cyIcon = GetSystemMetrics(SM_CYICON); CRect rect; GetClientRect(&rect); int x = (rect.Width() - cxIcon + 1) / 2; int y = (rect.Height() - cyIcon + 1) / 2; // Draw the icon dc.DrawIcon(x, y, m_hIcon); } else { CDialog::OnPaint(); } } // The system calls this function to obtain the cursor to display while the user drags // the minimized window. HCURSOR CCCWizardDlg::OnQueryDragIcon() { return static_cast<HCURSOR>(m_hIcon); } void CCCWizardDlg::OnBnClickedBrowsepath() { CFileDialog dlg(TRUE, NULL, NULL, 0, NULL, NULL, 0); if ( dlg.DoModal() == IDOK ) { CString sFile = dlg.GetPathName(); sFile.SetAt(sFile.ReverseFind(_T('\\')), _T('\0')); m_eOutput.SetWindowText(sFile); } } void CCCWizardDlg::OnBnClickedCreatefiles() { m_eStatus.Clear(); m_eOutput.GetWindowText(m_sPath); m_eClassName.GetWindowText(m_sClass); m_eLibraryName.GetWindowText(m_sLibrary); // Which language is selected? int idLanguage = GetCheckedRadioButton(IDC_RADIO1, IDC_RADIO3); GenerateGUIDs(); int rc = 0; switch ( idLanguage ) { case IDC_RADIO1: rc = BuildFilesCPlusPlus(); break; case IDC_RADIO2: rc = BuildFilesCSharp(); break; case IDC_RADIO3: rc = BuildFilesVB(); break; default: break; } return; } void CCCWizardDlg::GenerateGUIDs() { CString sStatus, sLine; m_eStatus.GetWindowText(sStatus); sLine.Format(_T("Generating GUIDs%c%c"), 0x0d, 0x0a); sStatus.Append(sLine); m_sInterfaceGUID = MakeGUID(); sLine.Format(_T("Interface GUID = %s%c%c"), m_sInterfaceGUID, 0x0d, 0x0a); sStatus.Append(sLine); m_sTlbGUID = MakeGUID(); sLine.Format(_T("TypeLibrary GUID = %s%c%c"), m_sTlbGUID, 0x0d, 0x0a); sStatus.Append(sLine); m_sClassGUID = MakeGUID(); sLine.Format(_T("Class GUID = %s%c%c"), m_sClassGUID, 0x0d, 0x0a); sStatus.Append(sLine); m_eStatus.SetWindowText(sStatus); } CString CCCWizardDlg::MakeGUID() { GUID guid; CoCreateGuid(&guid); BYTE * b; UuidToString((UUID*)&guid, &b); CString s((LPTSTR)b); RpcStringFree(&b); return s; } int CCCWizardDlg::BuildFilesCPlusPlus() { return 0; } int CCCWizardDlg::BuildFilesCSharp() { return 0; } int CCCWizardDlg::BuildFilesVB() { return 0; } void CCCWizardDlg::BuildDllDataFiles() { CString sFile; CStdioFile f; CString status, sLine; m_eStatus.GetWindowText(status); // ********************** // dlldatax.c // ********************** sFile.Format(_T("%s\\dlldatax.c"), m_sPath); sLine.Format(_T("Creating file %s%c%c"), sFile, 0x0d, 0x0a); status.Append(sLine); m_eStatus.SetWindowText(status); if ( !f.Open(sFile, CFile::modeCreate | CFile::typeText | CFile::shareDenyWrite) ) { sLine.Format(_T("Error creating file %s%c%c"), sFile, 0x0d, 0x0a); status.Append(sLine); m_eStatus.SetWindowText(status); return; } FileWrite(f, _T("// wrapper for dlldata.c\n\n")); FileWrite(f, _T("#ifdef _MERGE_PROXYSTUB // merge proxy stub DLL\n\n")); FileWrite(f, _T("#define REGISTER_PROXY_DLL //DllRegisterServer, etc.\n\n")); FileWrite(f, _T("#define _WIN32_WINNT 0x0400 //for WinNT 4.0 or Win95 with DCOM\n")); FileWrite(f, _T("#define USE_STUBLESS_PROXY //defined only with MIDL switch /Oicf\n\n")); FileWrite(f, _T("#pragma comment(lib, \"rpcndr.lib\")\n")); FileWrite(f, _T("#pragma comment(lib, \"rpcns4.lib\")\n")); FileWrite(f, _T("#pragma comment(lib, \"rpcrt4.lib\")\n\n")); FileWrite(f, _T("#define ENTRY_PREFIX Prx\n\n")); FileWrite(f, _T("#include \"dlldata.c\"\n")); FileWrite(f, _T("#include \"ClientCommands_p.c\"\n\n")); FileWrite(f, _T("#endif //_MERGE_PROXYSTUB\n")); f.Close(); // ********************** // dlldatax.h // ********************** sFile.Format(_T("%s\\dlldatax.h"), m_sPath); sLine.Format(_T("Creating file %s%c%c"), sFile, 0x0d, 0x0a); status.Append(sLine); m_eStatus.SetWindowText(status); if ( !f.Open(sFile, CFile::modeCreate | CFile::typeText | CFile::shareDenyWrite) ) { sLine.Format(_T("Error creating file %s%c%c"), sFile, 0x0d, 0x0a); status.Append(sLine); m_eStatus.SetWindowText(status); return; } FileWrite(f, _T("#pragma once\n\n")); FileWrite(f, _T("#ifdef _MERGE_PROXYSTUB\n\n")); FileWrite(f, _T("extern \"C\" \n")); FileWrite(f, _T("{\n")); FileWrite(f, _T("BOOL WINAPI PrxDllMain(HINSTANCE hInstance, DWORD dwReason, \n")); FileWrite(f, _T("\tLPVOID lpReserved);\n")); FileWrite(f, _T("STDAPI PrxDllCanUnloadNow(void);\n")); FileWrite(f, _T("STDAPI PrxDllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID* ppv);\n")); FileWrite(f, _T("STDAPI PrxDllRegisterServer(void);\n")); FileWrite(f, _T("STDAPI PrxDllUnregisterServer(void);\n")); FileWrite(f, _T("}\n\n")); FileWrite(f, _T("#endif\n")); f.Close(); } void CCCWizardDlg::BuildClassFiles() { CString sFile; CStdioFile f; CString status, sLine; m_eStatus.GetWindowText(status); // ********************** // <class>.rgs // ********************** sFile.Format(_T("%s\\%s.rgs"), m_sPath, m_sClass); sLine.Format(_T("Creating file %s%c%c"), sFile, 0x0d, 0x0a); status.Append(sLine); m_eStatus.SetWindowText(status); if ( !f.Open(sFile, CFile::modeCreate | CFile::typeText | CFile::shareDenyWrite) ) { sLine.Format(_T("Error creating file %s%c%c"), sFile, 0x0d, 0x0a); status.Append(sLine); m_eStatus.SetWindowText(status); return; } FileWrite(f, _T("HKCR")); FileWrite(f, _T("{")); FileWrite(f, _T("\t%s.%s.1 = s '%s Class'"), m_sLibrary, m_sClass, m_sClass); FileWrite(f, _T("\t{")); FileWrite(f, _T("\t\tCLSID = s '{%s}'"), m_sClassGUID); FileWrite(f, _T("\t}")); FileWrite(f, _T("\t%s.%s = s '%s Class'"), m_sLibrary, m_sClass, m_sClass); FileWrite(f, _T("\t{")); FileWrite(f, _T("\t\tCLSID = s '{%s}'"), m_sClassGUID); FileWrite(f, _T("\t\tCurVer = s '%s.%s.1'"), m_sLibrary, m_sClass); FileWrite(f, _T("\t}")); FileWrite(f, _T("\tNoRemove CLSID")); FileWrite(f, _T("\t{")); FileWrite(f, _T("\t\tForceRemove {%s} = s '%s Class'"), m_sClassGUID, m_sClass); FileWrite(f, _T("\t\t{")); FileWrite(f, _T("\t\t\tProgID = s '%s.%s.1'"), m_sLibrary, m_sClass); FileWrite(f, _T("\t\t\tVersionIndependentProgID = s '%s.%s'"), m_sLibrary, m_sClass); FileWrite(f, _T("\t\t\tForceRemove 'Programmable'")); FileWrite(f, _T("\t\t\tInprocServer32 = s '%MODULE%'")); FileWrite(f, _T("\t\t\t{")); FileWrite(f, _T("\t\t\t\tval ThreadingModel = s 'Apartment'")); FileWrite(f, _T("\t\t\t}")); FileWrite(f, _T("\t\t\tval AppID = s '%APPID%'")); FileWrite(f, _T("\t\t\t'TypeLib' = s '{%s}'"), m_sTlbGUID); FileWrite(f, _T("\t\t}")); FileWrite(f, _T("\t}")); FileWrite(f, _T("}")); f.Close(); // ********************** // <class>.h // ********************** sFile.Format(_T("%s\\%s.h"), m_sPath, m_sClass); sLine.Format(_T("Creating file %s%c%c"), sFile, 0x0d, 0x0a); status.Append(sLine); m_eStatus.SetWindowText(status); if ( !f.Open(sFile, CFile::modeCreate | CFile::typeText | CFile::shareDenyWrite) ) { sLine.Format(_T("Error creating file %s%c%c"), sFile, 0x0d, 0x0a); status.Append(sLine); m_eStatus.SetWindowText(status); return; } FileWrite(f, _T("// SphereClientCommands.h : Declaration of the CSphereClientCommands\n")); FileWrite(f, _T("\n")); FileWrite(f, _T("#pragma once\n")); FileWrite(f, _T("#include \"resource.h\" // main symbols\n")); FileWrite(f, _T("\n")); FileWrite(f, _T("#include \"%s.h\"\n"), m_sLibrary); FileWrite(f, _T("\n")); FileWrite(f, _T("\n")); FileWrite(f, _T("// C%s\n"), m_sClass); FileWrite(f, _T("\n")); FileWrite(f, _T("class ATL_NO_VTABLE C%s : \n"), m_sClass); FileWrite(f, _T("\tpublic CComObjectRootEx<CComSingleThreadModel>,\n")); FileWrite(f, _T("\tpublic CComCoClass<C%s, &CLSID_%s>,\n"), m_sClass, m_sClass); FileWrite(f, _T("\tpublic ISupportErrorInfo,\n")); FileWrite(f, _T("\tpublic IDispatchImpl<IClientCommands, &IID_I%s, &LIBID_%s, /*wMajor =*/ 1, /*wMinor =*/ 0>\n"), m_sLibrary, m_sLibrary); FileWrite(f, _T("{\n")); FileWrite(f, _T("public:\n")); FileWrite(f, _T("\tC%s()\n"), m_sClass); FileWrite(f, _T("\t{\n")); FileWrite(f, _T("\t}\n")); FileWrite(f, _T("\n")); FileWrite(f, _T("DECLARE_REGISTRY_RESOURCEID(IDR_%s)\n"), m_sClass); FileWrite(f, _T("\n")); FileWrite(f, _T("\n")); FileWrite(f, _T("BEGIN_COM_MAP(C%s)\n"), m_sClass); FileWrite(f, _T("\tCOM_INTERFACE_ENTRY(IClientCommands)\n")); FileWrite(f, _T("\tCOM_INTERFACE_ENTRY(IDispatch)\n")); FileWrite(f, _T("\tCOM_INTERFACE_ENTRY(ISupportErrorInfo)\n")); FileWrite(f, _T("END_COM_MAP()\n")); FileWrite(f, _T("\n")); FileWrite(f, _T("// ISupportsErrorInfo\n")); FileWrite(f, _T("\tSTDMETHOD(InterfaceSupportsErrorInfo)(REFIID riid);\n")); FileWrite(f, _T("\n")); FileWrite(f, _T("\tDECLARE_PROTECT_FINAL_CONSTRUCT()\n")); FileWrite(f, _T("\n")); FileWrite(f, _T("\tHRESULT FinalConstruct()\n")); FileWrite(f, _T("\t{\n")); FileWrite(f, _T("\t\treturn S_OK;\n")); FileWrite(f, _T("\t}\n")); FileWrite(f, _T("\n")); FileWrite(f, _T("\tvoid FinalRelease() \n")); FileWrite(f, _T("\t{\n")); FileWrite(f, _T("\t}\n")); FileWrite(f, _T("\n")); FileWrite(f, _T("public:\n")); FileWrite(f, _T("\n")); FileWrite(f, _T("\tSTDMETHOD(Set)(ULONG field, BSTR arg, VARIANT_BOOL target);\n")); FileWrite(f, _T("\tSTDMETHOD(SendCommand)(ULONG cmd, BSTR arg1, BSTR arg2, VARIANT_BOOL target);\n")); FileWrite(f, _T("\tSTDMETHOD(Toggle)(ULONG flag, VARIANT_BOOL target);\n")); FileWrite(f, _T("\tSTDMETHOD(SetSpawnInfo)(BSTR id, ULONG type, ULONG amount, ULONG timelo, ULONG timehi, ULONG distance, ULONG rate);\n")); FileWrite(f, _T("\tSTDMETHOD(InvokeSettingEditor)(void);\n")); FileWrite(f, _T("\tSTDMETHOD(GetServerCommandCount)(ULONG* count);\n")); FileWrite(f, _T("\tSTDMETHOD(GetServerCommandDescription)(ULONG index, BSTR* description);\n")); FileWrite(f, _T("\tSTDMETHOD(InvokeServerCommand)(ULONG index, BSTR arg);\n")); FileWrite(f, _T("};\n")); FileWrite(f, _T("\n")); FileWrite(f, _T("OBJECT_ENTRY_AUTO(__uuidof(%s), C%s)\n"), m_sClass, m_sClass); f.Close(); // ********************** // <class>.cpp // ********************** sFile.Format(_T("%s\\%s.h"), m_sPath, m_sClass); sLine.Format(_T("Creating file %s%c%c"), sFile, 0x0d, 0x0a); status.Append(sLine); m_eStatus.SetWindowText(status); if ( !f.Open(sFile, CFile::modeCreate | CFile::typeText | CFile::shareDenyWrite) ) { sLine.Format(_T("Error creating file %s%c%c"), sFile, 0x0d, 0x0a); status.Append(sLine); m_eStatus.SetWindowText(status); return; } FileWrite(f, _T("// %s.cpp : Implementation of C%s"), m_sClass, m_sClass); FileWrite(f, _T("")); FileWrite(f, _T("#include \"stdafx.h\"")); FileWrite(f, _T("#include \"%s.h\""), m_sClass); FileWrite(f, _T("")); FileWrite(f, _T("")); FileWrite(f, _T("// C%s"), m_sClass); FileWrite(f, _T("")); FileWrite(f, _T("STDMETHODIMP C%s::InterfaceSupportsErrorInfo(REFIID riid)"), m_sClass); FileWrite(f, _T("{")); FileWrite(f, _T("\tstatic const IID* arr[] = ")); FileWrite(f, _T("\t{")); FileWrite(f, _T("\t\t&IID_IClientCommands,")); FileWrite(f, _T("\t};")); FileWrite(f, _T("")); FileWrite(f, _T("\tfor (int i=0; i < sizeof(arr) / sizeof(arr[0]); i++)")); FileWrite(f, _T("\t{")); FileWrite(f, _T("\t\tif (InlineIsEqualGUID(*arr[i],riid))")); FileWrite(f, _T("\t\t\treturn S_OK;")); FileWrite(f, _T("\t}")); FileWrite(f, _T("\treturn S_FALSE;")); FileWrite(f, _T("}")); FileWrite(f, _T("")); FileWrite(f, _T("STDMETHODIMP C%s::Set(ULONG field, BSTR arg, VARIANT_BOOL target)"), m_sClass); FileWrite(f, _T("{")); FileWrite(f, _T("\tAFX_MANAGE_STATE(AfxGetStaticModuleState());")); FileWrite(f, _T("")); FileWrite(f, _T("\t// TODO: Add your implementation code here")); FileWrite(f, _T("")); FileWrite(f, _T("\treturn S_OK;")); FileWrite(f, _T("}")); FileWrite(f, _T("")); FileWrite(f, _T("STDMETHODIMP C%s::SendCommand(ULONG cmd, BSTR arg1, BSTR arg2, VARIANT_BOOL target)"), m_sClass); FileWrite(f, _T("{")); FileWrite(f, _T("\tAFX_MANAGE_STATE(AfxGetStaticModuleState());")); FileWrite(f, _T("")); FileWrite(f, _T("\t// TODO: Add your implementation code here")); FileWrite(f, _T("")); FileWrite(f, _T("\treturn S_OK;")); FileWrite(f, _T("}")); FileWrite(f, _T("")); FileWrite(f, _T("STDMETHODIMP C%s::Toggle(ULONG flag, VARIANT_BOOL target)"), m_sClass); FileWrite(f, _T("{")); FileWrite(f, _T("\tAFX_MANAGE_STATE(AfxGetStaticModuleState());")); FileWrite(f, _T("")); FileWrite(f, _T("\t// TODO: Add your implementation code here")); FileWrite(f, _T("")); FileWrite(f, _T("\treturn S_OK;")); FileWrite(f, _T("}")); FileWrite(f, _T("")); FileWrite(f, _T("STDMETHODIMP C%s::SetSpawnInfo(BSTR id, ULONG type, ULONG amount, ULONG timelo, ULONG timehi, ULONG distance, ULONG rate)"), m_sClass); FileWrite(f, _T("{")); FileWrite(f, _T("\tAFX_MANAGE_STATE(AfxGetStaticModuleState());")); FileWrite(f, _T("")); FileWrite(f, _T("\t// TODO: Add your implementation code here")); FileWrite(f, _T("")); FileWrite(f, _T("\treturn S_OK;")); FileWrite(f, _T("}")); FileWrite(f, _T("")); FileWrite(f, _T("STDMETHODIMP C%s::GetServerCommandCount(ULONG* count)"), m_sClass); FileWrite(f, _T("{")); FileWrite(f, _T("\tAFX_MANAGE_STATE(AfxGetStaticModuleState());")); FileWrite(f, _T("")); FileWrite(f, _T("\t// TODO: Add your implementation code here")); FileWrite(f, _T("")); FileWrite(f, _T("\treturn S_OK;")); FileWrite(f, _T("}")); FileWrite(f, _T("")); FileWrite(f, _T("STDMETHODIMP C%s::GetServerCommandDescription(ULONG index, BSTR* description)"), m_sClass); FileWrite(f, _T("{")); FileWrite(f, _T("\tAFX_MANAGE_STATE(AfxGetStaticModuleState());")); FileWrite(f, _T("")); FileWrite(f, _T("\t// TODO: Add your implementation code here")); FileWrite(f, _T("")); FileWrite(f, _T(" return S_OK;")); FileWrite(f, _T("}")); FileWrite(f, _T("")); FileWrite(f, _T("STDMETHODIMP C%s::InvokeServerCommand(ULONG index, BSTR arg)"), m_sClass); FileWrite(f, _T("{")); FileWrite(f, _T("\tAFX_MANAGE_STATE(AfxGetStaticModuleState());")); FileWrite(f, _T("")); FileWrite(f, _T("\t// TODO: Add your implementation code here")); FileWrite(f, _T("")); FileWrite(f, _T("\treturn S_OK;")); FileWrite(f, _T("}")); FileWrite(f, _T("")); FileWrite(f, _T("STDMETHODIMP C%s::InvokeSettingEditor(void)"), m_sClass); FileWrite(f, _T("{")); FileWrite(f, _T("\tAFX_MANAGE_STATE(AfxGetStaticModuleState());")); FileWrite(f, _T("")); FileWrite(f, _T("\t// TODO: Add your implementation code here")); FileWrite(f, _T("")); FileWrite(f, _T("\treturn S_OK;")); FileWrite(f, _T("}")); f.Close(); } void CCCWizardDlg::BuildTlbFiles() { } void CCCWizardDlg::BuildProjectFiles() { } void CCCWizardDlg::BuildExtraFiles() { } void CCCWizardDlg::FileWrite(CStdioFile &f, const char *format, ...) { CString s; va_list vargs; va_start(vargs, format); s.FormatV(format, vargs); va_end(vargs); f.WriteString(s); } --- NEW FILE: CCWizardDlg.h --- // CCWizardDlg.h : header file // #pragma once #include "afxwin.h" // CCCWizardDlg dialog class CCCWizardDlg : public CDialog { // Construction public: CCCWizardDlg(CWnd* pParent = NULL); // standard constructor // Dialog Data enum { IDD = IDD_CCWIZARD_DIALOG }; protected: virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support // Implementation protected: HICON m_hIcon; // Generated message map functions virtual BOOL OnInitDialog(); afx_msg void OnSysCommand(UINT nID, LPARAM lParam); afx_msg void OnPaint(); afx_msg HCURSOR OnQueryDragIcon(); DECLARE_MESSAGE_MAP() int BuildFilesCPlusPlus(); int BuildFilesCSharp(); int BuildFilesVB(); void GenerateGUIDs(); CString MakeGUID(); CString m_sInterfaceGUID; CString m_sTlbGUID; CString m_sClassGUID; CString m_sPath; CString m_sClass; CString m_sLibrary; // Functions to build C++ files void BuildDllDataFiles(); void BuildClassFiles(); void BuildTlbFiles(); void BuildProjectFiles(); void BuildExtraFiles(); // Functions to build C# files // Functions to build VB files // Other functions void FileWrite(CStdioFile &f, const char * format, ...); public: afx_msg void OnBnClickedBrowsepath(); afx_msg void OnBnClickedCreatefiles(); CEdit m_eOutput; CEdit m_eLibraryName; CEdit m_eClassName; CEdit m_eStatus; }; --- NEW FILE: resource.h --- //{{NO_DEPENDENCIES}} // Microsoft Visual C++ generated include file. // Used by CCWizard.rc // #define IDR_MANIFEST 1 #define IDM_ABOUTBOX 0x0010 #define IDD_ABOUTBOX 100 #define IDS_ABOUTBOX 101 #define IDD_CCWIZARD_DIALOG 102 #define IDR_MAINFRAME 128 #define IDC_LIBRARYNAME 1000 #define IDC_CLASSNAME 1001 #define IDC_RADIO1 1002 #define IDC_RADIO2 1003 #define IDC_RADIO3 1004 #define IDC_EDIT3 1005 #define IDC_STATUS 1005 #define IDC_CREATEFILES 1006 #define IDC_OUTPUTPATH 1007 #define IDC_BROWSEPATH 1008 // Next default values for new objects // #ifdef APSTUDIO_INVOKED #ifndef APSTUDIO_READONLY_SYMBOLS #define _APS_NEXT_RESOURCE_VALUE 129 #define _APS_NEXT_COMMAND_VALUE 32771 #define _APS_NEXT_CONTROL_VALUE 1009 #define _APS_NEXT_SYMED_VALUE 101 #endif #endif --- NEW FILE: stdafx.cpp --- // stdafx.cpp : source file that includes just the standard includes // CCWizard.pch will be the pre-compiled header // stdafx.obj will contain the pre-compiled type information #include "stdafx.h" --- NEW FILE: stdafx.h --- // stdafx.h : include file for standard system include files, // or project specific include files that are used frequently, // but are changed infrequently #pragma once #ifndef VC_EXTRALEAN #define VC_EXTRALEAN // Exclude rarely-used stuff from Windows headers #endif // Modify the following defines if you have to target a platform prior to the ones specified below. // Refer to MSDN for the latest info on corresponding values for different platforms. #ifndef WINVER // Allow use of features specific to Windows 95 and Windows NT 4 or later. #define WINVER 0x0400 // Change this to the appropriate value to target Windows 98 and Windows 2000 or later. #endif #ifndef _WIN32_WINNT // Allow use of features specific to Windows NT 4 or later. #define _WIN32_WINNT 0x0400 // Change this to the appropriate value to target Windows 98 and Windows 2000 or later. #endif #ifndef _WIN32_WINDOWS // Allow use of features specific to Windows 98 or later. #define _WIN32_WINDOWS 0x0410 // Change this to the appropriate value to target Windows Me or later. #endif #ifndef _WIN32_IE // Allow use of features specific to IE 4.0 or later. #define _WIN32_IE 0x0400 // Change this to the appropriate value to target IE 5.0 or later. #endif #define _ATL_CSTRING_EXPLICIT_CONSTRUCTORS // some CString constructors will be explicit // turns off MFC's hiding of some common and often safely ignored warning messages #define _AFX_ALL_WARNINGS #include <afxwin.h> // MFC core and standard components #include <afxext.h> // MFC extensions #include <afxdisp.h> // MFC Automation classes #include <afxdtctl.h> // MFC support for Internet Explorer 4 Common Controls #ifndef _AFX_NO_AFXCMN_SUPPORT #include <afxcmn.h> // MFC support for Windows Common Controls #endif // _AFX_NO_AFXCMN_SUPPORT |