Indigo Rose Software

Professional Software Development Tools

 
+ Reply to Thread
Results 1 to 2 of 2
  1. #1
    Join Date
    May 2008
    Location
    Slovakia, Bratislava
    Posts
    16

    Fill dynamically combobox within LUA script

    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.

  2. #2
    Join Date
    Jun 2000
    Location
    Indigo Rose Software
    Posts
    1,943
    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:

    Code:
    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.
    Last edited by Mark; 05-15-2008 at 08:42 AM.
    MSI Factory The Next Generation Intelligent Setup Builder

Similar Threads

  1. Lua script action is not executed via DoAction on button click
    By psulek in forum MSI Factory 2.0 Discussion
    Replies: 8
    Last Post: 05-14-2008, 09:35 AM
  2. Assign value to global property within lua script
    By psulek in forum MSI Factory 2.0 Discussion
    Replies: 1
    Last Post: 05-13-2008, 02:36 AM
  3. Building pages from script
    By Roboblue in forum AutoPlay Media Studio 7.5
    Replies: 23
    Last Post: 02-28-2008, 10:31 AM
  4. Fill ComboBox
    By bobbie in forum AutoPlay Media Studio 6.0
    Replies: 24
    Last Post: 03-04-2006, 03:34 PM
  5. How can I know the FS Command name of a movie???
    By yoske in forum AutoPlay Media Studio 5.0
    Replies: 27
    Last Post: 01-01-2005, 10:39 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts