zoukankan      html  css  js  c++  java
  • Installshield系列(三) 自定义窗口

    使用的是Install MSI Project

    (1)新建一个Dialog。

    InstallShield ->Installation Designer->User Interface->Diaglogs->All Dialogs->使用各种方法新建一个Dialog(直接New或者Import)

    (2)写自定义函数

       

     脚本

    #include "sqlhelper.rul"    //导入其他脚本函数
    #define DLG_MYDLG "SdCheckHytIndustry"  //SdCheckHytIndustry是我们的对话框名字
    #define btnTestConn 1302      //测试按钮  
    #define Server 1307           //服务器地址    
    #define DataBaseName 1308     //数据库名   
    #define UserName 1309         //用户名
    #define Password 1310         //密码 
    prototype NUMBER SetMidDataBase( BYREF STRING, BYREF STRING, BYREF STRING, BYREF STRING); 
    function NUMBER SetMidDataBase(svServer,svDatabaseName,svUserName,svPwd)
         HWND    hDlg,hwndItem,hwndDlg,hwndItemTest;      
         NUMBER nId, nResult; 
        NUMBER nControl,nMessage;
        BOOL bDone;  
        string msg,szPwd;
    begin  
          // ensure general initialization is complete
               if (!bSdInit) then
                  SdInit( );
               endif;
        //初始对话框函数
         if (EzDefineDialog( DLG_MYDLG,ISUSER , DLG_MYDLG, 0 ) = DLG_ERR) then         
             MessageBox ("Error in defining dialog", SEVERE); 
         return ISERR_GEN_FAILURE;
        endif;          
        bDone = FALSE;     
        //循环
        while (!bDone)
            nId = WaitOnDialog( DLG_MYDLG ); //获得对话框的消息  
            hwndDlg = CmdGetHwndDlg( DLG_MYDLG );
            hwndItem = CtrlGetDlgItem( "", hwndDlg, NEXT );        
            switch (nId)
            case DLG_INIT:
                CtrlSetText( DLG_MYDLG, DataBaseName, svDatabaseName );
                CtrlSetText( DLG_MYDLG, Server, svServer );
                CtrlSetText( DLG_MYDLG, UserName, svUserName );
                CtrlSetText( DLG_MYDLG, Password, svPwd );               
                StrTrim( svDatabaseName )    ;
                StrTrim( svServer )    ;
                StrTrim( svUserName )    ;
                StrTrim( svPwd )   ;   
                if(svPwd=""||svDatabaseName=""||svServer=""||svUserName=""||!CheckConnection(svServer,svDatabaseName,svUserName,svPwd))
                       then                    
                        EnableWindow( hwndItem, FALSE);
                endif;   
            case btnTestConn:
       //调用SqlHelper脚本里的CheckConnection函数
    if(CheckConnection(svServer,svDatabaseName,svUserName,svPwd)) then MessageBox("连接成功",INFORMATION) ; EnableWindow( hwndItem, TRUE); else MessageBox("连接失败",SEVERE) ; EnableWindow( hwndItem, FALSE); endif; case Password: nMessage = CtrlGetSubCommand( DLG_MYDLG ); if( nMessage = EDITBOX_EDITBOXCHANGE ) then CtrlGetText( DLG_MYDLG, Password, svPwd); endif; StrTrim( svPwd ) ; if(svPwd="") then EnableWindow( hwndItem, FALSE); endif; case UserName: nMessage = CtrlGetSubCommand( DLG_MYDLG ); if( nMessage = EDITBOX_CHANGE ) then CtrlGetText( DLG_MYDLG, UserName, svUserName); endif; StrTrim( svUserName ) ; if(svUserName="") then EnableWindow( hwndItem, FALSE); endif; case DataBaseName: nMessage = CtrlGetSubCommand( DLG_MYDLG ); if( nMessage = EDITBOX_CHANGE ) then CtrlGetText( DLG_MYDLG, DataBaseName, svDatabaseName); endif; StrTrim( svDatabaseName ) ; if(svDatabaseName="") then EnableWindow( hwndItem, FALSE); endif; case Server: nMessage = CtrlGetSubCommand( DLG_MYDLG ); if( nMessage = EDITBOX_CHANGE ) then CtrlGetText( DLG_MYDLG, Server, svServer); endif; StrTrim( svServer ) ; if(svServer="") then EnableWindow( hwndItem, FALSE); endif; case BACK: nId=BACK; bDone = TRUE; case NEXT: nId=NEXT; 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; //释放窗体 EndDialog( DLG_MYDLG ); ReleaseDialog( DLG_MYDLG ); SdUnInit( ); MsiSetProperty(ISMSI_HANDLE,"CONN","Data Source="+svServer+";Initial Catalog="+svDatabaseName+";User ID="+svUserName+";Password="+svPwd); return nId; end;


    总结:

    (1)初始化窗口。

    (2)使用While函数写各个控件的事件。

           

         

  • 相关阅读:
    Android Studio中无法找到android.os.SystemProperties解决办法
    Faster R-CNN: Towards Real-Time Object Detection with Region Proposal Networks
    神经网络中的常用表示方式
    Leetcode 223. 矩形面积
    Leetcode 836. 矩形重叠
    Mysql-索引
    Mysql表操作
    Mysql-概念
    利用mnist数据集进行深度神经网络
    剑指-面试题-07.重建二叉树
  • 原文地址:https://www.cnblogs.com/forneter/p/3826915.html
Copyright © 2011-2022 走看看