ok!我贴!// DrawView.cpp : CDrawView 类的实现
//
#include "stdafx.h"
#include "Draw.h"
#include "DrawDoc.h"
#include "DrawView.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#endif
// CDrawView
IMPLEMENT_DYNCREATE(CDrawView, CView)
BEGIN_MESSAGE_MAP(CDrawView, CView)
// 标准打印命令
ON_COMMAND(ID_FILE_PRINT, &CView::OnFilePrint)
ON_COMMAND(ID_FILE_PRINT_DIRECT, &CView::OnFilePrint)
ON_COMMAND(ID_FILE_PRINT_PREVIEW, &CView::OnFilePrintPreview)
END_MESSAGE_MAP()
// CDrawView 构造/析构
CDrawView::CDrawView()
{
// TODO: 在此处添加构造代码
m_bDragging=false;//初始化拖曳标记
m_hCross=AfxGetApp()->LoadStandardCursor(IDC_CROSS);//获得十字光标
}
CDrawView::~CDrawView()
{
}
BOOL CDrawView::PreCreateWindow(CREATESTRUCT& cs)
{
// TODO: 在此处通过修改
//
CREATESTRUCT cs 来修改窗口类或样式
return CView::PreCreateWindow(cs);
}
// CDrawView 绘制
void CDrawView::OnDraw(CDC* /*pDC*/)
{
CDrawDoc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
if (!pDoc)
return;
// TODO: 在此处为本机数据添加绘制代码
}
// CDrawView 打印
BOOL CDrawView::OnPreparePrinting(CPrintInfo* pInfo)
{
// 默认准备
return DoPreparePrinting(pInfo);
}
void CDrawView::OnBeginPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
// TODO: 添加额外的打印前进行的初始化过程
}
void CDrawView::OnEndPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
// TODO: 添加打印后进行的清除过程
}
// CDrawView 诊断
#ifdef _DEBUG
void CDrawView::AssertValid() const
{
CView::AssertValid();
}
void CDrawView::Dump(CDumpContext& dc) const
{
CView::Dump(dc);
}
CDrawDoc* CDrawView::GetDocument() const // 非调试版本是内联的
{
ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CDrawDoc)));
return (CDrawDoc*)m_pDocument;
}
#endif //_DEBUG
// CDrawView 消息处理程序
这是MFC生成的源程序,我要为CDrawDoc类添加消息处理函数.
这是调试代码:
<!- Copyright (c) Microsoft Corporation. All rights reserved. -->
<HTML DIR="LTR">
<HEAD>
<TITLE>添加成员函数向导</TITLE>
<META NAME="vs_targetSchema" CONTENT="http://schemas.
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=gb2312">
<META HTTP-EQUIV="MSThemeCompatible" CONTENT="Yes">
<LINK ID="LINKURL" REL="stylesheet" HREF="../../../../../2052/NewStyles.css">
<SYMBOL NAME="RETURN_TYPE" TYPE=text VALUE="void"></SYMBOL>
<SYMBOL NAME="FUNCTION_NAME" TYPE=text VALUE=""></SYMBOL>
<SYMBOL NAME="FUNCTION_FULLNAME" TYPE=text VALUE=""></SYMBOL>
<SYMBOL NAME="PARAMETER_TYPE" TYPE=text VALUE="int"></SYMBOL>
<SYMBOL NAME="PARAMETER_NAME" TYPE=text VALUE=""></SYMBOL>
<SYMBOL NAME="ACCESS" TYPE="select-one" VALUE=1></SYMBOL>
<SYMBOL NAME="STATIC" TYPE=checkbox VALUE=false></SYMBOL>
<SYMBOL NAME="VIRTUAL" TYPE=checkbox VALUE=false></SYMBOL>
<SYMBOL NAME="PURE" TYPE=checkbox VALUE=false></SYMBOL>
<SYMBOL NAME="INLINE" TYPE=checkbox VALUE=false></SYMBOL>
<SYMBOL NAME="IMPL_FILE" TYPE=text VALUE=""></SYMBOL>
<SYMBOL NAME="COMMENT" TYPE=text VALUE=""></SYMBOL>
</HEAD>
<BODY BGCOLOR="BUTTONFACE" TOPMARGIN="0" LEFTMARGIN="0" RIGHTMARGIN="0" BOTTOMMARGIN="0" ONLOAD="InitDocument(document);" ONKEYDOWN="OnKey();" ONKEYPRESS="OnPress()">
<TABLE CLASS="ONE" BORDER="0" CELLPADDING="0" CELLSPACING="0">
<COL WIDTH="100%">
<TR VALIGN="TOP">
<TD HEIGHT="79">
<!--OPEN OF ALL ENCOMPASSING TABLE ROW ONE//-->
<TABLE CLASS="TWO" BORDER="0" CELLPADDING="0" CELLSPACING="0">
<COL WIDTH="12"><COL><COL WIDTH="12">
<TR>
<TD VALIGN="TOP" HEIGHT="12" WIDTH="12">
</TD>
<TD VALIGN="TOP" HEIGHT="12">
</TD>
<TD VALIGN="TOP" HEIGHT="12" WIDTH="12">
</TD>
<TD CLASS="IMAGE" VALIGN="BOTTOM" WIDTH="110" ROWSPAN="2">
<DIV ID="Layer0">
<IMG CLASS="SMALLEST" SRC="..\..\Images\method.gif" WIDTH="63" HEIGHT="63" ALT="" BORDER="0">
</DIV>
</TD>
<TD VALIGN="TOP" HEIGHT="12" WIDTH="6" ROWSPAN="2">
</TD>
</TR>
<TR>
<TD VALIGN="TOP" HEIGHT="65" WIDTH="12">
</TD>
<TD VALIGN="TOP" HEIGHT="65">
<H4 CLASS="HEAD" ID="HEAD">欢迎使用添加成员函数向导</H4>
<P CLASS="SUBHEAD" ID="SUBHEAD">本向导向类、结构或联合添加成员函数。</P>
</TD>
<TD VALIGN="TOP" HEIGHT="65" WIDTH="12">
</TD>
</TR>
<TR>
<TD VALIGN="TOP" CLASS="RULE" COLSPAN="5" HEIGHT="2">
<TABLE BORDER="0" WIDTH="100%" HEIGHT="1" CELLPADDING="0" CELLSPACING="0">
<TR VALIGN="TOP">
<TD HEIGHT="1" WIDTH="100%" BGCOLOR="BUTTONSHADOW"></TD>
<TD HEIGHT="1" WIDTH="1" BGCOLOR="WINDOW"></TD>
</TR>
</TABLE>
</TD>
</TR>
</TABLE>
<!--CLOSE OF ALL ENCOMPASSING TABLE ROW ONE//-->
</TD>
</TR>
<TR VALIGN="TOP">
<TD HEIGHT="100%">
<!--OPEN OF ALL ENCOMPASSING TABLE ROW TWO//-->
<TABLE CLASS="ONE" BORDER="0" CELLPADDING="0" CELLSPACING="0">
<COL>
<TR>
<TD VALIGN="TOP" HEIGHT="100%">
<!--OPEN OF CONTENT AND BUTTON TABLE//-->
<TABLE CLASS="ONE" BORDER="0" CELLPADDING="0" CELLSPACING="0">
<COL WIDTH="100%">
<TR VALIGN="TOP">
<TD HEIGHT="100%">
<!--OPEN OF CONTENT//-->
<TABLE CLASS="CONTENT" BORDER="0" CELLPADDING="0" CELLSPACING="0">
<COL WIDTH="12"><COL WIDTH="185"><COL WIDTH="12"><COL WIDTH="185"><COL WIDTH="12"><COL WIDTH="185"><COL WIDTH="12">
<TR>
<TD VALIGN="TOP" HEIGHT="12" COLSPAN="7">
</TD>
</TR>
<TR>
<TD VALIGN="TOP" WIDTH="12">
</TD>
<TD VALIGN="TOP">
<SPAN CLASS="itemTextTop" TITLE="选择或输入该函数的返回类型。" ID="AUT_ID" >
<LABEL FOR="ReturnType" ID="ReturnType_LABEL">返回类型(<U>Y</U>):</LABEL>
<BR>
<INPUT CLASS="sideBtnThreeColumn" ID="RETURN_TYPE" TITLE="选择或输入该函数的返回类型。" TYPE="hidden"></INPUT>
<OBJECT CLASS="itemTextThreeColumn" ID="ReturnType" ACCESSKEY="Y" onblur="SetFunctionSignature();"
CLASSID="CLSID:d4d285dd-2447-11d7-8bf6-00b0d03daa06" VIEWASTEXT></OBJECT>
</SPAN>
</TD>
<TD VALIGN="TOP" WIDTH="12">
</TD>
<TD VALIGN="TOP">
<SPAN CLASS="itemTextTop" TITLE="输入要生成的函数的名称。" ID="AUT_ID1" >
<LABEL FOR="FUNCTION_NAME" ID="FUNCTION_NAME_LABEL">函数名(<U>U</U>):</LABEL>
<BR>
<INPUT CLASS="sideBtnThreeColumn" ID="FUNCTION_NAME" ACCESSKEY="U" TITLE="输入要生成的函数的名称。" TYPE="text" onPropertychange="OnFunctionName();">
</SPAN>
</TD>
<TD VALIGN="TOP" WIDTH="12">
</TD>
<TD VALIGN="TOP">
</TD>
<TD VALIGN="TOP" WIDTH="12">
</TD>
</TR>
<TR>
<TD VALIGN="TOP" HEIGHT="13" COLSPAN="7">
</TD>
</TR>
<TR VALIGN="TOP">
<TD VALIGN="TOP" WIDTH="12">
</TD>
<TD VALIGN="TOP">
<SPAN CLASS="itemText" TITLE="选择或输入要添加到参数列表的参数的数据类型。" ID="AUT_ID2" >
<LABEL FOR="ParameterType" ID="ParameterType_LABEL">参数类型(<U>T</U>):</LABEL>
<BR>
<INPUT CLASS="SideBtnThreeColumn" ID="PARAMETER_TYPE" TYPE="HIDDEN" TITLE="选择或输入要添加到参数列表的参数的数据类型。"></INPUT>
<OBJECT CLASS="itemTextThreeColumn" ID="ParameterType" ACCESSKEY="T" CLASSID="CLSID:d4d285dd-2447-11d7-8bf6-00b0d03daa06" VIEWASTEXT></OBJECT>
</SPAN>
</TD>
<TD VALIGN="TOP" WIDTH="12">
</TD>
<TD VALIGN="TOP">
<SPAN CLASS="itemText" TITLE="输入要添加到参数列表的参数名。" ID="AUT_ID3" >
<LABEL FOR="PARAMETER_NAME" ID="PARAMETER_NAME_LABEL">参数名(<U>N</U>):</LABEL>
<BR>
<INPUT CLASS="sideBtnThreeColumn" ID="PARAMETER_NAME" ACCESSKEY="N" TITLE="输入要添加到参数列表的参数名。" TYPE="text" onPropertychange="ToggleButtons(); SetFunctionSignature();" >
<BUTTON ID="AddBtn" TITLE="添加参数" CLASS="buttonClass2" ACCESSKEY="A" onClick="AddParameter();" type=button>添加(<U>A</U>)</BUTTON>
<SPAN CLASS="Spacer8"></SPAN>
<BUTTON ID="RemoveBtn" TITLE="移除参数" CLASS="buttonClass2" ACCESSKEY="R" onClick="RemoveParameter();" type=button>移除(<U>R</U>)</BUTTON>
</SPAN>
</TD>
<TD VALIGN="TOP" WIDTH="12">
</TD>
<TD VALIGN="TOP">
<SPAN CLASS="itemText" ID="PARAMETER_LIST_SPAN" TITLE="函数参数列表。">
<LABEL FOR="PARAMETER_LIST" ID="PARAMETER_LIST_LABEL">参数列表(<U>L</U>):</LABEL>
<BR>
<SELECT CLASS="SideBtnThreeColumn" SIZE="3" ID="PARAMETER_LIST" ACCESSKEY="L" TITLE="" VALUE="void" TITLE="函数参数列表。">
</SELECT>
</SPAN>
</TD>
<TD VALIGN="TOP" WIDTH="12">
</TD>
</TR>
<TR>
<TD VALIGN="TOP" HEIGHT="8" COLSPAN="7">
</TD>
</TR>
<TR VALIGN="TOP">
<TD VALIGN="TOP" WIDTH="12">
</TD>
<TD VALIGN="TOP">
<SPAN CLASS="itemText" TITLE="选择该函数的访问类型。" ID="AUT_ID4" >
<LABEL FOR="ACCESS" ID="Access_LABEL">访问(<U>E</U>):</LABEL>
<BR>
<SELECT CLASS="SideBtnThreeColumn" SIZE="1" ID="ACCESS" ACCESSKEY="e" TITLE="选择该函数的访问类型。" VALUE="1">
<-- vsCMAccessPublic = 1 -->
<OPTION VALUE="1" ID="PUBLIC_OPTION" SELECTED>public</OPTION>
<-- vsCMAccessProtected = 8
-->
<OPTION VALUE="8" ID="PROTECTED_OPTION">protected</OPTION>
<-- vsCMAccessPrivate = 2
-->
<OPTION VALUE="2" ID="PRIVATE_OPTION">private</OPTION>
</SELECT>
</SPAN>
</TD>
<TD VALIGN="TOP" WIDTH="12">
</TD>
<TD VALIGN="TOP">
<NOBR>
<SPAN CLASS="itemText" TITLE="生成静态函数。" ID="AUT_ID5"
STYLE="MARGIN-TOP:2PX;">
<INPUT TYPE="checkbox" ID="STATIC" ACCESSKEY="S" TITLE="生成静态函数。" onClick="OnFunctionType(this);" CHECKED>
<LABEL FOR="STATIC" ID="STATIC_LABEL">静态(<U>S</U>)    </LABEL>
</SPAN>
</NOBR>
<NOBR>
<SPAN CLASS="itemText" TITLE="生成虚函数。" ID="AUT_ID6"
STYLE="MARGIN-TOP:2PX;">
<INPUT TYPE="checkbox" ID="VIRTUAL" ACCESSKEY="V" TITLE="生成虚函数。" onClick="OnFunctionType(this);" CHECKED>
<LABEL FOR="VIRTUAL" ID="VIRTUAL_LABEL">虚函数(<U>V</U>)</LABEL>
</SPAN>
</NOBR>
<NOBR>
<SPAN CLASS="itemText" TITLE="生成纯虚函数。" ID="AUT_ID7"
STYLE="MARGIN-TOP:2PX;">
<INPUT TYPE="checkbox" ID="PURE" ACCESSKEY="P" TITLE="生成纯虚函数。" onClick="OnFunctionType(this);" CHECKED>
<LABEL FOR="PURE" ID="PURE_LABEL">纯虚函数(<U>P</U>)</LABEL>
</SPAN>
</NOBR>
<NOBR>
<SPAN CLASS="itemText" TITLE="生成内联函数。" ID="AUT_ID8"
STYLE="MARGIN-TOP:2px">
<INPUT TYPE="checkbox" ID="INLINE" ACCESSKEY="I" TITLE="生成内联函数。" onClick="OnFunctionType(this);" CHECKED>
<LABEL FOR="INLINE" ID="INLINE_LABEL">内联(<U>I</U>)</LABEL>
</SPAN>
</NOBR>
</TD>
<TD VALIGN="TOP" WIDTH="12">
</TD>
<TD VALIGN="TOP">
<NOBR>
<SPAN ID="impl_file_title" CLASS="itemText" TITLE="将实现函数的文件的名称。">
<LABEL FOR="IMPL_FILE" ID="IMPL_FILE_LABEL">.cpp 文件(<U>F</U>):</LABEL>
<BR>
<INPUT CLASS="sideBtn21" TYPE="text" ID="IMPL_FILE" ACCESSKEY="F" TITLE="将实现函数的文件的名称。">
<BUTTON CLASS="buttonClass3Custom" ID="BrowseBtn" TYPE="BUTTON" TITLE="浏览实现文件" onClick="OnBrowseImplFile();">...</BUTTON>
</SPAN>
</NOBR>
</TD>
<TD VALIGN="TOP" WIDTH="12">
</TD>
</TR>
<TR>
<TD VALIGN="TOP" HEIGHT="4" COLSPAN="7">
</TD>
</TR>
<TR VALIGN="TOP">
<TD VALIGN="TOP" WIDTH="12">
</TD>
<TD VALIGN="TOP" COLSPAN="5">
<SPAN CLASS="itemText" TITLE="出现在函数声明上方的注释。" ID="AUT_ID9" >
<NOBR>
<LABEL FOR="COMMENT" ID="COMMENT_LABEL">注释(不需要 // 表示法)(<U>M</U>):</LABEL>
</NOBR>
<BR>
<INPUT CLASS="COMMENT" TYPE="text" ID="COMMENT" ACCESSKEY="m" TITLE="出现在函数声明上方的注释。">
</SPAN>
</TD>
<TD VALIGN="TOP" WIDTH="12">
</TD>
</TR>
<TR>
<TD VALIGN="TOP" HEIGHT="12" COLSPAN="7">
</TD>
</TR>
<TR VALIGN="TOP">
<TD VALIGN="TOP" WIDTH="12">
</TD>
<TD VALIGN="TOP" COLSPAN="5">
<SPAN CLASS="itemText" TITLE="生成的函数签名。" ID="AUT_ID10"
DISABLED>
<NOBR>
<LABEL FOR="FUNCTION_SIGNATURE" ID="FUNCTION_SIGNATURE_LABEL">函数签名:</LABEL>
</NOBR>
<BR>
<INPUT CLASS="COMMENT" TYPE="text" ID="FUNCTION_SIGNATURE" TITLE="生成的函数签名。" READONLY DISABLED>
</SPAN>
</TD>
<TD VALIGN="TOP" WIDTH="12">
</TD>
</TR>
<TR>
<TD VALIGN="TOP" HEIGHT="100%" COLSPAN="7">
</TD>
</TR>
</TABLE>
<!--CLOSE OF CONTENT//-->
</TD>
</TR>
<TR VALIGN="BOTTOM">
<TD HEIGHT="48">
<!--OPEN OF BUTTON HTML//-->
<TABLE HEIGHT="48" BORDER="0" CELLPADDING="0" CELLSPACING="0">
<COL WIDTH="12"><COL><COL WIDTH="75"><COL WIDTH="4"><COL WIDTH="75"><COL WIDTH="4"><COL WIDTH="75"><COL WIDTH="12">
<TR>
<TD VALIGN="TOP" CLASS="RULE" COLSPAN="8" HEIGHT="2">
<TABLE BORDER="0" WIDTH="100%" HEIGHT="1" CELLPADDING="0" CELLSPACING="0">
<TR VALIGN="TOP">
<TD HEIGHT="1" WIDTH="100%" BGCOLOR="BUTTONSHADOW"></TD>
<TD HEIGHT="1" WIDTH="1" BGCOLOR="WINDOW"></TD>
</TR>
</TABLE>
</TD>
</TR>
<TR>
<TD VALIGN="TOP" HEIGHT="11" COLSPAN="8">
</TD>
</TR>
<TR>
<TD VALIGN="MIDDLE" HEIGHT="23" WIDTH="12">
</TD>
<TD VALIGN="TOP" HEIGHT="23">
</TD>
<TD VALIGN="MIDDLE" HEIGHT="23" WIDTH="75">
<BUTTON CLASS="BUTTONS" ID="FinishBtn" onClick="OnFinish(document);">完成</BUTTON>
</TD>
<TD VALIGN="MIDDLE" HEIGHT="23" WIDTH="4">
</TD>
<TD VALIGN="MIDDLE" HEIGHT="23" WIDTH="75">
<BUTTON CLASS="BUTTONS" ID="CancelBtn" onClick="window.external.Finish(document, 'cancel');">取消</BUTTON>
</TD>
<TD VALIGN="MIDDLE" HEIGHT="23" WIDTH="4">
</TD>
<TD VALIGN="MIDDLE" HEIGHT="23" WIDTH="75">
<BUTTON CLASS="BUTTONS" ID="HelpBtn" onClick="window.external.OnHelp('vc.codewiz.function.overview');">帮助</BUTTON>
</TD>
<TD VALIGN="MIDDLE" HEIGHT="23" WIDTH="12">
</TD>
</TR>
<TR>
<TD VALIGN="TOP" HEIGHT="12" COLSPAN="8">
</TD>
</TR>
</TABLE>
<!--CLOSE OF BUTTON HTML//-->
</TD>
</TR>
</TABLE>
<!--CLOSE OF CONTENT AND BUTTON TABLE//-->
</TD>
</TR>
</TABLE>
<!--CLOSE OF ALL ENCOMPASSING TABLE ROW TWO//-->
</TD>
</TR>
</TABLE>
</BODY>
</HTML>
<SCRIPT LANGUAGE="JSCRIPT">
var strParameters = "";
var tab_array = new Array();
function InitDocument(document)
{
setDirection();
if (window.external.FindSymbol("DOCUMENT_FIRST_LOAD"))
{
var L_WizardDialogTitle_Text = "添加成员函数向导";
window.external.AddSymbol("WIZARD_DIALOG_TITLE", L_WizardDialogTitle_Text);
window.external.SetDefaults(document);
}
window.external.Load(document);
// Disable virtual checkbox for unions
if(window.external.ParentKind == vsCMElementUnion)
{
VIRTUAL.disabled = true;
VIRTUAL_LABEL.disabled = true;
PURE.disabled = true;
PURE_LABEL.disabled = true;
}
// Find the file of first implementation of member function and make it default
var impl = window.external.ParentObject.Functions;
for(var item = 1; item<=impl.Count+1; item++)
{
var strModule;
if(item<=impl.Count)
strModule = impl(item).Location(vsCMWhereDefault);
else
strModule = window.external.ParentObject.Location(vsCMWhereDeclaration); // Just the class declaration file, if we did not find any function definition
// Extract just the file name
strModule = strModule.substr(strModule.lastIndexOf('\\')+1);
var dotIndex = strModule.lastIndexOf('.');
var strExtention = strModule.substr(dotIndex).toUpperCase();
if(strExtention==".CPP")
{
IMPL_FILE.value = strModule;
break;
}
}
PopulateReturnTypes();
PopulateParamTypes();
ReturnType.ListIndex = 5;
ParameterType.ListIndex = 4;
SetFunctionSignature();
ReturnType.focus();
ToggleButtons();
}
function Next(document, linkto)
{
window.external.Next(document, linkto);
}
function OnFinish(document)
{
RETURN_TYPE.value = ReturnType.Value;
PARAMETER_TYPE.value = ParameterType.Value;
if (!ValidateInput())
return;
OnWizFinish(document);
}
function OnBrowseImplFile()
{
var strFile;
try
{
L_Title1_Text = "VS 向导选择文件";
L_Title2_Text = "Visual C++ 文件(*.cpp;*.h;*.inl;*.c)\0*.cpp;*.h;*.inl;*.c\0\0";
strFile = window.external.GetOpenFileNameViaDlg(L_Title1_Text, window.external.FindSymbol("PROJECT_PATH"), L_Title2_Text, IMPL_FILE.value);
}
catch(e)
{
if (e.number != OLE_E_PROMPTSAVECANCELLED)
{
L_Err1_Text = "OnBrowseImplFile() 中出现错误";
if (e.description.length != 0)
{
L_Err1_Text += ": ";
L_Err1_Text += e.description;
}
window.external.ReportError(L_Err1_Text);
}
return;
}
IMPL_FILE.value = strFile;
}
function PopulateReturnTypes()
{
ReturnType.Clear();
ReturnType.AddItem("bool");
ReturnType.AddItem("char");
ReturnType.AddItem("double");
ReturnType.AddItem("float");
ReturnType.AddItem("HRESULT");
ReturnType.AddItem("int");
ReturnType.AddItem("long");
ReturnType.AddItem("long double");
ReturnType.AddItem("short");
ReturnType.AddItem("unsigned char");
ReturnType.AddItem("unsigned int");
ReturnType.AddItem("unsigned long");
ReturnType.AddItem("void");
}
function PopulateParamTypes()
{
ParameterType.Clear();
ParameterType.AddItem("bool");
ParameterType.AddItem("char");
ParameterType.AddItem("double");
ParameterType.AddItem("float");
ParameterType.AddItem("int");
ParameterType.AddItem("long");
ParameterType.AddItem("long double");
ParameterType.AddItem("short");
ParameterType.AddItem("unsigned char");
ParameterType.AddItem("unsigned int");
ParameterType.AddItem("unsigned long");
}
function OnFunctionName()
{
SetFunctionSignature();
}
function OnFunctionType(obj)
{
if (obj.id == "STATIC" && STATIC.checked)
{
// Static cannot be virtual or pure
VIRTUAL.checked = false;
PURE.checked = false;
INLINE.disabled = false;
INLINE_LABEL.disabled = false;
IMPL_FILE.disabled = false;
impl_file_title.disabled = false;
BrowseBtn.disabled = false;
}
else if (obj.id == "VIRTUAL")
{
if (VIRTUAL.checked)
{
STATIC.checked = false;
}
else
{
PURE.checked = false;
// Re-enable the virtual and inline checkboxes
// and other related stuff that may have been disabled by PURE
INLINE.disabled = false;
INLINE_LABEL.disabled = false;
IMPL_FILE.disabled = false;
impl_file_title.disabled = false;
BrowseBtn.disabled = false;
}
}
else if (obj.id == "INLINE")
{
var bInline = INLINE.checked;
IMPL_FILE.disabled = bInline;
impl_file_title.disabled = bInline;
BrowseBtn.disabled = bInline;
}
else if (obj.id == "PURE")
{
if (PURE.checked)
{
// If it is pure, then it is not static and has to be virtual
STATIC.checked = false;
VIRTUAL.checked = true;
// Inline has no meaning (no body for pure) so uncheck and disable
// it and other related stuff
INLINE.checked = false;
INLINE.disabled = true;
INLINE_LABEL.disabled = true;
IMPL_FILE.disabled = true;
impl_file_title.disabled = true;
BrowseBtn.disabled = true;
}
else
{
// Re-enable the virtual and inline checkboxes
// and other related stuff
INLINE.disabled = false;
INLINE_LABEL.disabled = false;
IMPL_FILE.disabled = false;
impl_file_title.disabled = false;
BrowseBtn.disabled = false;
}
}
SetFunctionSignature();
}
function SetFunctionSignature()
{
var strVal = "";
if (STATIC.checked)
strVal = "static ";
if (VIRTUAL.checked)
strVal = "virtual ";
strVal += ReturnType.Value;
if (strParameters == "")
{
if (PURE.checked)
strVal += " " + FUNCTION_NAME.value + "(void) = 0";
else
strVal += " " + FUNCTION_NAME.value + "(void)";
}
else
{
if (PURE.checked)
strVal += " " + FUNCTION_NAME.value + "(" + strParameters + ") = 0";
else
strVal += " " + FUNCTION_NAME.value + "(" + strParameters + ")";
}
FUNCTION_SIGNATURE.value = strVal;
}
function AddParameter()
{
PARAMETER_TYPE.value = ParameterType.Value;
if (ParameterType.Value == "" || ParameterType.Value == "void" )
{
L_Err2_Text = "无效值";
window.external.ReportError(L_Err2_Text);
ParameterType.focus();
return;
}
var strName = PARAMETER_NAME.value;
var bEmpty = true;
for (i = 0; i < strName.length; i++)
{
if (strName.substr(i, 1) != " ")
{
bEmpty = false;
break;
}
}
if (strName.length == 0 || bEmpty)
{
L_Err3_Text = "必须指定名称。";
window.external.ReportError(L_Err3_Text);
PARAMETER_NAME.focus;
return;
}
var strParamNames = ExtractParamNames() + "," + strName;
if(!window.external.dte.VCLanguageManager.ValidateParameterNames(FUNCTION_NAME.value, strParamNames, vsCMElementFunction))
{
window.external.ReportError();
PARAMETER_NAME.focus();
return;
}
var strParam, NamePos, NameLength, NameLengthPos;
try
{
NameLengthPos = new VBArray(window.external.CppParseTypeString(ParameterType.Value));
}
catch(e)
{
L_Err4_Text = "无效的参数类型";
window.external.ReportError(L_Err4_Text);
ParameterType.focus();
return;
}
NamePos = NameLengthPos.getItem(0);
NameLength = NameLengthPos.getItem(1);
if(NamePos==ParameterType.Value.length)
{
strParam = ParameterType.Value + " " + strName;
}
else
{
strParam = ParameterType.Value.substr(0, NamePos) + " " + strName;
strParam += ParameterType.Value.substr(NamePos+NameLength); //always replace eventual name with PARAMETER_NAME.value
}
if (strParameters == "")
strParameters = strParam
else
strParameters += (", " + strParam);
PARAMETER_NAME.value = "";
var Params = document.all.tags("SELECT").item("PARAMETER_LIST");
var Opt = document.createElement("OPTION");
Opt.value = strParam;
Opt.text = strParam;
Params.add(Opt);
Params.selectedIndex = Params.length - 1;
SetFunctionSignature();
ToggleButtons();
ParameterType.focus();
}
function ExtractParamNames()
{
var strParamNames = "";
var Params = document.all.tags("SELECT").item("PARAMETER_LIST");
for(var index=0; index < Params.options.length; index++)
{
var strParam = Params.options[index].value;
var NamePos, NameLength;
var NameLengthPos = new VBArray(window.external.CppParseTypeString(strParam));
NamePos = NameLengthPos.getItem(0);
NameLength = NameLengthPos.getItem(1);
if(index!=0)
strParamNames += ","
strParamNames += strParam.substr(NamePos, NameLength);
}
return strParamNames;
}
function RemoveParameter()
{
var Params = document.all.tags("SELECT").item("PARAMETER_LIST");
var len = Params.options.length;
if (!len)
return;
if (Params.selectedIndex == -1)
return;
var nIndex = Params.selectedIndex;
Params.remove(Params.selectedIndex);
if (Params.options.length)
Params.selectedIndex = (nIndex < Params.length) ? nIndex : Params.length-1;
strParameters = "";
for(var nParam=0; nParam < Params.length; nParam++)
{
if(nParam!=0)
strParameters += ", ";
strParameters += Params.options[nParam].value;
}
SetFunctionSignature();
ToggleButtons();
}
function ValidateInput()
{
var oInvalid = null;
var strType = TrimStr(RETURN_TYPE.value);
if (strType == "")
{
strType = "void";
}
var strFuncName = FUNCTION_NAME;
strFuncName.value = TrimStr(strFuncName.value);
if (!Validate(strFuncName))
oInvalid = FUNCTION_NAME;
if (oInvalid == null && !INLINE.checked && !PURE.checked)
{
if (IMPL_FILE.value != "")
{
if (!Validate(IMPL_FILE))
oInvalid = IMPL_FILE;
}
}
if (oInvalid != null)
{
window.external.ReportError();
oInvalid.focus();
return false;
}
RETURN_TYPE.value = strType;
FUNCTION_NAME.value = strFuncName.value;
return true;
}
function Validate(obj)
{
try
{
var bValid = true;
switch(obj.id)
{
case "FUNCTION_NAME":
{
var strNameWithParamList = FUNCTION_NAME.value + "(" + strParameters + ")";
window.external.AddSymbol("FUNCTION_FULLNAME", strNameWithParamList);
bValid = window.external.ParentObject.ValidateMember(strNameWithParamList, vsCMElementFunction, RETURN_TYPE.value);
if (bValid)
bValid = window.external.dte.VCLanguageManager.ValidateParameterNames(obj.value, ExtractParamNames(), vsCMElementFunction);
break;
}
case "IMPL_FILE":
bValid = ValidateFileNameAndEnsureInProject(obj.value, vsCMValidateFileExtCppSource);
break;
default:
break;
}
if (typeof(bValid) == "undefined")
bValid = false;
return bValid;
}
catch(e)
{
window.external.SetErrorInfo(e.description);
return false;
}
}
function ToggleButtons()
{
if (ParameterType.Value.length && PARAMETER_NAME.value.length)
{
AddBtn.disabled = false;
}
else
{
AddBtn.disabled = true;
}
if (PARAMETER_LIST.options.length && PARAMETER_LIST.selectedIndex != -1)
{
RemoveBtn.disabled = false;
}
else
{
RemoveBtn.disabled = true;
}
}
</SCRIPT>
<SCRIPT ID="INCLUDE_SCRIPT" LANGUAGE="JSCRIPT"></SCRIPT>
<SCRIPT ID="INCLUDE_COMMON" LANGUAGE="JSCRIPT"></SCRIPT>
<SCRIPT>
document.scripts("INCLUDE_SCRIPT").src = window.external.FindSymbol("SCRIPT_COMMON_PATH") + "/Script.js";
document.scripts("INCLUDE_COMMON").src = window.external.FindSymbol("SCRIPT_COMMON_PATH") + "/Common.js";
</SCRIPT>
<SCRIPT FOR="ReturnType" EVENT="Change">
SetFunctionSignature();
</SCRIPT>
<SCRIPT FOR="ReturnType" EVENT="KeyDown(nKeyCode)">
OnWizComboKeyDown(nKeyCode);
</SCRIPT>
<SCRIPT FOR="ParameterType" EVENT="Change">
ToggleButtons();
</SCRIPT>
<SCRIPT FOR="ParameterType" EVENT="KeyDown(nKeyCode)">
OnWizComboKeyDown(nKeyCode);
</SCRIPT>