在InstallShield2009下使用ComboBox

来源:互联网 发布:java中写htnl 编辑:程序博客网 时间:2024/05/16 18:24

自定义对话框资源

运行效果

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

 

做这个实验的最大收获是知道自定义对话框怎么用了,以后可以作出很花的UI和用户交互.

有美工的配合,还可以换上好看的背景图,效果要比标准对话框好很多。

 

<2011_0812>

有人提到InstallShield下拉框只支持30个条目, 我做了实验,至少255. 只是移动条目位置时,多余30的要用键盘,而不能用鼠标(因为下拉框没有滚动条)

Installshield中 List 也没有设置下拉框风格的API , 也许研究的没有细致, 以后遇到再补充.

prototype NUMBER CustomDialog(BYREF STRING, BYREF BOOL);//BYREF 才能传出值 function NUMBER CustomDialog(strRc, bOkBtnIsPress) BOOL bQuit; NUMBER nRc; NUMBER nControl;NUMBER nComboBoxID;//自定义的下拉框IDSTRING strDlgName;//自定义的对话框名称            STRING strOption;/**< 选项 */            STRING strTmp;NUMBER i;   NUMBER iPortMax;NUMBER iRc;LIST listPara; begin //上次不知道怎么使用自定义对话框, 这次突然明白了    //按钮的定义好象只能是500~900, 忘了在哪看到的了    //而且这个按钮不能用添加对话框时给的,必须要是自己手工加上的    #define nID_MYOK 500//自己定义的确定按钮的ID    nComboBoxID = 1302;//我们自己定义的下拉列表框ID是1302    strDlgName = "LsCustomDialog";//我们自定义的对话框名称    nRc = EzDefineDialog(strDlgName, ISUSER, strDlgName, 0);    bQuit = FALSE;         //create our list containing the combo box items     listPara = ListCreate(STRINGLIST);/*** 填充下拉对话框* 填充内容为 "串口xxx"* 串口的有效范围为COM1~COM1024*/             iPortMax = 1024;for i = 1 to iPortMax step 1strOption = "串口";NumToStr (strTmp, i); strOption = strOption + strTmp;iRc = ListAddString(listPara, strOption, AFTER);if(iRc < 0) then               /** 这里不曾报错, 说明添加的正确 */                       strTmp = "ListAddString failed. Port =" + strTmp;MessageBox (strTmp, INFORMATION);endif;    endfor;              iRc = ListCount(listPara);    NumToStr (strTmp, iRc);              /**    * 添加完的数量是iPortMax(1024)    * 可以用键盘来移动选择下拉框的内容,     * 不能用鼠标来拖动下拉框的滚动条    * 这种下来框没有滚动条, 看了InstallShield的帮助    * List Processing Functions 并没有设置下拉框风格的API    *     * 如果我遇到这个问题,我会调用一个c++写的EXE来完成选择, 然后把结果写到注册表或文件中    * 供安装程序进一步读取. 以前也这么干过, 毕竟InstallShield只是脚本程序, 无法完成C++那么强大细致的工作    */    MessageBox (strTmp, INFORMATION);       while(!bQuit)     nControl = WaitOnDialog(strDlgName);     switch (nControl)         case DLG_INIT:             CtrlSetList(strDlgName, nComboBoxID, listPara);                          //设置'选项3'为当前选项//方法由2种                          //1. 验证ok, 这种方法不用硬编码, 好些                                 ListSetIndex(listPara, LISTFIRST);//ListSetIndex(listPara, LISTNEXT);//ListSetIndex(listPara, LISTNEXT);            ListCurrentString(listPara, strTmp);//由ListSetIndex设置            CtrlSetCurSel(strDlgName, nComboBoxID, strTmp);//设置ComboBox当前显示                        //2. 验证ok            //CtrlSetCurSel(strDlgName, nComboBoxID, "选项3");//设置ComboBox当前显示                        bOkBtnIsPress = FALSE;        // ...cases for other controls... case nID_MYOK: //我们自己定义的按钮ID, 确定的那个按钮                bQuit = TRUE;                 bOkBtnIsPress = TRUE;    endswitch;     endwhile;     CtrlGetCurSel(strDlgName, nComboBoxID, strRc);//传出用户的选择     EndDialog(strDlgName);     ReleaseDialog(strDlgName);           ListDestroy(listPara);               return nRc; end; 
效果图: