InstallShield自定义对话框模板代码(转)

ExpandedBlockStart.gif 代码
//===========================================================================
//
//  File Name:   MyCustomDialog.rul
//
//  Description: Custom Dialog Template
//
//  Comments:    Written by Kevin Wan. Written August  2010 .
//               This  is  freeware  as   long   as  you keep mention my name in your code
//               Send questions  to  kevin.wan@msn.com  or  QQ: 17842153
//
//===========================================================================


// Include Ifx.h  for   built - in InstallScript  function   prototypes. 
#include  " Ifx.h "    

#define  RES_DIALOG_ID      13699     //  ID of dialog itself 

export prototyp e MyCustomDialog( string string ); 

function  MyCustomDialog(szTitle, szMsg) 
    
string   szDlg, szDialogName, szDLLName, szDialog;
    
number   nId, nSdDialog, hInstance, hwndParent, nResult;
    
HWND     hwndDlg;  
    
BOOL    bDone;    
begin 
     //  Specify a name  to  ident ify the custom dialog in this installation. 
    szDlg      =   " NewDialog " ;
    nSdDialog  =   RES_DIALOG_ID;  
    
     //  record data produced by this dialog
    
if ( MODE  SILENTMODE then
        
return  nId;
    
endif
      
     //  ensure gener al initialization  is  complete
    
if ( ! bSdInit then
        
SdInit ();
    
endif ;  
    
    szDialogName  =   " NewDialog " ;
    hInstance   =   0 ;
    szDLLName   =   "" ;
    szDialog    =   ""
    hwndParent  =   0
    nResult   =   DefineDialog  (szDialogName, hInstance, szDLLName, nSdDialog, szDialog, 
                             hwndParent, HWND_INSTALL, 
                             
DLG_MSG_STANDARD | DLG_CENTERED );    
    
if  ( nResult  =   DLG_ERR  then
       bDone  =   TRUE ;
       
return  - 1 ;
    
endif ;  

     //  Initialize the indica tor used  to  control the  while   loop
    bDone  =   FALSE

     //   Loop  until done. 
    
while  (!bDone)

         //  Display  the dialog  and  return the  next  dialog  event. 
        nId  =   WaitOnDialog ( szDlg );

         //  Respond  to  the event. 
        
switch (nId) 
        
            
case   DLG_INIT:
            
                  //  No initialization  is  required  for  this example.   

            
case   NEXT
                
          nId    =   NEXT ;
                bDone  =   TRUE

            
case  BACK: 
            
                nId     =   BACK;
                bDone  =   TRUE ;  
                
            
case   DLG_ERR
            
                
SdError - 1 " MyDefineDialog "  );
                nId     =   - 1
                bDone   =   TRUE ;   
                
            
case   DLG_CLOSE :   
            
                
SdCloseDlg ( hwndDlg, nId, bDone );    
                            
            
default

                 // check standard handling
               
if ( SdIsStdButton ( nId ) && SdDoStdButton ( nId )) then
                   
bDone = TRUE;
               
endif;
        
endswitch
    
endwhile


     //  Cleanup Dialog
    
EndDialog ( szDlg );
    
ReleaseDialog ( szDlg );
    
SdUnInit ();
    
    
//  record data produced by this dialog
    
if ( MODE  RECORDMODE then
         //
    
endif;

    
return  nId;
end

另InstallShield帮助文件中代码模板:

//  Dialog and control IDs. 

#define  RES_DIALOG_ID     12027    //  ID of dialog itself 

#define  RES_PBUT_NEXT         1    //  ID of Next button 

#define  RES_PBUT_CANCEL       9    //  ID of Cancel button 

#define  RES_PBUT_BACK        12    //  ID of Back button 


//  Include Ifx.h for built-in InstallScript function prototypes. 

#include 
" Ifx.h "  


export prototype ExFn_DefineDialog(HWND); 


function ExFn_DefineDialog(hMSI) 

    STRING  szDialogName, szDLLName, szDialog; 

    NUMBER  nDialog, nResult, nCmdValue; 

    BOOL    bDone; 

    HWND    hInstance, hwndParent; 

begin 


    
//  Define the name of a dialog to pass as first 

    
//  parameter to DefineDialog. 

    szDialogName 
=   " ExampleDialog "

     

    
//  DefineDialog's second parameter will be 0 because the 

    
//  .dll file is in _isres.dll. 

    hInstance 
=   0

     

    
//  DefineDialog's third parameter will be null; installation will 

    
//  search for the dialog in _isuser.dll and _isres.dll. 

    szDLLName 
=   ""

     

    
//  DefineDialog's fifth parameter will be null because the 

    
//  dialog is identified by its ID in the fourth parameter. 

    szDialog 
=   ""

     

    
//  This value is reserved and must be 0. 

    hwndParent 
=   0

     

    
//  Define the dialog. The installation's main window will own the 

    
//  dialog (indicated by HWND_INSTALL in parameter 7). 

    nResult  
=  DefineDialog (szDialogName, hInstance, szDLLName, 

                            RES_DIALOG_ID, szDialog, hwndParent, 

                            HWND_INSTALL, DLG_MSG_STANDARD
| DLG_CENTERED); 

     

    
//  Check for an error. 

    
if  (nResult  <   0 ) then 

        MessageBox (
" An error occurred while defining the dialog. " , SEVERE); 

        bDone 
=  TRUE; 

        abort; 

    endif; 


   
//  Initialize the indicator used to control the while loop. 

   bDone 
=  FALSE; 


   
//  Loop until done. 

   repeat 


        
//  Display the dialog and return the next dialog event. 

        nCmdValue 
=  WaitOnDialog(szDialogName); 


        
//  Respond to the event. 

        
switch  (nCmdValue) 

            
case  DLG_CLOSE: 

                
//  The user clicked the window's Close button. 

                Do (EXIT); 

            
case  DLG_ERR: 

                MessageBox (
" Unable to display dialog. Setup canceled. " , SEVERE); 

                abort; 

            
case  DLG_INIT: ; 

                
//  No initialization is required for this example. 

            
case  RES_PBUT_CANCEL: 

                
//  The user clicked the Cancel button. 

                Do (EXIT); 

            
case  RES_PBUT_NEXT: 

                bDone 
=  TRUE; 

            
case  RES_PBUT_BACK: 

                bDone 
=  TRUE; 

            
//  check standard handling 

            
if  (SdIsStdButton( nCmdValue )  &&  SdDoStdButton( nCmdValue )) then 

                bDone 
=  TRUE; 

            endif; 

        endswitch; 


    until bDone; 


    
//  Close the dialog. 

    EndDialog (szDialogName); 


    
//  Free the dialog from memory. 

    ReleaseDialog (szDialogName); 


end; 

参考网址:http://www.cnblogs.com/installshield/archive/2010/09/13/1824981.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值