cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
peterbi
Level 7

AskOptions() issue

Hi,

Our QA reported that some of our InstallShield (InstallScript project) dialogs don't respond to the clicking of 'X' button on the up right corner. The issue is that when the buttton is clicked, it should prompt for error/warning messages, but actually nothing happened.

The dialogs are customized from InstallShield AskOptions(). I accept the fix of either prompting message, or simply disable the button(?), but I don't know how. Can anybody give some help?


Thank,
Yabing
Labels (1)
0 Kudos
(7) Replies
RobertDickau
Flexera Alumni

As a sanity check, does your InstallScript custom dialog box code handle the case IDCANCEL or DLG_CLOSE in the WaitOnDialog loop?
0 Kudos
peterbi
Level 7

Robert,

This is an installscript project and I am calling the built-in (InstallShield 2009) AskOptions() function, do I need to handle a specific return in the custom code? I think InstallShield's AskOptions() already does so, here is the copy of the AskOptions() code (C:\program files\InstallShield\2009\Script\Isrt\src):

//////////////////////////////////////////////////////////////////////////////////////////
//
// File Name: AskOptionsDlg.rul
//
// Description: This file contains the InstallShield script for the AskOptions
// dialog function.
//
/////////////////////////////////////////////////////////////////////////////////////////

#include "Dialogs.h"
#include "ISRTDefs.h"
#include "Silent.h"
#include "Sdint.h"
#include "Str.h"
#include "CustomDlg.h"
#include "Winapi.h"
#include "Misc.h"
#include "DialogsPriv.h"
#include "Sdrc.h"

// private constants
#define DLG_ASKOPTIONS "AskOptions"
#define DLG_ASKOPTIONS_ID 10105
#define FIRST_BUTTON_ID 601
#define STATIC_TEXT_ID 901

// private globals
NUMBER nDlgAskOptions;

function AskOptions(nValue, szMsg, Options)
NUMBER nOptions, nVal, i, nSel, nId, nStyle;
STRING szDontCare, szSel;
BOOL bDone, bChecked;
HWND hDlg, hItem;
begin
nOptions = SizeOf(Options);

if ((nOptions % 2) != 0) then
return ISERR_GEN_FAILURE;
endif;

nOptions = nOptions / 2;

if (nOptions = 0) then
return ISERR_GEN_FAILURE;
endif;

if (MODE = SILENTMODE) then
SdMakeName(szAppKey, DLG_ASKOPTIONS, "", nDlgAskOptions);
SilentReadData(szAppKey, "Result", DATA_NUMBER, szDontCare, nVal);

if (nVal = NEXT) then
for i = 0 to (nOptions - 1)
Sprintf(szSel, "Sel-%ld", i);
SilentReadData(szAppKey, szSel, DATA_NUMBER, szDontCare, nSel);
Options((2 * i) + 1) = nSel;
endfor;
endif;

return nVal;
endif;

// ensure general initialization is complete
if (!bSdInit) then
SdInit();
endif;

if (EzDefineDialog(DLG_ASKOPTIONS, "", "", DLG_ASKOPTIONS_ID) = DLG_ERR) then
return ISERR_GEN_FAILURE;
endif;

// Loop in dialog until the user selects a standard button
bDone = FALSE;

while (!bDone)
nId = WaitOnDialog(DLG_ASKOPTIONS);

switch (nId)
case DLG_INIT:
hDlg = CmdGetHwndDlg(DLG_ASKOPTIONS);

i = nOptions;
hItem = GetDlgItem(hDlg, FIRST_BUTTON_ID + i);

while (hItem)
ShowWindow(hItem, SW_HIDE);
i = i + 1;
hItem = GetDlgItem(hDlg, FIRST_BUTTON_ID + i);
endwhile;

for i = 0 to (nOptions - 1)
SetWindowText(GetDlgItem(hDlg, FIRST_BUTTON_ID + i), Options(2 * i));
endfor;

if (nValue = EXCLUSIVE) then
bChecked = FALSE;

for i = 0 to (nOptions - 1)
hItem = GetDlgItem(hDlg, FIRST_BUTTON_ID + i);
nStyle = WS_CHILD | WS_VISIBLE | BS_AUTORADIOBUTTON;

if (i = 0) then
nStyle = nStyle | (WS_TABSTOP | WS_GROUP);
endif;

SetWindowLong(hItem, GWL_STYLE, nStyle);
SetWindowPos(hItem, NULL, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER | SWP_FRAMECHANGED);
InvalidateRect(hItem, NULL, TRUE);

if (bChecked = FALSE) then
if (Options((2 * i) + 1) = TRUE) then
SendMessage(hItem, BM_SETCHECK, TRUE, 0);
SetFocus(hItem);
bChecked = TRUE;
endif;
endif;
endfor;
else
for i = 0 to (nOptions - 1)
hItem = GetDlgItem(hDlg, FIRST_BUTTON_ID + i);
SetWindowText(hItem, Options(2 * i));
SendMessage(hItem, BM_SETCHECK, Options((2 * i) + 1), 0);
endfor;
endif;

if (szMsg != "") then
SetWindowText(GetDlgItem(hDlg, STATIC_TEXT_ID), szMsg);
endif;

SdGeneralInit(DLG_ASKOPTIONS, hDlg, 0, szSdProduct);

SdSetDlgTitle(DLG_ASKOPTIONS, hDlg, GetDialogTitle(DLG_ASK_OPTIONS));

case SD_PBUT_CONTINUE:
for i = 0 to (nOptions - 1)
Options((2 * i) + 1) = SendMessage(GetDlgItem(hDlg, FIRST_BUTTON_ID + i), BM_GETCHECK, 0, 0);
endfor;

nId = NEXT;
bDone = TRUE;

case SD_PBUT_BACK:
nId = BACK;
bDone = TRUE;

case DLG_ERR:
nId = ISERR_GEN_FAILURE;
bDone = TRUE;
SdError(nId, DLG_ASKOPTIONS);

case DLG_CLOSE:
SdCloseDlg(hDlg, nId, bDone);

default:
// check standard handling
if (SdIsStdButton(nId) && SdDoStdButton(nId)) then
bDone = TRUE;
endif;

endswitch;
endwhile;

EndDialog(DLG_ASKOPTIONS);
ReleaseDialog(DLG_ASKOPTIONS);

if (MODE = RECORDMODE) then
SdMakeName(szAppKey, DLG_ASKOPTIONS, "", nDlgAskOptions);
SilentWriteData(szAppKey, "Result", DATA_NUMBER, "", nId);

if (nId = NEXT) then
for i = 0 to (nOptions - 1)
Sprintf(szSel, "Sel-%ld", i);
SilentWriteData(szAppKey, szSel, DATA_NUMBER, "", Options((2 * i) + 1));
endfor;
endif;

endif;

return nId;
end;


The dialog ID is 10105. I don't know what else I should check, SdCloseDlg() is working since clicking 'X' button on other dialogs (e.g. SdLicense2(), which should result in DLG_CLOSE and the call to SdCloseDlg()) triggered an exit setup warning message. Only dialogs created by AskOptions() have the problem.


Thanks,
Peter
0 Kudos
peterbi
Level 7

Robert,

This is an installscript project and I am calling the built-in (InstallShield 2009) AskOptions() function, do I need to handle a specific return in the custom code? I think InstallShield's AskOptions() already does so, here is the copy of the AskOptions() code (C:\program files\InstallShield\2009\Script\Isrt\src):

//////////////////////////////////////////////////////////////////////////////////////////
//
// File Name: AskOptionsDlg.rul
//
// Description: This file contains the InstallShield script for the AskOptions
// dialog function.
//
/////////////////////////////////////////////////////////////////////////////////////////

#include "Dialogs.h"
#include "ISRTDefs.h"
#include "Silent.h"
#include "Sdint.h"
#include "Str.h"
#include "CustomDlg.h"
#include "Winapi.h"
#include "Misc.h"
#include "DialogsPriv.h"
#include "Sdrc.h"

// private constants
#define DLG_ASKOPTIONS "AskOptions"
#define DLG_ASKOPTIONS_ID 10105
#define FIRST_BUTTON_ID 601
#define STATIC_TEXT_ID 901

// private globals
NUMBER nDlgAskOptions;

function AskOptions(nValue, szMsg, Options)
NUMBER nOptions, nVal, i, nSel, nId, nStyle;
STRING szDontCare, szSel;
BOOL bDone, bChecked;
HWND hDlg, hItem;
begin
nOptions = SizeOf(Options);

if ((nOptions % 2) != 0) then
return ISERR_GEN_FAILURE;
endif;

nOptions = nOptions / 2;

if (nOptions = 0) then
return ISERR_GEN_FAILURE;
endif;

if (MODE = SILENTMODE) then
SdMakeName(szAppKey, DLG_ASKOPTIONS, "", nDlgAskOptions);
SilentReadData(szAppKey, "Result", DATA_NUMBER, szDontCare, nVal);

if (nVal = NEXT) then
for i = 0 to (nOptions - 1)
Sprintf(szSel, "Sel-%ld", i);
SilentReadData(szAppKey, szSel, DATA_NUMBER, szDontCare, nSel);
Options((2 * i) + 1) = nSel;
endfor;
endif;

return nVal;
endif;

// ensure general initialization is complete
if (!bSdInit) then
SdInit();
endif;

if (EzDefineDialog(DLG_ASKOPTIONS, "", "", DLG_ASKOPTIONS_ID) = DLG_ERR) then
return ISERR_GEN_FAILURE;
endif;

// Loop in dialog until the user selects a standard button
bDone = FALSE;

while (!bDone)
nId = WaitOnDialog(DLG_ASKOPTIONS);

switch (nId)
case DLG_INIT:
hDlg = CmdGetHwndDlg(DLG_ASKOPTIONS);

i = nOptions;
hItem = GetDlgItem(hDlg, FIRST_BUTTON_ID + i);

while (hItem)
ShowWindow(hItem, SW_HIDE);
i = i + 1;
hItem = GetDlgItem(hDlg, FIRST_BUTTON_ID + i);
endwhile;

for i = 0 to (nOptions - 1)
SetWindowText(GetDlgItem(hDlg, FIRST_BUTTON_ID + i), Options(2 * i));
endfor;

if (nValue = EXCLUSIVE) then
bChecked = FALSE;

for i = 0 to (nOptions - 1)
hItem = GetDlgItem(hDlg, FIRST_BUTTON_ID + i);
nStyle = WS_CHILD | WS_VISIBLE | BS_AUTORADIOBUTTON;

if (i = 0) then
nStyle = nStyle | (WS_TABSTOP | WS_GROUP);
endif;

SetWindowLong(hItem, GWL_STYLE, nStyle);
SetWindowPos(hItem, NULL, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER | SWP_FRAMECHANGED);
InvalidateRect(hItem, NULL, TRUE);

if (bChecked = FALSE) then
if (Options((2 * i) + 1) = TRUE) then
SendMessage(hItem, BM_SETCHECK, TRUE, 0);
SetFocus(hItem);
bChecked = TRUE;
endif;
endif;
endfor;
else
for i = 0 to (nOptions - 1)
hItem = GetDlgItem(hDlg, FIRST_BUTTON_ID + i);
SetWindowText(hItem, Options(2 * i));
SendMessage(hItem, BM_SETCHECK, Options((2 * i) + 1), 0);
endfor;
endif;

if (szMsg != "") then
SetWindowText(GetDlgItem(hDlg, STATIC_TEXT_ID), szMsg);
endif;

SdGeneralInit(DLG_ASKOPTIONS, hDlg, 0, szSdProduct);

SdSetDlgTitle(DLG_ASKOPTIONS, hDlg, GetDialogTitle(DLG_ASK_OPTIONS));

case SD_PBUT_CONTINUE:
for i = 0 to (nOptions - 1)
Options((2 * i) + 1) = SendMessage(GetDlgItem(hDlg, FIRST_BUTTON_ID + i), BM_GETCHECK, 0, 0);
endfor;

nId = NEXT;
bDone = TRUE;

case SD_PBUT_BACK:
nId = BACK;
bDone = TRUE;

case DLG_ERR:
nId = ISERR_GEN_FAILURE;
bDone = TRUE;
SdError(nId, DLG_ASKOPTIONS);

case DLG_CLOSE:
SdCloseDlg(hDlg, nId, bDone);

default:
// check standard handling
if (SdIsStdButton(nId) && SdDoStdButton(nId)) then
bDone = TRUE;
endif;

endswitch;
endwhile;

EndDialog(DLG_ASKOPTIONS);
ReleaseDialog(DLG_ASKOPTIONS);

if (MODE = RECORDMODE) then
SdMakeName(szAppKey, DLG_ASKOPTIONS, "", nDlgAskOptions);
SilentWriteData(szAppKey, "Result", DATA_NUMBER, "", nId);

if (nId = NEXT) then
for i = 0 to (nOptions - 1)
Sprintf(szSel, "Sel-%ld", i);
SilentWriteData(szAppKey, szSel, DATA_NUMBER, "", Options((2 * i) + 1));
endfor;
endif;

endif;

return nId;
end;


The dialog ID is 10105. I don't know what else I should check, SdCloseDlg() is working since clicking 'X' button on other dialogs (e.g. SdLicense2(), which should result in DLG_CLOSE and the call to SdCloseDlg()) triggered an exit setup warning message. Only dialogs created by AskOptions() have the problem.


Thanks,
Peter
0 Kudos
RobertDickau
Flexera Alumni

That's odd; in a pure InstallScript project, in a test script here, a call to the built-in AskOptions dialog box closes when I click the X close button.

(As a last resort, www.installsite.org > InstallScript Samples > User Interface has a script for disabling the close button.)
0 Kudos
peterbi
Level 7

Will the .rc file help to narrow down the issue? I created an empty InstallScript project to compare with the existing project on AskOptions dialog.

Here is the 10105 dialog (AskOptinos) info in _ISUser1033.rc files from the two projects:

1) empty project -

10105 DIALOGEX 0,0,332,218
STYLE DS_SETFONT | DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
CAPTION "InstallShield Wizard"

FONT 8,"MS Sans Serif",0,0,0x1
BEGIN
LTEXT "",52,0,0,332,36,,NOT WS_GROUP
LTEXT "@10550,10551;1;0;;0,128,128 ",1200,0,0,332,36,0,WS_EX_TRANSPARENT
LTEXT "Select the features you want to install, and deselect the features you do not want to install. Click Next to continue.",901,16,40,293,16,ES_AUTOHSCROLL | SS_NOPREFIX
CONTROL "Option1",601,"Button",BS_AUTOCHECKBOX | WS_TABSTOP | WS_GROUP,16,65,152,12
CONTROL "Option2",602,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,16,80,152,12
CONTROL "Option3",603,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,16,95,152,12
CONTROL "Option4",604,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,16,110,152,12
CONTROL "Option5",605,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,16,126,152,12
CONTROL "Option6",606,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,170,65,144,12
CONTROL "Option7",607,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,170,80,144,12
CONTROL "Option8",608,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,170,95,144,12
CONTROL "Option9",609,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,170,110,144,12
PUSHBUTTON "< &Back",12,166,196,50,14,WS_GROUP
DEFPUSHBUTTON "&Next >",1,215,196,50,14
PUSHBUTTON "Cancel",9,272,196,50,14
CONTROL "",1300,"Static",SS_BLACKFRAME | WS_GROUP,42,186,288,1
LTEXT "",7,2,182,40,10,NOT WS_VISIBLE
LTEXT "Select the setup type that best suits your needs.",51,16,15,213,19,ES_AUTOHSCROLL | SS_NOPREFIX,WS_EX_TRANSPARENT
LTEXT "Setup Type",50,10,3,220,8,0,WS_EX_TRANSPARENT
CONTROL "",1301,"Static",SS_ETCHEDHORZ | WS_GROUP,0,36,332,1
PUSHBUTTON "C",2,164,225,50,14,NOT WS_TABSTOP | NOT WS_VISIBLE | WS_GROUP
END


2) existing project (with the issue on the dialog)
10105 DIALOGEX 0,0,332,218
STYLE DS_SETFONT | DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
CAPTION "InstallShield Wizard"

FONT 8,"MS Sans Serif",0,0,0x1
BEGIN
LTEXT "@10550,10551;1;0;;0,128,128 ",1200,0,0,332,36,0,WS_EX_TRANSPARENT
LTEXT "Select the features you want to install, and deselect the features you do not want to install. Click Next to continue.",901,16,40,293,32,ES_AUTOHSCROLL | SS_NOPREFIX
CONTROL "Option1",601,"Button",BS_AUTOCHECKBOX | WS_TABSTOP | WS_GROUP,16,81,152,12
CONTROL "Option2",602,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,16,96,152,12
CONTROL "Option3",603,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,16,111,152,12
CONTROL "Option4",604,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,16,126,152,12
CONTROL "Option5",605,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,16,142,152,12
CONTROL "Option6",606,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,170,81,144,12
CONTROL "Option7",607,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,170,96,144,12
CONTROL "Option8",608,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,170,111,144,12
CONTROL "Option9",609,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,170,126,144,12
PUSHBUTTON "< &Back",12,166,196,50,14,WS_GROUP
DEFPUSHBUTTON "&Next >",1,215,196,50,14
PUSHBUTTON "Cancel",9,272,196,50,14
CONTROL "",1300,"Static",SS_BLACKFRAME | WS_GROUP,42,186,288,1
LTEXT "",7,2,182,40,10,NOT WS_VISIBLE
LTEXT "Select the setup type that best suits your needs.",51,16,15,213,19,ES_AUTOHSCROLL | SS_NOPREFIX,WS_EX_TRANSPARENT
LTEXT "Setup Type",50,10,3,220,8,0,WS_EX_TRANSPARENT
CONTROL "",1301,"Static",SS_ETCHEDHORZ | WS_GROUP,0,36,332,1
LTEXT "",52,0,0,332,36,,NOT WS_GROUP
END


I am not familiar with .rc files and maybe some of you guys can figure something out?


Thanks,
Peter
0 Kudos
RobertDickau
Flexera Alumni

One difference appears to be this entry:

PUSHBUTTON "C",2,164,225,50,14,NOT WS_TABSTOP | NOT WS_VISIBLE | WS_GROUP

and perhaps this button was lost along the way? Does the Cancel button work on the one dialog even though the X close button does not?
0 Kudos
peterbi
Level 7

The line can't be forced to the .rc file - it's deleted during build.

Disabling 'X' button on AskOptionsDlg() is acceptable to us too. But I haven't figured out how to integrate your code to the existing project yet. I prefer to add it to my own project, instead of the IS200x source (eg. C:\Program Files\InstallShield\2009\Script\Isrt\src) modules, since that change will require a tedious process including CM group.

If you can simply point out how to integrate, it will be great.

Here is how we use AskOptions() in the project code:

nResult = AskOptions(EXCLUSIVE,@_DLS_FEATURETREE_WKSTN_MSG,
@_DLS_SETUPTYPE_WKSTN_ESTIMATOR,bEstimator,
@_DLS_SETUPTYPE_WKSTN_COORDINATOR,bCoordinator);



Thanks,
Peter
0 Kudos