This website uses cookies. By clicking Accept, you consent to the use of cookies. Click Here to learn more about how we use cookies.
Turn on suggestions
Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.
- Revenera Community
- :
- InstallShield
- :
- InstallShield Forum
- :
- Select File Dialog Box
Subscribe
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Subscribe
- Mute
- Printer Friendly Page
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎Oct 03, 2007
12:44 AM
Select File Dialog Box
I am working on InstallscriptMSI project in Install Shiled 2008. There is an inbuilt dialog for selecting a folder by using "SelectDir". But i haven't seen any dialog for selecting a file. Is there any inbuilt dialog for selecting a file? If not then what are the alternatives for it?
Thanks
Thanks
(3) Replies
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎Apr 03, 2008
04:29 AM
I am having the exact same problem.
Please post, if you have any ideas
Thanks.
Please post, if you have any ideas
Thanks.
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎Apr 03, 2008
08:33 AM
I think there are examples you can use at www.installsite.org > InstallScript Samples > User Interface, as well as MSI custom action-based versions for Basic MSI projects.
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎Apr 03, 2008
08:35 AM
There is no built-in function that let you select a file, the solution is to author a new dialog box for this.
I just want to point out that you should create custom skin prior to making any custom dialogs, because they will not be skinned if you try to apply it later.
This is how I did this:
1. Create a new dialog in the Dialogs editor, and in addition to the Back, next and cancel buttons, add a Browse button and a edit field. Assign unique Control identifiers to these (see script defines below).
2. Create a new .rul file for the dialog ( e.g. "SdAskFile.rul").
SdAskFile.rul
3. Create a Dll to control the FileBrowse dialog fired by the Browse button. I found this to be easier than to start mucking around in installscript to set up the required structure tha needs to be passed to the Common Controls API.
C++ Source code for this dll function:
4. Put the dll in your SUPPORTDIR so that it can be used from the SdAskFile.rul.
Hope this helps you guys out!
I just want to point out that you should create custom skin prior to making any custom dialogs, because they will not be skinned if you try to apply it later.
This is how I did this:
1. Create a new dialog in the Dialogs editor, and in addition to the Back, next and cancel buttons, add a Browse button and a edit field. Assign unique Control identifiers to these (see script defines below).
2. Create a new .rul file for the dialog ( e.g. "SdAskFile.rul").
SdAskFile.rul
#define BUTTON_NEXT 1
#define BUTTON_BACK 12
#define BUTTON_CANCELAR 9
#define BUTTON_BROWSE 199
#define EDIT_FILENAME 213
#define TEXT_TITLE 50
#define TEXT_SUBTITLE 51
#define TEXT_MESSAGE 1305
#define SD_DIALOG_ID 1600
prototype STDCALL BOOL MyCustomDll.FileBrowseDialog( BYREF STRING, INT );
prototype NUMBER SdAskFile( STRING, STRING, BYREF STRING );
function NUMBER SdAskFile( szTitle, szMsg, svFile )
NUMBER nControl, nReturn;
BOOL bDone;
STRING svPath[260];
begin
bDone = FALSE;
nReturn = EzDefineDialog( "SdAskFile", ISUSER, "", SD_DIALOG_ID );
if ( nReturn != 0)then
if ( nReturn == DLG_ERR_ALREADY_EXISTS ) then
MessageBox("Error defining custom dialog box \"SdAskFile\", it already exists.", WARNING);
else
MessageBox("Error defining custom dialog box \"SdAskFile\"", WARNING);
return nReturn;
endif;
endif;
while (!bDone)
nControl = WaitOnDialog("SdAskFile");
switch (nControl)
case DLG_ERR:
MessageBox("Error occured while displaying a dialogbox", WARNING );
Do(EXIT);
case DLG_INIT:
// Set up the dialog if needed..
CtrlSetText( "SdAskFile", TEXT_MESSAGE, szMsg );
CtrlSetText( "SdAskFile", EDIT_FILENAME, svFile );
CtrlSetText( "SdAskFile", TEXT_TITLE, szTitle );
bDone = FALSE;
case BUTTON_BACK:
// user clicked Back
nReturn = BUTTON_BACK;
bDone = TRUE;
case BUTTON_NEXT:
// user clicked Next
nReturn = BUTTON_NEXT;
bDone = TRUE;
case BUTTON_BROWSE:
// Browse button clicked, browse for file with GetOpenFileName API
UseDLL( SUPPORTDIR ^ "MyCustomDll.dll" );
CtrlGetText( "SdAskFile", EDIT_FILENAME, svPath );
DBConnector.FileBrowseDialog( svPath, 260 );
UnUseDLL("MyCustomDll.dll");
// Update the control that displays the filename.
CtrlSetText("SdAskFile", EDIT_FILENAME, svPath);
case BUTTON_CANCELAR:
// user clicked Cancel; ask user to verify cancellation
Do(EXIT);
endswitch;
endwhile;
//The edit field is the master 🙂
CtrlGetText( "SdAskFile", EDIT_FILENAME, svFile );
EndDialog("SdAskFile");
ReleaseDialog("SdAskFile");
return nReturn;
end;
3. Create a Dll to control the FileBrowse dialog fired by the Browse button. I found this to be easier than to start mucking around in installscript to set up the required structure tha needs to be passed to the Common Controls API.
C++ Source code for this dll function:
#include
#include
/**
* Helper function for installshield to browse for a file.
*
* @param Buffer The preallocated buffer to put the filename in
* @param BufferLength Length of preallocated buffer
* @return ErrorCode or 0 for success
*/
int APIENTRY FileBrowseDialog( char *Buffer, int BufferLength ) {
OPENFILENAME ofn;
BOOL bRet;
// Initialize OPENFILENAME
ZeroMemory(&ofn, sizeof(ofn));
ofn.lStructSize = sizeof(ofn);
ofn.hwndOwner = NULL;
ofn.lpstrFilter = "MyFileType\0*.mft\0All\0*.*\0\0";
ofn.nFilterIndex = 1;
ofn.lpstrFile = Buffer;
ofn.nMaxFile = BufferLength;
//
// Set lpstrFile[0] to '\0' so that GetOpenFileName does not
// use the contents of szFile to initialize itself.
//
ofn.lpstrFile[0] = '\0';
ofn.lpstrFileTitle = NULL;
ofn.nMaxFileTitle = 0;
ofn.lpstrInitialDir = NULL;
ofn.Flags = OFN_PATHMUSTEXIST | OFN_FILEMUSTEXIST | OFN_HIDEREADONLY ;
bRet = GetOpenFileName( &ofn );
if ( bRet )
return 0;
else
return -1;
}
4. Put the dll in your SUPPORTDIR so that it can be used from the SdAskFile.rul.
Hope this helps you guys out!
![](/skins/images/8CE4FAD0DE6F3A6F9D0567434D2D2DAE/responsive_peak/images/icon_anonymous_message.png)