Common dialogs
Common dialogs
Is there a plugin available, (or a sample) that shows how to use a Common windows dialog (i.e. an open file dialog or browse for file). I want to add functionality to a form to have a browse button.
Joel Hess
Joel Hess
-
- Posts: 3452
- Joined: Thu Dec 22, 2005 7:17 pm
- Contact:
Hi Joel
While I cannot offer you anything prebuilt, I can offer you some ideas to get you started:
Just some ideas to get you going!
While I cannot offer you anything prebuilt, I can offer you some ideas to get you started:
- You can study the CD Autorun template to see how to process individual button click events in your setup script.
You can call the native Win32 API for displaying an open dialog box using the Call DLL Function command.
You can build your own dialog for browsing to a particular file using the rich set of dialog controls available - including tree, combo, and list views for navigating folders and files on the system.
Just some ideas to get you going!
Michael Nesmith
InstallAware
Home of The Next Generation MSI Installer
Get your free copy today - http://www.installaware.com/
InstallAware
Home of The Next Generation MSI Installer
Get your free copy today - http://www.installaware.com/
I opted to add the API Call to a Support DLL that we are already using, but the function is returning an LPSTR and I can't seem to get Installaware to acknowledge the response. The value of the variable that I'm assigning the result to doesn't change after it's been called.
Here's my CallDLL Function:
~InstallAware Clipboard Data~
~Call DLL Function~
~{1D47A69E-6C73-F75-AA23-835243005153}~
~$SUPPORTDIR$\\fgfinst.dll,fnOpenDialog,word,$ret1$,long,$Parm1$,long,$Parm3$,"pointer to string",$Parm2$,$~
~mIDEFunc.dll\\mEXEFunc.dll~
And just for the sake of completeness, here's my C++ function:
Here's my CallDLL Function:
~InstallAware Clipboard Data~
~Call DLL Function~
~{1D47A69E-6C73-F75-AA23-835243005153}~
~$SUPPORTDIR$\\fgfinst.dll,fnOpenDialog,word,$ret1$,long,$Parm1$,long,$Parm3$,"pointer to string",$Parm2$,$~
~mIDEFunc.dll\\mEXEFunc.dll~
And just for the sake of completeness, here's my C++ function:
Code: Select all
extern "C" LPSTR PASCAL EXPORT fnOpenDialog(HWND hWnd, LPLONG/*lplValue*/, LPSTR lpszValue )
{
//LONG nReturn;
LONG nResult;
//CString strPrinter(lpszValue);
// generate debug message
TRACE(_T("fnOpenDialog() called!\\n"));
OPENFILENAME ofn = {0};
TCHAR szFile[MAX_PATH+1] = {0};
static TCHAR *szFilter =
_T("All Files\\0*.*\\0\\0");
//
// Fill out data structure
//
ofn.Flags = OFN_HIDEREADONLY;
ofn.hInstance = GetModuleHandle( NULL );
ofn.hwndOwner = hWnd;
ofn.lpstrCustomFilter = 0;
ofn.lpstrFile = szFile;
ofn.lpstrFileTitle = 0;
ofn.lpstrFilter = szFilter;
ofn.lpstrInitialDir = 0;
ofn.lpstrTitle = _T("Browse for File");
ofn.lStructSize = sizeof( OPENFILENAME );
ofn.nMaxFile = MAX_PATH;
//
// Show dialog
//
nResult = GetOpenFileName( &ofn );
TRACE(_T("-- INFO -- fnOpenDialog() nResult(%d)\\n"), nResult);
TRACE(_T("-- INFO -- fnOpenDialog() szFile(%s)\\n"), szFile);
if( nResult == 1 )
return szFile;
else
return _T("Cancel");
}
-
- Posts: 3452
- Joined: Thu Dec 22, 2005 7:17 pm
- Contact:
Your function should not return a string. The return value should instead be an integer (-ish) value, following standard Win32 API conventions. You can pass the string value in a dedicated string buffer that is one of the function parameters. You can instruct InstallAware to allocate the memory required for this parameter in the Call DLL Function plug-in.
The problem with returning a string is that memory is allocated for it by the DLL, but never freed. Also it is not "defined" whether the host application can access this memory - given the state of the DLL, its memory contents may be ambiguous. This can cause lots of problems including stack corruption.
The problem with returning a string is that memory is allocated for it by the DLL, but never freed. Also it is not "defined" whether the host application can access this memory - given the state of the DLL, its memory contents may be ambiguous. This can cause lots of problems including stack corruption.
Michael Nesmith
InstallAware
Home of The Next Generation MSI Installer
Get your free copy today - http://www.installaware.com/
InstallAware
Home of The Next Generation MSI Installer
Get your free copy today - http://www.installaware.com/
OK, I'm getting closer.
I've changed my function to:
and my Call DLL function to:
~InstallAware Clipboard Data~
~Call DLL Function~
~{F22EA679-6E8B-4C4A-9FE0-B6384E107B0B}~
~C:\\PRNInst\\Debug\\fgfinst.dll,fnOpenDialog,void,$ret1$,long,$Handle$,"allocated string buffer (MAX_PATH length)",$Parm3$,long,$strBuffer$,$~
~mIDEFunc.dll\\mEXEFunc.dll~
But I'm not getting anything back into my variables. I can watch the Debug output from the DLL and everything appears to be working correctly.
Ideas?
I've changed my function to:
Code: Select all
extern "C" LONG PASCAL EXPORT fnOpenDialog(HWND hWnd, LPSTR lpszValue, LONG lpBuffSize )
{
//LONG nReturn;
LONG nResult;
//CString strPrinter(lpszValue);
// generate debug message
TRACE(_T("fnOpenDialog() called!\\n"));
OPENFILENAME ofn = {0};
TCHAR szFile[MAX_PATH+1] = {0};
static TCHAR *szFilter =
_T("All Files\\0*.*\\0\\0");
//
// Fill out data structuren
//
//
// Show dialog
//
nResult = GetOpenFileName( &ofn );
TRACE(_T("-- INFO -- fnOpenDialog() nResult(%d)\\n"), nResult);
TRACE(_T("-- INFO -- fnOpenDialog() szFile(%s)\\n"), szFile);
TRACE(_T("-- INFO -- fnOpenDialog() lpBuffSize(%d)\\n"), lpBuffSize);
if( nResult == 1 )
{
strncpy(lpszValue, szFile, lpBuffSize);
TRACE(_T("-- INFO -- fnOpenDialog() szValue(%s)\\n"), lpszValue);
}
return nResult;
and my Call DLL function to:
~InstallAware Clipboard Data~
~Call DLL Function~
~{F22EA679-6E8B-4C4A-9FE0-B6384E107B0B}~
~C:\\PRNInst\\Debug\\fgfinst.dll,fnOpenDialog,void,$ret1$,long,$Handle$,"allocated string buffer (MAX_PATH length)",$Parm3$,long,$strBuffer$,$~
~mIDEFunc.dll\\mEXEFunc.dll~
But I'm not getting anything back into my variables. I can watch the Debug output from the DLL and everything appears to be working correctly.
Ideas?
-
- Posts: 3452
- Joined: Thu Dec 22, 2005 7:17 pm
- Contact:
Are you initializing the variables beforehand?
Michael Nesmith
InstallAware
Home of The Next Generation MSI Installer
Get your free copy today - http://www.installaware.com/
InstallAware
Home of The Next Generation MSI Installer
Get your free copy today - http://www.installaware.com/
-
- Posts: 3452
- Joined: Thu Dec 22, 2005 7:17 pm
- Contact:
I'm not a C expert...not sure what might be going wrong. I apologize for the inconvenience.
Michael Nesmith
InstallAware
Home of The Next Generation MSI Installer
Get your free copy today - http://www.installaware.com/
InstallAware
Home of The Next Generation MSI Installer
Get your free copy today - http://www.installaware.com/
Hi,
I'm currently developing a plugin to use common dialogs (Open File Dialog, Save File Dialog and Path Selector). The IDE part is already done - the complete plugin will published tomorrow.
Hope this helps,
Markus
I'm currently developing a plugin to use common dialogs (Open File Dialog, Save File Dialog and Path Selector). The IDE part is already done - the complete plugin will published tomorrow.
Hope this helps,
Markus
Markus Diettrich
InstallAware MVP
If it can't be done with InstallAWARE then you are not using Windows
InstallAware MVP
If it can't be done with InstallAWARE then you are not using Windows
Hi,
the plugin is now available - please check out this post:
http://www.installaware.com/forum/viewtopic.php?t=503
You can download the mdPLUGINS for InstallAWARE Setup here...
cu
Markus
the plugin is now available - please check out this post:
http://www.installaware.com/forum/viewtopic.php?t=503
You can download the mdPLUGINS for InstallAWARE Setup here...
cu
Markus
Markus Diettrich
InstallAware MVP
If it can't be done with InstallAWARE then you are not using Windows
InstallAware MVP
If it can't be done with InstallAWARE then you are not using Windows
-
- Posts: 3452
- Joined: Thu Dec 22, 2005 7:17 pm
- Contact:
Many thanks for the support here, Markus!
Michael Nesmith
InstallAware
Home of The Next Generation MSI Installer
Get your free copy today - http://www.installaware.com/
InstallAware
Home of The Next Generation MSI Installer
Get your free copy today - http://www.installaware.com/
-
- Posts: 149
- Joined: Fri Oct 21, 2005 8:42 am
- Location: UK
Hi guys, I have just been using the plugin written by casic. this seems great, I do however have one issue.
How do you fire this off from a dialog in the middle of the installation?
I am trying to add a dialog that allows you to select a licese file from your system. The idea was to have a text entry field for the file name and a browse button that will open the file open dialog and enter the selected file name in the text box.
I have managed to get most of the functionality by setting the browse button to goto the next dialog, running the file open script and then returning to the original dialog, but how should I differentiate between clicking the Next button and clicking the Browse button
Cheers
How do you fire this off from a dialog in the middle of the installation?
I am trying to add a dialog that allows you to select a licese file from your system. The idea was to have a text entry field for the file name and a browse button that will open the file open dialog and enter the selected file name in the text box.
I have managed to get most of the functionality by setting the browse button to goto the next dialog, running the file open script and then returning to the original dialog, but how should I differentiate between clicking the Next button and clicking the Browse button

Cheers
-
- Posts: 149
- Joined: Fri Oct 21, 2005 8:42 am
- Location: UK
Re:
Gareth Owen wrote:Hi guys, I have just been using the plugin written by casic. this seems great, I do however have one issue.
How do you fire this off from a dialog in the middle of the installation?
I am trying to add a dialog that allows you to select a licese file from your system. The idea was to have a text entry field for the file name and a browse button that will open the file open dialog and enter the selected file name in the text box.
I have managed to get most of the functionality by setting the browse button to goto the next dialog, running the file open script and then returning to the original dialog, but how should I differentiate between clicking the Next button and clicking the Browse button![]()
Cheers
I know this is a very old thread but how did you work out differentiating between the Next and Browse button?
-
- Site Admin
- Posts: 5361
- Joined: Sun Aug 22, 2010 4:28 am
Re: Common dialogs
... just conditionally check in your script the returned value by the WIZARD pre-defined variable.
With the following example, the conditional statement is executed if the CANCEL button has been selected.
Regards
With the following example, the conditional statement is executed if the CANCEL button has been selected.
Code: Select all
if Variable WIZARD Equals CANCEL
GoTo Label: Main Install
end
Regards
Francesco Toscano
InstallAware Software
White Papers (HowTos) - http://www.installaware.com/publication ... papers.htm
Publications - http://www.installaware.com/publications-review.htm
InstallAware Help -F1 anywhere in the InstallAware IDE
InstallAware Software
White Papers (HowTos) - http://www.installaware.com/publication ... papers.htm
Publications - http://www.installaware.com/publications-review.htm
InstallAware Help -F1 anywhere in the InstallAware IDE
Who is online
Users browsing this forum: No registered users and 71 guests