IS裡面自己DIY Dialog後,添加 rul 腳本來控制 Dialog 的行為.

#ifndef SQLCONNECTPARAM__RUL
 #define SQLCONNECTPARAM__RUL
 #include "Func.rul"
 
 #define RES_PBUT_NEXT         1   // ID of 'Next' push button
 #define RES_PBUT_CANCEL       9   // ID of 'Cancel' push button
 #define RES_PBUT_BACK        12
 
 #define RES_DIALOG_NAME    "SQLConnectParam"
 #define RES_DIALOG_EdtServer  1400
 #define RES_DIALOG_EdtDatabase  1401
 #define RES_DIALOG_EdtUser   1402
 #define RES_DIALOG_EdtPassword  1403
 #define RES_DIALOG_EdtPassword2 1403
               
 export prototype SQLConnectParam(byref string /*Server Name*/,byref string/*Database*/,byref string/*User Name*/,byref string/*Password*/);
 export prototype SQLConnectParam_TestParam(string,string,string,string);
 
 function SQLConnectParam_TestParam(szServer,szDatabase,szUser,szPassword)
  variant Conn,RS;
  string szConnectString;
  BOOL bResult;
  string SQL;
 begin 
  bResult = FALSE;   
  MessageBox(@MSGODBCSet,INFORMATION);
  SdShowMsg(@IDS__SQLConnect_Test,TRUE);   
     szConnectString = "Driver={SQL Server};Server=%s;database=%s;UID=%s;PWD=%s";
     trs_sql(szServer);trs_sql(szDatabase);trs_sql(szUser);trs_sql(szPassword);
     Sprintf(szConnectString,szConnectString,szServer,szDatabase,szUser,szPassword);
  set Conn = CreateObject("ADODB.Connection");  
  try 
   Conn.Open(szConnectString);
         if (IsObject(Conn)) then
          bResult = TRUE;
         endif;
  catch
         bResult = FALSE;
  endcatch;
  if(!bResult)then
   SdShowMsg(@IDS__SQLConnect_Test,FALSE);
         MessageBox(@IDS__SQLConnect_ConnectError,SEVERE);      
        endif; 
        set Conn = NOTHING;
  SdShowMsg(@IDS__SQLConnect_Test,FALSE);
        return bResult;
 end;
 
 function SQLConnectParam(szServer,szDatabase,szUser,szPassword)
     STRING  szDialogName, szDLLName, szDialog;
     NUMBER  nDialog, nResult, nCmdValue;
     BOOL    bDone;
     HWND    hInstance, hwndParent;
     LIST lWebServer;
     STRING  szMessage;
     string  szTmp;
     string szS,szU,szD,szU2;
 begin    
     szDialogName = RES_DIALOG_NAME;
     hInstance = 0;
     szDLLName = ISUSER;
     //szDialog = "";
     hwndParent = 0;
     nResult  = DefineDialog (szDialogName, hInstance, szDLLName,
                             hInstance, RES_DIALOG_NAME, 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;
    repeat
         nCmdValue = WaitOnDialog(szDialogName);
         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:
              CtrlSetText(szDialogName,RES_DIALOG_EdtServer,szServer);
              CtrlSetText(szDialogName,RES_DIALOG_EdtDatabase,szDatabase);
              CtrlSetText(szDialogName,RES_DIALOG_EdtUser,szUser);
              CtrlSetText(szDialogName,RES_DIALOG_EdtPassword,szPassword);
              CtrlSetText(szDialogName,RES_DIALOG_EdtPassword2,szPassword);
             case RES_PBUT_CANCEL:
                 Do (EXIT);
             case RES_PBUT_BACK:
                 bDone = TRUE;
                 nResult = 12;
             case RES_PBUT_NEXT:
              CtrlGetText(szDialogName,RES_DIALOG_EdtServer,szServer);
              CtrlGetText(szDialogName,RES_DIALOG_EdtDatabase,szDatabase);
              CtrlGetText(szDialogName,RES_DIALOG_EdtUser,szUser);
              CtrlGetText(szDialogName,RES_DIALOG_EdtPassword,szPassword);
              CtrlGetText(szDialogName,RES_DIALOG_EdtPassword2,szTmp);
              
              if(szTmp==szPassword)then              
               bDone = SQLConnectParam_TestParam(szServer,szDatabase,szUser,szPassword);
              else 
               MessageBox(@IDS__SQLConnect_ConfirPassword,SEVERE);
              endif;
              nResult = 1;                                         
         endswitch;
         CtrlGetText(szDialogName,RES_DIALOG_EdtServer,szS);
         CtrlGetText(szDialogName,RES_DIALOG_EdtDatabase,szD);
         CtrlGetText(szDialogName,RES_DIALOG_EdtUser,szU);
         EnableControl(szDialogName,RES_PBUT_NEXT,szS!="" && szU!="" && szD!="" );        
     until bDone;
     EndDialog (szDialogName);
     ReleaseDialog (szDialogName);
     return nResult;
 end;
#endif 
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值