PDA

View Full Version : Custom Dialog to select a file



Snoopstah
07-11-2007, 09:15 PM
I know this is a very broad question but I don't know where to start.

How do I create a cusom dialog box that allows me to select an individual file?

I would like it to be similar to DatabaseFolder which spawns the InstallChangeFolder dlg box. Except it needs to go one level further and allow me to select an individual file rather than just a folder.

Any help greatly appreciated.

RobertDickau
07-11-2007, 09:30 PM
Assuming you're talking about Basic MSI, there's nothing built in that shows files; for one approach, perhaps see www.installsite.org > Windows Installer > Custom Actions > File Browse Dialog. I think there are also a couple of InstallScript examples of the same kind of thing.

Snoopstah
07-11-2007, 09:34 PM
Thanks Robert, that's exactly the answer I was after. I'll convert my project to an InstallScript MSI and then work on developing the dialog.

RobertDickau
07-11-2007, 09:42 PM
I don't think I've looked at that example, but you shouldn't have to convert the project (unless you want to, of course); I imagine it's a custom action just calls the GetOpenFileName or similar API function and feeds the selection back to your MSI project...

Snoopstah
07-12-2007, 01:17 AM
I have it all working except for one small thing that is really frustrating.

My entire install is setup and working as long as the ProductName is set to "Default". The minute I change this name to reflect the actual product name, the dialog box edit text field in the dialog box does not update showing which file was selected.

I have seen a similar problem when a user selects a folder from a browse button into an edit text field. The property is correctly updated but not displayed in the edit text field on the dialog. The workaround for this is to launch a 2nd identical dialog box as the last action on the Change button.

Why is this required? How is the ProductName affecting this ???

Is this the only workaround?

RobertDickau
07-13-2007, 03:14 PM
That doesn't make any sense; is the custom action code using FindWindow to look for a window with "Default" in the caption, for example?

Snoopstah
07-15-2007, 06:57 PM
I am not 100% sure what is in the CA dll as it is from the installsite example you sent me to. I don't have the tools to view dll code. I have attached the relevant DLL.

I have had a similar issue with IS12 (although I have no idea if it was related to Default productname as I did not test that.) I create a new dialog with a simple EditText dialog box and the property set to [MYPATH]. There is a browse button that calls a browse DLL (similar to attached). The following action is to set the [MYPATH] value and the edit text field should be populated with the new value.

The property is definitely set correctly but the edit box does not display the updated value. If i click NEXT and then BACK, the edit box has bee "updated" to show the correct value.

SherylSikora
07-16-2007, 02:43 PM
I downloaded all of the source code for this dll from InstallSite and when looking at the "BrowseForFile.cpp" code, it is in fact looking for a dialog caption of "Default - InstallShield Wizard". You will need to change this and recompile the dll.

Snoopstah
07-16-2007, 05:27 PM
Ahh fabulous. Thankyou. I will pass this on to our developers who can hopefully resove the problem.

Can this be changed to an InstallShield property such as [ProductName]? Or do they need to hardcode the product name in there?

RobertDickau
07-17-2007, 08:55 AM
Calling MsiGetProperty with ProductName should do the trick.