psulek
05-15-2008, 12:56 AM
Can you gave me an example how to populate combobox within LUA script? It is not sure how to access to controls within lua script. I know how to get/set msi property, but dont know how to access to control and controls its properties, like combobox items.
HI psulek,
Take a look at the MSI.ViewModify() example in the help it shows the basic form to use when interacting with controls.
I used that example code to come up with the following that adds an item to an existing ComboBox:
hDatabase = MSI.GetActiveDatabase(_hInstall);
if (hDatabase ~= 0) then
-- Get the ComboBox entry
strQuery = "SELECT * FROM `ComboBox`";
hView = MSI.DatabaseOpenView(hDatabase, strQuery);
if (hView ~= 0) then
bExecuteResult = MSI.ViewExecute(hView, 0);
if (bExecuteResult) then
bContinue = true;
hRecord = MSI.CreateRecord(4)
-- Property associated with combo
MSI.RecordSetString(hRecord, 1, "NEW_COMBO_PROPERTY");
-- Order
MSI.RecordSetInteger(hRecord, 2, 3);
-- Value
MSI.RecordSetString(hRecord, 3, "MyValue");
-- Text
MSI.RecordSetString(hRecord, 3, "MyText");
-- Add to the View
if (not MSI.ViewModify(hView, MSIMODIFY_INSERT_TEMPORARY, hRecord)) then
Dialog.Message("Could Not", "Modify")
end
MSI.CloseHandle(hRecord);
end
MSI.ViewClose(hView);
MSI.CloseHandle(hView);
else
hError = MSI.GetLastErrorRecord();
strError = MSI.FormatRecord(_hInstall, hError);
Dialog.Message("Error", "Error opening database view:\r\n"..strError);
MSI.CloseHandle(hError);
end
MSI.CloseHandle(hDatabase);
end
Basically what I'm doing is inserting a new record into the ComboBox table. The new record represents the new item in the ComboBox. The item that I insert is linked to the ComboBox on the dialog via the first entry in the record, the Property. This is the same property that can be found on the Settings tab of the ComboBox properties.
I tested my script by running the action during the "InstallUISequence" executing it before the "WelcomeDlg" and the item was inserted into my ComboBox.
You'll probably have to play around with the code a little bit to get it to work in your install but I'm sure once you work with it a bit you'll get it working.
vBulletin® v3.8.4, Copyright ©2000-2009, Jelsoft Enterprises Ltd.