cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Balaji_Vinu
Level 5

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.
Labels (1)
0 Kudos
(2) Replies
ITI_Randy
Level 6

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;
0 Kudos
TheTraveler
Level 8

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;
0 Kudos