杉宫竹苑工作室

 找回密码
 立即注册
搜索
热搜: 活动 交友 discuz
查看: 2209|回复: 0

在 InstallShield 下使用ComboBox

[复制链接]
发表于 2017-3-1 18:38:10 | 显示全部楼层 |阅读模式

正式会员享受无限制浏览网站功能和高速网盘下载,赶快加入本站吧!

您需要 登录 才可以下载或查看,没有账号?立即注册

x

  1. prototype NUMBER CustomDialog(BYREF STRING, BYREF BOOL);//BYREF 才能传出值   
  2. function NUMBER CustomDialog(strRc, bOkBtnIsPress)   
  3.     BOOL bQuit;   
  4.     NUMBER nRc;   
  5.     NUMBER nControl;  
  6.       
  7.     NUMBER nComboBoxID;//自定义的下拉框ID  
  8.     STRING strDlgName;//自定义的对话框名称  
  9.       
  10.     STRING strTmp;  
  11.     LIST listPara;   
  12. begin   
  13.     //上次不知道怎么使用自定义对话框, 这次突然明白了  
  14.     //按钮的定义好象只能是500~900, 忘了在哪看到的了  
  15.     //而且这个按钮不能用添加对话框时给的,必须要是自己手工加上的  
  16.     #define nID_MYOK 500//自己定义的确定按钮的ID  
  17.     nComboBoxID = 1302;//我们自己定义的下拉列表框ID是1302  
  18.     strDlgName = "LsCustomDialog";//我们自定义的对话框名称  
  19.     nRc = EzDefineDialog(strDlgName, ISUSER, strDlgName, 0);  
  20.     bQuit = FALSE;   
  21.       
  22.     //create our list containing the combo box items   
  23.     listPara = ListCreate(STRINGLIST);  
  24.     //填充下拉列表框   
  25.     ListAddString(listPara, "选项1", AFTER);  
  26.     ListAddString(listPara, "选项2", AFTER);  
  27.     ListAddString(listPara, "选项3", AFTER);  
  28.     ListAddString(listPara, "选项4", AFTER);  
  29.     ListAddString(listPara, "选项5", AFTER);  
  30.     ListAddString(listPara, "选项6", AFTER);  
  31.     ListAddString(listPara, "选项7", AFTER);   
  32.      
  33.     while(!bQuit)   
  34.         nControl = WaitOnDialog(strDlgName);   
  35.         switch (nControl)   
  36.             case DLG_INIT:   
  37.                 CtrlSetList(strDlgName, nComboBoxID, listPara);  
  38.                                 
  39.                 //设置'选项3'为当前选项  
  40.                 //方法由2种                             
  41.                 //1. 验证ok, 这种方法不用硬编码, 好些                                   
  42.                 ListSetIndex(listPara, LISTFIRST);  
  43.                 ListSetIndex(listPara, LISTNEXT);  
  44.                 ListSetIndex(listPara, LISTNEXT);  
  45.       
  46.                 ListCurrentString(listPara, strTmp);//由ListSetIndex设置  
  47.                 CtrlSetCurSel(strDlgName, nComboBoxID, strTmp);//设置ComboBox当前显示  
  48.                   
  49.                 //2. 验证ok  
  50.                 //CtrlSetCurSel(strDlgName, nComboBoxID, "选项3");//设置ComboBox当前显示  
  51.                   
  52.                 bOkBtnIsPress = FALSE;  
  53.       
  54.             // ...cases for other controls...   
  55.             case nID_MYOK: //我们自己定义的按钮ID, 确定的那个按钮  
  56.                     bQuit = TRUE;   
  57.                     bOkBtnIsPress = TRUE;  
  58.         endswitch;   
  59.     endwhile;   
  60.     CtrlGetCurSel(strDlgName, nComboBoxID, strRc);//传出用户的选择   
  61.     EndDialog(strDlgName);   
  62.     ReleaseDialog(strDlgName);   
  63.             
  64.     ListDestroy(listPara);   
  65.             
  66.     return nRc;   
  67. end;   
  68. //---------------------------------------------------------------------------  
  69. // OnBegin  
  70. //  
  71. // The OnBegin event is called directly by the framework after the setup  
  72. // initializes. Note that this event will be called AFTER "Initialization"  
  73. // events (i.e.) OnSetTARGETDIR, OnCheckMediaPassword.  
  74. //  
  75. // Note: This event will not be called automatically in a  
  76. // program...endprogram style setup.  
  77. //---------------------------------------------------------------------------  
  78. function OnBegin()  
  79.     BOOL bOK;  
  80.     NUMBER nRc;        
  81.     STRING strSelect;  
  82. begin   
  83.     nRc = CustomDialog(strSelect, bOK);  
  84.     if(0 != nRc) then  
  85.         MessageBox("自定义对话框执行错误", INFORMATION | MB_OK);  
  86.         abort;  
  87.     endif;  
  88.         
  89.     if(bOK) then   
  90.         MessageBox("您的选择是:" + strSelect, INFORMATION | MB_OK);  
  91.     else                                                         
  92.         MessageBox("您取消了选择", INFORMATION | MB_OK);//这个对话框是没有取消按钮的  
  93.     endif;  
  94. end;  
复制代码

自定义对话框资源

0_128257527645C5.gif

运行效果

0_1282575315DS2q.gif

0_1282575329484S.gif

可以运行的工程的上传位置








回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

QQ|小黑屋|手机版|Archiver|SgzyStudio

GMT+8, 2024-5-19 18:42 , Processed in 0.124821 second(s), 21 queries .

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表