This website uses cookies. By clicking Accept, you consent to the use of cookies. Click Here to learn more about how we use cookies.
Turn on suggestions
Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.
- Revenera Community
- :
- InstallShield
- :
- InstallShield Forum
- :
- list box
Subscribe
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Subscribe
- Mute
- Printer Friendly Page
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎Sep 29, 2008
06:45 AM
How to create a list ?
Hi ,
Iam new to Installshield and I want to create a list on a dialog where the values should be read from the file and populated dynamically into the List. And the user should be able to select an option from the list.
Iam new to Installshield and I want to create a list on a dialog where the values should be read from the file and populated dynamically into the List. And the user should be able to select an option from the list.
(2) Replies
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎Sep 29, 2008
09:54 AM
I assume that you have already added the list box to the desired dialog. Now you will want to create a custom action that can populate the list box from the file you describe. The following CA example assumes that you have placed a file in "Support Files" for this purpose called "items.txt".
export prototype PopulateListbox(HWND);
function PopulateListbox(hMSI)
HWND hDB, hViewlist, hRecordlist;
HWND hViewprop, hRecordprop;
NUMBER nFileHandle, nBuffer, r, nSize, nOpen;
STRING sLine, sSupport, sPropname, sPropvalue;
begin
try
//get the file path where printer values are stored
MsiGetProperty(hMSI, "SUPPORTDIR", sSupport, nSize);
// for each Property record, add PROPNAME="value" record to ListBox table
OpenFileMode (FILE_MODE_NORMAL);
nOpen = OpenFile (nFileHandle, sSupport, "items.txt");
if (nOpen = 0) then
//get the active database
hDB = MsiGetActiveDatabase(hMSI);
//open a view into the ListBox table
MsiDatabaseOpenView(hDB, "SELECT * FROM `ListBox` WHERE `Property`='MYLISTVALUES'", hViewlist);
MsiViewExecute(hViewlist, NULL);
r = 0;
while (GetLine (nFileHandle, sLine) = 0)
nBuffer = 256; // set size buffer
MsiRecordGetString(hRecordprop, 1, sLine, nBuffer);
r = r + 1;
hRecordlist = MsiCreateRecord(4);
MsiRecordSetString(hRecordlist, 1, "MyListValue");
MsiRecordSetInteger(hRecordlist, 2, r);
MsiRecordSetString(hRecordlist, 3, sLine);
MsiRecordSetString(hRecordlist, 4, sLine);
// can only temporarily modify running MSI database
MsiViewModify(hViewlist, MSIMODIFY_INSERT_TEMPORARY, hRecordlist);
endwhile;
MsiViewClose(hViewlist);
//MsiViewClose(hViewprop);
CloseFile (nFileHandle);
endif;
catch
//exception handling
endcatch;
end;
export prototype PopulateListbox(HWND);
function PopulateListbox(hMSI)
HWND hDB, hViewlist, hRecordlist;
HWND hViewprop, hRecordprop;
NUMBER nFileHandle, nBuffer, r, nSize, nOpen;
STRING sLine, sSupport, sPropname, sPropvalue;
begin
try
//get the file path where printer values are stored
MsiGetProperty(hMSI, "SUPPORTDIR", sSupport, nSize);
// for each Property record, add PROPNAME="value" record to ListBox table
OpenFileMode (FILE_MODE_NORMAL);
nOpen = OpenFile (nFileHandle, sSupport, "items.txt");
if (nOpen = 0) then
//get the active database
hDB = MsiGetActiveDatabase(hMSI);
//open a view into the ListBox table
MsiDatabaseOpenView(hDB, "SELECT * FROM `ListBox` WHERE `Property`='MYLISTVALUES'", hViewlist);
MsiViewExecute(hViewlist, NULL);
r = 0;
while (GetLine (nFileHandle, sLine) = 0)
nBuffer = 256; // set size buffer
MsiRecordGetString(hRecordprop, 1, sLine, nBuffer);
r = r + 1;
hRecordlist = MsiCreateRecord(4);
MsiRecordSetString(hRecordlist, 1, "MyListValue");
MsiRecordSetInteger(hRecordlist, 2, r);
MsiRecordSetString(hRecordlist, 3, sLine);
MsiRecordSetString(hRecordlist, 4, sLine);
// can only temporarily modify running MSI database
MsiViewModify(hViewlist, MSIMODIFY_INSERT_TEMPORARY, hRecordlist);
endwhile;
MsiViewClose(hViewlist);
//MsiViewClose(hViewprop);
CloseFile (nFileHandle);
endif;
catch
//exception handling
endcatch;
end;
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎Sep 29, 2008
10:09 AM
You didn't mention what project type you are using. Here is something you can try in Install Shield Script.
HWND hDlg;
STRING szDlg;
LIST listTemp;
NUMBER nDropDownListControl;
Begin
listTemp = ListCreate( STRINGLIST );
ListReadFromFile ( listTemp, "MyListFile.txt" );
szDlg = "MyCustomDialog"
hDlg = CmdGetHwndDlg(szDlg);
nDropDownListControl = 1200;
CtrlSetList(szDlg, nDropDownListControl, listTemp );
End;