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
- :
- Re: A Custom Dialog that only allows the user to choose which hard drive to install to.
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
Aug 06, 2013
08:57 AM
A Custom Dialog that only allows the user to choose which hard drive to install to.
I needed a custom dialog that only would allow the user to choose the hard drives with which to install our products to. Currently, there is no such animal. I copied the SdAskDestPath code, and created a new function in my main script, called SdAskDestDrive. Here is the code to make it work. You need to go edit the standard SdAskDestPath. Just delete the text box where the path shows up and put in a combobox. make sure to note it's ID in the properties pane.
//---------------------------------------------------------------------------
// function NUMBER SdAskDestDrive(szTitle, szMsg, svDir, nStyle)
// Returns: NUMBER
// Desc: Custom Dialog to ask for only a drive to install product to.
//---------------------------------------------------------------------------
function NUMBER SdAskDestDrive(szTitle, szMsg, svDir, nStyle)
string szDlg, svDirLoc, szTemp, svDrive;
number nId, nTemp, nSdDialog;
HWND hwndDlg;
BOOL bDone;
LIST listDrives;
begin
szDlg = "SdAskDestDrive";
nSdDialog = SD_NDLG_ASKDESTPATH;
svDirLoc = svDir;
// record data produced by this dialog
if(MODE=SILENTMODE) then
SdMakeName( szAppKey, szDlg, szTitle, nSdAskDestPath );
SilentReadData( szAppKey, "Result", DATA_NUMBER, szTemp, nId );
if((nId != BACK) && (nId != CANCEL)) then
SilentReadData( szAppKey, "szDir", DATA_STRING, svDir, nTemp );
endif;
return nId;
endif;
// ensure general initialization is complete
if(!bSdInit) then
SdInit();
endif;
if(EzDefineDialog( szDlg, "", "", SD_NDLG_ASKDESTPATH ) = DLG_ERR) then
return -1;
endif;
// Loop in dialog until the user selects a standard button
bDone = FALSE;
while (!bDone)
nId = WaitOnDialog( szDlg );
switch (nId)
case DLG_INIT:
listDrives = ListCreate(STRINGLIST);
GetValidDrivesList(listDrives, FIXED_DRIVE, -1);
CtrlSetList(szDlg, DRIVECOMBO, listDrives);
ListGetFirstString (listDrives, svDrive);
CtrlSetCurSel(szDlg,DRIVECOMBO, svDrive);
// CtrlSetText( szDlg, 0x80000000 | SD_STA_DESTDIR, svDrive);
if(szMsg != "") then
SdSetStatic( szDlg, SD_STA_CHANGEDIRMSG, szMsg );
endif;
hwndDlg = CmdGetHwndDlg( szDlg );
SdGeneralInit( szDlg, hwndDlg, nStyle, szSdProduct );
SdSetDlgTitle(szDlg, hwndDlg, szTitle);
case SD_PBUT_CHANGEDIR:
//
// Only "create" the folder if this is not ISMSI embedded.
//
SelectDirNoLog( "", "", svDirLoc, !INSTALLSCRIPTMSIEEUI );
case SD_PBUT_CONTINUE:
svDir = sDrive;
nId = NEXT;
bDone = TRUE;
case BACK:
nId = BACK;
bDone = TRUE;
case DLG_ERR:
SdError( -1, "SdAskDestDrive" );
nId = -1;
bDone = TRUE;
case DLG_CLOSE:
SdCloseDlg( hwndDlg, nId, bDone );
default:
CtrlGetCurSel(szDlg,DRIVECOMBO, svDrive);
// CtrlSetText( szDlg, 0x80000000 | SD_STA_DESTDIR, svDrive );
// check standard handling
if(SdIsStdButton( nId ) && SdDoStdButton( nId )) then
bDone = TRUE;
endif;
endswitch;
endwhile;
// Cleanup Dialog
EndDialog( szDlg );
ReleaseDialog( szDlg );
SdUnInit();
// record data produced by this dialog
if(MODE=RECORDMODE) then
SdMakeName( szAppKey, szDlg, szTitle, nSdAskDestPath );
SilentWriteData( szAppKey, "szDir", DATA_STRING, svDir, 0 );
SilentWriteData( szAppKey, "Result", DATA_NUMBER, "", nId );
endif;
return nId;
end;
(1) Reply
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
Aug 06, 2013
09:03 AM
Remember to set the ID you got from the properties view for the combo box. Set it to some defined constant, I used DRIVECOMBO set to 1302 because that was my control ID for the combo box control.
this way the install drive is captured, then I add the standard path before setting TARGETDIR. works GREAT. I only wish they would make this a standard dialog. Giving a user the ability to install to any folder is not a good thing at all. I only allow users to install to PROGRAMFILES or PROGRAMFILES64 only using the drive specified by the user. Hence, if they choose 😧 drive, the TARGETDIR would be D:\Program Files (x86)\COMPANY for 32 bit and D:\Program Files\COMPANY for 64 bit apps.
this way the install drive is captured, then I add the standard path before setting TARGETDIR. works GREAT. I only wish they would make this a standard dialog. Giving a user the ability to install to any folder is not a good thing at all. I only allow users to install to PROGRAMFILES or PROGRAMFILES64 only using the drive specified by the user. Hence, if they choose 😧 drive, the TARGETDIR would be D:\Program Files (x86)\COMPANY for 32 bit and D:\Program Files\COMPANY for 64 bit apps.