Jump to content


This is a ready-only archive of the InstallSite Forum. You cannot post any new content here. / Dies ist ein Archiv des InstallSite Forums. Hier können keine neuen Beiträge veröffentlicht werden.
Photo

Add and remove items to ListBox


4 replies to this topic

Kiril

Kiril
  • Members
  • 39 posts

Posted 22 August 2001 - 11:19

Hi All,
I made a dialog box  with ListBox, EditBox and two buttons "Add" and "Remove". When dialog apaers ListBox is empty.I want enter text to Edit click Add and insert item in List. But CustomAction that I call from Add button doesn't work:
hDatabase = MsiGetActiveDatabase(hMSI);
sQuery = "SELECT * FROM ListBox WHERE Property='MYLIST'";
MsiDatabaseOpenView(hDatabase, sQuery, hView);
hRec=MsiCreateRecord(4);    
MsiRecordSetString(hRec, 1, "MYLIST");
MsiRecordSetInteger(hRec, 2, 1);    
MsiRecordSetString(hRec, 3, szValue);
MsiRecordSetString(hRec, 4, szValue);
MsiViewModify(hView, MSIMODIFY_INSERT_TEMPORARY, hRec);    
MsiViewClose(hView);
But this code work fine if I call it before my dialog apears. Why. May be I need refresh ListBox?
Any Idea???

Ian Blake

Ian Blake
  • Members
  • 483 posts

Posted 22 August 2001 - 13:02

I read on a newsgroup that you might be able to use the RESET event to cause the dialog to redisplay itself but I am doubtful. Let us know it is works.

If RESET does not work you need to make a near identical copy of your dialog.  Your Add button will call the NewDialog event, after adding the new entry.  to display the alternate dialog.  This will result iin the list box being re-initialised with the new data.


Kiril

Kiril
  • Members
  • 39 posts

Posted 23 August 2001 - 09:34

Hi Ian,
1).I 've tried add RESET event to Add Button. It's doesn't work. That interesting when I back to prev. dialog and step next to my  dialog ListBox contains new item.   ??????
2) In your second variant I don't  understand what should happend when user click on Add button in identical copy of dialog.
May be I need use MSIMODIFY_REFRESH or MSIMODIFY_UPDATE in MsiViewModify when I insert Items.


Ian Blake

Ian Blake
  • Members
  • 483 posts

Posted 23 August 2001 - 10:03

I didn;t think RESET would work but it was worth a try

The listbox table is being updated.  The problem is that the listbox dialog is filled on dialog creation.  Unfortuanelty there is no way to refresh the contents of the listbox object other than displaying a new dialog,

Unfortunately you can not NewDialog the same dialog because Msi knows it already has the dialog loaded so you need to make a dialog that looks the same to your users but is different to msi.

You create

MyDialog and MyDialogAlt

On your add button for MyDialog you have two events
DoAction AddToList 1
NewDialog MyDialogAlt

On your add button for MyDialogAlt you have two events
DoAction AddToList 1
NewDialog MyDialog

In this way msi needs to build a new dialog and create a new list box with the latest data.