1.在Dialogs視圖中,右鍵All Dialog,選擇新建對話框(New Dialog)
2.創建一個空白對話框,命名爲MyDlg.
3.雙擊MyDlg下的子項即可進入對話框的編輯模式
4.這裏我們添加一個Hello按鈕。選擇按鈕控件然後在對話框的界面上拖拉出一個按鈕控件。
修改按鈕屬性text爲Hello。注意一下這裏的Control Identifer屬性值,後面我們會用到。
5.在installscript視圖中新建一個rul文件,命名爲MyDlg.url
6.編寫MyDlg.url
內容如下:
#define DLG_MYDLG "MyDlg" //MyDlg是我們的對話框名字
#define HELLOBTN 1301 //1301就是我們那個按鈕的Control Identifer屬性值
prototype NUMBER MyDlg(BYREF STRING);
function NUMBER MyDlg(msg)
HWND hDlg;
NUMBER nId, nResult;
NUMBER nControl;
BOOL bDone;
begin
//初始對話框函數
if (EzDefineDialog( DLG_MYDLG,ISUSER , "MyDlg", 0 ) = DLG_ERR) then
return ISERR_GEN_FAILURE;
endif;
bDone = FALSE;
//循環
while (!bDone)
nId = WaitOnDialog( DLG_MYDLG ); //獲得對話框的消息
switch (nId)
case HELLOBTN: //如果是HELLOBTN
MessageBox(msg,WARNING);
bDone=TRUE;
case DLG_ERR:
nId = ISERR_GEN_FAILURE;
SdError(nId, DLG_MYDLG);
bDone = TRUE;
case DLG_CLOSE:
SdCloseDlg(hDlg, nId, bDone);
default:
// check standard handling
if (SdIsStdButton(nId) && SdDoStdButton(nId)) then
bDone = TRUE;
endif;
endswitch;
endwhile;
end;
7.setup.url內容:
//添加的內容是 #include "MyDlg.rul"
//以及我們自定義的對話框。其他的代碼都是自動生成的。
// First Install UI Sequence - Before Move Data
//
// The OnFirstUIBefore event is called by OnShowUI when the setup is
// running in first install mode. By default this event displays UI allowing
// the end user to specify installation parameters.
//
// Note: This event will not be called automatically in a
// program...endprogram style setup.
//---------------------------------------------------------------------------
#include "MyDlg.rul"
function OnFirstUIBefore()
number nResult, nLevel, nSize, nSetupType;
string szTitle, szMsg, szOpt1, szOpt2, szLicenseFile;
string szName, szCompany, szTargetPath, szDir, szFeatures;
BOOL bLicenseAccepted;
begin
nSetupType = COMPLETE;
szDir = TARGETDIR;
szName = "";
szCompany = "";
bLicenseAccepted = FALSE;
// Beginning of UI Sequence
Dlg_Start:
nResult = 0;
Dlg_SdWelcome:
szTitle = "";
szMsg = "";
//{{IS_SCRIPT_TAG(Dlg_SdWelcome)
nResult = SdWelcome( szTitle, szMsg );
//}}IS_SCRIPT_TAG(Dlg_SdWelcome)
if (nResult = BACK) goto Dlg_Start;
Dlg_Hello:
////我們自定義的對話框
szTitle="";
szMsg="It's my hello DLG";
nResult=MyDlg(szMsg);
if (nResult=BACK) goto Dlg_Start;
Dlg_SdLicense2:
szTitle = "";
szOpt1 = "";
szOpt2 = "";
//{{IS_SCRIPT_TAG(License_File_Path)
szLicenseFile = SUPPORTDIR ^ "License.rtf";
//}}IS_SCRIPT_TAG(License_File_Path)
//{{IS_SCRIPT_TAG(Dlg_SdLicense2)
nResult = SdLicense2Rtf( szTitle, szOpt1, szOpt2, szLicenseFile, bLicenseAccepted );
//}}IS_SCRIPT_TAG(Dlg_SdLicense2)
if (nResult = BACK) then
goto Dlg_SdWelcome;
else
bLicenseAccepted = TRUE;
endif;
Dlg_SdRegisterUser:
szMsg = "";
szTitle = "";
//{{IS_SCRIPT_TAG(Dlg_SdRegisterUser)
// nResult = SdRegisterUser( szTitle, szMsg, szName, szCompany );
//}}IS_SCRIPT_TAG(Dlg_SdRegisterUser)
if (nResult = BACK) goto Dlg_MyDlg;
Dlg_SetupType2:
szTitle = "";
szMsg = "";
nResult = CUSTOM;
//{{IS_SCRIPT_TAG(Dlg_SetupType2)
// nResult = SetupType2( szTitle, szMsg, "", nSetupType, 0 );
//}}IS_SCRIPT_TAG(Dlg_SetupType2)
if (nResult = BACK) then
goto Dlg_SdRegisterUser;
else
nSetupType = nResult;
if (nSetupType != CUSTOM) then
szTargetPath = TARGETDIR;
nSize = 0;
FeatureCompareSizeRequired( MEDIA, szTargetPath, nSize );
if (nSize != 0) then
MessageBox( szSdStr_NotEnoughSpace, WARNING );
goto Dlg_SetupType2;
endif;
endif;
endif;
Dlg_SdAskDestPath2:
if ((nResult = BACK) && (nSetupType != CUSTOM)) goto Dlg_SetupType2;
szTitle = "";
szMsg = "";
if (nSetupType = CUSTOM) then
//{{IS_SCRIPT_TAG(Dlg_SdAskDestPath2)
nResult = SdAskDestPath2( szTitle, szMsg, szDir );
//}}IS_SCRIPT_TAG(Dlg_SdAskDestPath2)
TARGETDIR = szDir;
endif;
if (nResult = BACK) goto Dlg_SetupType2;
Dlg_SdFeatureTree:
if ((nResult = BACK) && (nSetupType != CUSTOM)) goto Dlg_SdAskDestPath2;
szTitle = "";
szMsg = "";
szFeatures = "";
nLevel = 2;
if (nSetupType = CUSTOM) then
//{{IS_SCRIPT_TAG(Dlg_SdFeatureTree)
// nResult = SdFeatureTree( szTitle, szMsg, TARGETDIR, szFeatures, nLevel );
//}}IS_SCRIPT_TAG(Dlg_SdFeatureTree)
if (nResult = BACK) goto Dlg_SdAskDestPath2;
endif;
Dlg_SQLServer:
nResult = OnSQLServerInitialize( nResult );
if( nResult = BACK ) goto Dlg_SdFeatureTree;
Dlg_ObjDialogs:
nResult = ShowObjWizardPages( nResult );
if (nResult = BACK) goto Dlg_SQLServer;
Dlg_SdStartCopy2:
szTitle = "";
szMsg = "";
//{{IS_SCRIPT_TAG(Dlg_SdStartCopy2)
nResult = SdStartCopy2( szTitle, szMsg );
//}}IS_SCRIPT_TAG(Dlg_SdStartCopy2)
if (nResult = BACK) goto Dlg_ObjDialogs;
// Added in 11.0 - Set appropriate StatusEx static text.
SetStatusExStaticText( SdLoadString( IDS_IFX_STATUSEX_STATICTEXT_FIRSTUI ) );
return 0;
end;
編譯運行就可以看到自己的對方框了。