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

Set Dialog Title

Project Type: InstallShield MSI

I'd like to create a single "error dialog" and change the text and title whenever the error dialog gets instantiated, reusing the same dialog. I have everything working as expected except I can't seem to figure out how to change the title of the dialog programmatically. I have a generic title set in the dialogs direct editor screen but I'd like to be able to programmatically set the title to match the error being shown. SetDialogTitle won't work as I'm not using one of the pre-defined dialog types but a dialog created from scratch. Is there any way to set the title each time the dialog is created?
Labels (1)
0 Kudos
(10) Replies
RobertDickau
Flexera Alumni

Depending how it was created, set IFX_SETUP_TITLE to the title you want?
0 Kudos
honolua
Level 7

I tried setting IFX_SETUP_TITLE just before creating the dialog and just after creating it with DefineDialog. I still get the title defined in the direct editor table.
0 Kudos
RobertDickau
Flexera Alumni

Could you post an outline of the custom dialog code, including any initialization?
0 Kudos
honolua
Level 7

Below are both of my relevant functions and a sample calling. I've left in the most recent attempt at setting IFX_SETUP_TITLE. I've also tried setting it in the DLG_INIT code to no avail.


function NUMBER spsDialogCreate( szDialogName, nResourceId )
BOOL bDone;
HWND hInstance, hParent;
NUMBER nResult;
STRING szDialog, szDllName;
begin
hInstance = 0;
szDllName = "";
szDialog = "";
hParent = 0;
nResult = DefineDialog( szDialogName, hInstance, szDllName,
nResourceId, szDialog, hParent,
HWND_INSTALL, DLG_MSG_STANDARD|DLG_CENTERED );
if ( nResult < 0 ) then
MessageBox( "Error in defining dialog", SEVERE);
abort;
endif;

return nResult;
end;


function spsDisplayError( szText )
BOOL bDone;
NUMBER nResult;
STRING szDialogName;
begin
IFX_SETUP_TITLE = "foo";

szDialogName = "dlgError";
nResult = spsDialogCreate( szDialogName, RES_DLG_ERROR );

bDone = FALSE;
while ( !bDone )
nResult = WaitOnDialog( szDialogName );
if ( nResult == DLG_INIT ) then
CtrlSetText( szDialogName, RES_TEXT_ERROR_TEXT, szText );
elseif ( nResult == RES_BTN_ERROR_OK || nResult == DLG_CLOSE ) then
bDone = TRUE;
elseif ( nResult == DLG_ERR ) then
MessageBox( "Unable to display dialog. Setup canceled.", SEVERE );
abort;
endif;
endwhile;

EndDialog( szDialogName );
ReleaseDialog( szDialogName );
end;



spsDisplayError( szText );
0 Kudos
RobertDickau
Flexera Alumni

Perhaps try calling SdInit( ); near the beginning of your custom dialog function and then set IFX_SETUP_TITLE; in a quick test, that seemed to make the dialog pay attention...
0 Kudos
honolua
Level 7

I've tried SdInit() in several locations inside of both spsCreateDialog and spsDisplayError. In every case, the IFX_SETUP_TITLE was set after the call to SdInit(). None has produced a change in the dialog's title. Could you show the sample code from your test that worked?
0 Kudos
RobertDickau
Flexera Alumni

Sloppy and condensed, but this seemed to work:
#include "ifx.h"

// dialog nickname and also name in Dialogs view
#define DLGNAME "TestDlg"

prototype ShowMyDlg( );

function ShowMyDlg( )
begin
SdInit( );
IFX_SETUP_TITLE = "Changed Dialog Title";
EzDefineDialog(DLGNAME, ISUSER, DLGNAME, 0);
while(TRUE)
switch(WaitOnDialog(DLGNAME))
case 9: Do(EXIT); // Cancel, that is
endswitch;
endwhile;
EndDialog(DLGNAME); ReleaseDialog(DLGNAME);
end;


Later, in OnFirstUIBefore after SdWelcome:
IFX_SETUP_TITLE = "Unchanged Dialog Title";
// display custom dialog
ShowMyDlg( );


After which the changed IFX_SETUP_TITLE seems to show up:
0 Kudos
honolua
Level 7

I just tried this sequence with the exception that my dialog is created with DefineDialog instead of EzDefineDialog. Perhaps therein lies the problem.
0 Kudos
RobertDickau
Flexera Alumni

Hmmm, replacing my EzDefineDialog call with this---
DefineDialog(DLGNAME, 0, ISUSER,
0, DLGNAME, 0,
HWND_INSTALL, DLG_MSG_STANDARD|DLG_CENTERED);
---seems to work, too...
0 Kudos
honolua
Level 7

When I replace my nResourceId with 0, as you have done, I get a DLG_ERR condition and the dialog is not displayed. I guess I'll just leave it as a generic "Error!" title and not worry about it. I hope your insights can help someone else get this working for them.

Thanks for the time and effort.
0 Kudos