📄 default.js
字号:
// Windows Template Library - WTL version 8.0
// Copyright (C) Microsoft Corporation. All rights reserved.
//
// This file is a part of the Windows Template Library.
// The use and distribution terms for this software are covered by the
// Microsoft Permissive License (Ms-PL) which can be found in the file
// Ms-PL.txt at the root of this distribution.
var ProjWiz;
ProjWiz = new ActiveXObject("ProjWiz.SDProjWiz2.2");
function OnFinish(selProj, selObj)
{
try
{
var strProjectPath = wizard.FindSymbol('PROJECT_PATH');
var strProjectName = wizard.FindSymbol('PROJECT_NAME');
// Create symbols based on the project name
var strSafeProjectName = CreateSafeName(strProjectName);
var strProjectRoot = strSafeProjectName.substr(0, 1).toUpperCase() + strSafeProjectName.substr(1);
wizard.AddSymbol("SAFE_PROJECT_NAME", strSafeProjectName);
wizard.AddSymbol("NICE_SAFE_PROJECT_NAME", strProjectRoot);
wizard.AddSymbol("UPPERCASE_SAFE_PROJECT_NAME", strSafeProjectName.toUpperCase());
// Set current year symbol
var d = new Date();
var nYear = d.getFullYear();
if(nYear >= 2006)
wizard.AddSymbol("WTL_CURRENT_YEAR", nYear);
var strBaseName = wizard.FindSymbol("NICE_SAFE_PROJECT_NAME");
// Set app type symbols
if(wizard.FindSymbol("WTL_APPTYPE_SDI"))
{
var strFrameFile = strBaseName + "Frame";
var strFrameClass = "C" + strFrameFile;
wizard.AddSymbol("WTL_APPWND_FILE", strFrameFile);
wizard.AddSymbol("WTL_APPWND_CLASS", strFrameClass);
wizard.AddSymbol("WTL_FRAME_CLASS",strFrameClass);
// Set view symbols
if(wizard.FindSymbol("WTL_USE_VIEW"))
SetViewSymbols(strBaseName);
}
else if(wizard.FindSymbol("WTL_APPTYPE_DLG"))
{
var strDlgFile = strBaseName + "Dialog";
wizard.AddSymbol("WTL_APPWND_FILE", strDlgFile);
wizard.AddSymbol("WTL_MAINDLG_CLASS", "C" + strDlgFile);
wizard.AddSymbol("WTL_APPWND_CLASS", "C" + strDlgFile);
var BaseClassName = "CAppStdDialogImpl";
if(wizard.FindSymbol("WTL_APP_DLG_ORIENT_AWARE"))
if(wizard.FindSymbol("WTL_APP_DLG_RESIZE"))
BaseClassName = "CAppStdDialogResizeImpl";
else if(wizard.FindSymbol("WTL_APP_DLG_ORIENT"))
BaseClassName = "CAppStdOrientedDialogImpl";
if(wizard.FindSymbol("WTL_ENABLE_AX"))
BaseClassName = BaseClassName.replace("Std", "StdAx");
wizard.AddSymbol("WTL_MAINDLG_BASE_CLASS", BaseClassName);
wizard.AddSymbol("WTL_USE_STATUSBAR", false);
wizard.AddSymbol("WTL_USE_VIEW", false);
}
EnsureDevicePlatforms();
// this call must occur before we create the project, because otherwise the templates are already generated.
SetDeviceSymbolsForPlatforms();
if(wizard.FindSymbol("POCKETPC2003_UI_MODEL") && wizard.FindSymbol("SMARTPHONE2003_UI_MODEL"))
wizard.AddSymbol("DUAL_UI_MODEL", true);
// Create project and configurations
selProj = CreateDeviceProject(strProjectName, strProjectPath);
AddConfigurations(selProj, strProjectName);
AddFilters(selProj);
// Create the project's Templates.inf file
var InfFile = CreateInfFile(); // common.js
// Add the files in Templates.inf to the project.
AddFilesToCustomProj(selProj, strProjectName, strProjectPath, InfFile);
SetCommonPchSettings(selProj);
SetWtlDeviceResourceConfigurations(selProj.Object);
selProj.Object.Save();
InfFile.Delete();
if(wizard.FindSymbol("WTL_APPTYPE_DLG"))
{
var ResHelper = wizard.ResourceHelper;
ResHelper.OpenResourceFile(strProjectPath + "\\" + strProjectName + ".rc");
ResHelper.OpenResourceInEditor("DIALOG", "IDD_MAINDLG");
}
else if(wizard.FindSymbol("WTL_USE_VIEW") && wizard.FindSymbol("WTL_VIEWTYPE_FORM"))
{
var strDialogID = "IDD_" + wizard.FindSymbol("UPPERCASE_SAFE_PROJECT_NAME") + "_FORM";
var ResHelper = wizard.ResourceHelper;
ResHelper.OpenResourceFile(strProjectPath + "\\" + strProjectName + ".rc");
ResHelper.OpenResourceInEditor("DIALOG", strDialogID);
}
}
catch(e)
{
if(e.description.length != 0)
SetErrorInfo(e);
return e.number
}
}
function CreateCustomProject(strProjectName, strProjectPath)
{
try
{
var strProjTemplatePath = wizard.FindSymbol('PROJECT_TEMPLATE_PATH');
var strProjTemplate = '';
strProjTemplate = strProjTemplatePath + '\\default.vcproj';
var Solution = dte.Solution;
var strSolutionName = "";
if (wizard.FindSymbol("CLOSE_SOLUTION"))
{
Solution.Close();
strSolutionName = wizard.FindSymbol("VS_SOLUTION_NAME");
if (strSolutionName.length)
{
var strSolutionPath = strProjectPath.substr(0, strProjectPath.length - strProjectName.length);
Solution.Create(strSolutionPath, strSolutionName);
}
}
var strProjectNameWithExt = '';
strProjectNameWithExt = strProjectName + '.vcproj';
var oTarget = wizard.FindSymbol("TARGET");
var prj;
if (wizard.FindSymbol("WIZARD_TYPE") == vsWizardAddSubProject) // vsWizardAddSubProject
{
var prjItem = oTarget.AddFromTemplate(strProjTemplate, strProjectNameWithExt);
prj = prjItem.SubProject;
}
else
{
prj = oTarget.AddFromTemplate(strProjTemplate, strProjectPath, strProjectNameWithExt);
}
return prj;
}
catch(e)
{
throw e;
}
}
function AddFilters(proj)
{
try
{
// Add the folders to your project
var strSrcFilter = wizard.FindSymbol('SOURCE_FILTER');
var group = proj.Object.AddFilter('Source Files');
group.Filter = strSrcFilter;
strSrcFilter = wizard.FindSymbol('INCLUDE_FILTER');
group = proj.Object.AddFilter('Header Files');
group.Filter = strSrcFilter;
strSrcFilter = wizard.FindSymbol('RESOURCE_FILTER');
group = proj.Object.AddFilter('Resource Files');
group.Filter = strSrcFilter;
}
catch(e)
{
throw e;
}
}
function AddConfigurations(proj, strProjectName)
{
try
{
var oConfigs = proj.Object.Configurations;
for(var nCntr = 1; nCntr <= oConfigs.Count; nCntr++)
{
var config = oConfigs(nCntr);
// Check if it's Debug configuration
var bDebug = false;
if(config.Name.indexOf("Debug") != -1)
bDebug = true;
// General settings
config.CharacterSet = charSetUnicode;
config.ATLMinimizesCRunTimeLibraryUsage = false;
if(bDebug)
{
config.IntermediateDirectory = "$(PlatformName)\\Debug";
config.OutputDirectory = "$(PlatformName)\\Debug";
}
else
{
config.IntermediateDirectory = "$(PlatformName)\\Release";
config.OutputDirectory = "$(PlatformName)\\Release";
}
// Instruction set
var instructionSet = "";
var sIndex = config.Name.indexOf("(");
var eIndex = config.Name.indexOf(")");
if((sIndex != -1) && (eIndex != -1))
{
instructionSet = config.Name.substr(sIndex + 1, eIndex - sIndex - 1);
}
// Compiler settings
var CLTool = config.Tools('VCCLCompilerTool');
CLTool.UsePrecompiledHeader = pchUseUsingSpecific;
CLTool.WarningLevel = warningLevel_3;
if(bDebug)
{
CLTool.RuntimeLibrary = rtMultiThreadedDebug;
CLTool.MinimalRebuild = true;
CLTool.DebugInformationFormat = debugEnabled;
CLTool.Optimization = optimizeDisabled;
}
else
{
CLTool.RuntimeLibrary = rtMultiThreaded;
CLTool.ExceptionHandling = false;
CLTool.DebugInformationFormat = debugDisabled;
}
var strDefines = GetPlatformDefine(config);
strDefines += "_WIN32_WCE=$(CEVER);UNDER_CE=$(CEVER);WINCE;";
if(bDebug)
strDefines += "_DEBUG";
else
strDefines += "NDEBUG";
// PLATFORMDEFINES isn't defined for all platforms
var PlatformDefines = config.Platform.GetMacroValue("PLATFORMDEFINES");
if(PlatformDefines != "")
strDefines += ";$(PLATFORMDEFINES)";
strDefines += ";$(ARCHFAM);$(_ARCHFAM_);_UNICODE"
CLTool.PreprocessorDefinitions = strDefines;
// Linker settings
var LinkTool = config.Tools('VCLinkerTool');
if(bDebug)
{
LinkTool.LinkIncremental = linkIncrementalYes;
LinkTool.GenerateDebugInformation = true;
}
else
{
LinkTool.LinkIncremental = linkIncrementalNo;
}
LinkTool.SubSystem = subSystemNotSet;
LinkTool.IgnoreImportLibrary = true;
if(bDebug)
LinkTool.AdditionalDependencies = "atlsd.lib libcmtd.lib"
else
LinkTool.AdditionalDependencies = "atls.lib libcmt.lib"
LinkTool.AdditionalDependencies += " corelibc.lib coredll.lib commctrl.lib ole32.lib oleaut32.lib uuid.lib atl.lib atlosapis.lib $(NOINHERIT)"
if(config.Platform.Name != "Win32")
{
LinkTool.AdditionalOptions = " /subsystem:windowsce," + ProjWiz.GetNativePlatformMajorVersion(config.Platform.Name) + "." + ProjWiz.GetNativePlatformMinorVersion(config.Platform.Name);
LinkTool.AdditionalOptions = LinkTool.AdditionalOptions + " " + ProjWiz.GetLinkerMachineType(instructionSet);
}
if(config.Platform.Name == "Pocket PC 2003 (ARMV4)" ||
config.Platform.Name == "SmartPhone 2003 (ARMV4)" ||
config.Platform.Name == "Smartphone 2003 (ARMV4)" )
{
LinkTool.AdditionalOptions = LinkTool.AdditionalOptions + " /ARMPADCODE";
}
if(config.Platform.Name == "Pocket PC 2003 (Emulator)" ||
config.Platform.Name == "SmartPhone 2003 (Emulator)" ||
config.Platform.Name == "Smartphone 2003 (Emulator)" )
{
if(bDebug)
{
LinkTool.AdditionalDependencies += " libcmtx86d.lib";
}
else
{
LinkTool.AdditionalDependencies += " libcmtx86.lib";
}
}
if(config.Platform.Name.indexOf("Pocket PC 2003") != -1)
{
LinkTool.AdditionalDependencies += " ccrtrtti.lib";
}
if(config.Platform.Name.indexOf("SmartPhone 2003") != -1 ||
config.Platform.Name.indexOf("Smartphone 2003") != -1 )
{
LinkTool.AdditionalDependencies += " ccrtrtti.lib";
}
LinkTool.AdditionalDependencies += " $(NOINHERIT)";
LinkTool.DelayLoadDLLs = "$(NOINHERIT)";
// var DeployTool = config.DeploymentTool;
// if(DeployTool)
// {
// DeployTool.AdditionalFiles += "atl80.dll|$(VCInstallDir)ce\\dll\\$(INSTRUCTIONSET)\\|%CSIDL_WINDOWS%|0;";
// }
// Resource settings
var RCTool = config.Tools("VCResourceCompilerTool");
RCTool.Culture = rcEnglishUS;
RCTool.AdditionalIncludeDirectories = "$(IntDir)";
if(bDebug)
strDefines = "_DEBUG";
else
strDefines = "NDEBUG";
strDefines += ";_UNICODE;UNICODE;_WIN32_WCE=$(CEVER);SHELLSDK_MODULES_AYGSHELL"
RCTool.PreprocessorDefinitions = strDefines;
RCTool.AdditionalOptions = "-n"; // null-terminated string resources
// MIDL settings
var MidlTool = config.Tools("VCMidlTool");
MidlTool.MkTypLibCompatible = false;
if(IsPlatformWin32(config))
MidlTool.TargetEnvironment = midlTargetWin32;
if(bDebug)
MidlTool.PreprocessorDefinitions = "_DEBUG";
else
MidlTool.PreprocessorDefinitions = "NDEBUG";
MidlTool.HeaderFileName = strProjectName + ".h";
MidlTool.InterfaceIdentifierFileName = strProjectName + "_i.c";
MidlTool.ProxyFileName = strProjectName + "_p.c";
MidlTool.GenerateStublessProxies = true;
MidlTool.TypeLibraryName = "$(IntDir)/" + strProjectName + ".tlb";
MidlTool.DLLDataFileName = "";
// Post-build settings
if(wizard.FindSymbol('WTL_COM_SERVER'))
{
var PostBuildTool = config.Tools("VCPostBuildEventTool");
PostBuildTool.Description = "Performing registration...";
PostBuildTool.CommandLine = "\"$(TargetPath)\" /RegServer";
}
}
}
catch(e)
{
throw e;
}
}
function DelFile(fso, strWizTempFile)
{
try
{
if (fso.FileExists(strWizTempFile))
{
var tmpFile = fso.GetFile(strWizTempFile);
tmpFile.Delete();
}
}
catch(e)
{
throw e;
}
}
function CreateCustomInfFile()
{
try
{
var fso, TemplatesFolder, TemplateFiles, strTemplate;
fso = new ActiveXObject('Scripting.FileSystemObject');
var TemporaryFolder = 2;
var tfolder = fso.GetSpecialFolder(TemporaryFolder);
var strTempFolder = tfolder.Drive + '\\' + tfolder.Name;
var strWizTempFile = strTempFolder + "\\" + fso.GetTempName();
var strTemplatePath = wizard.FindSymbol('TEMPLATES_PATH');
var strInfFile = strTemplatePath + '\\Templates.inf';
wizard.RenderTemplate(strInfFile, strWizTempFile);
var WizTempFile = fso.GetFile(strWizTempFile);
return WizTempFile;
}
catch(e)
{
throw e;
}
}
function GetTargetName(strName, strProjectName)
{
try
{
var strTarget = strName;
var strResPath = "res\\";
if(strName.substr(0, 4) == "root")
{
var nNameLen = strName.length;
if(strName == "root.ico")
{
strTarget = strResPath + strProjectName + strName.substr(4, nNameLen - 4);
}
else
{
strTarget = strProjectName + strName.substr(4, nNameLen - 4);
}
}
else if(strName == 'frame.h' || strName == 'MainDlg.h')
{
strTarget = wizard.FindSymbol("WTL_APPWND_FILE") +'.h';
}
else if(strName == 'frame.cpp' || strName == 'MainDlg.cpp')
{
strTarget = wizard.FindSymbol("WTL_APPWND_FILE") +'.cpp';
}
else if(strName == 'view.h')
{
strTarget = wizard.FindSymbol("WTL_VIEW_FILE") + '.h';
}
else if(strName == 'view.cpp')
{
strTarget = wizard.FindSymbol("WTL_VIEW_FILE") + '.cpp';
}
else if(strName == 'toolbar.bmp')
{
strTarget = strResPath + strName;
}
else
{
strTarget = strName;
}
return strTarget;
}
catch(e)
{
throw e;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -