PDA

View Full Version : Controlling title and message in custom dialogs



orthodev
08-06-2004, 12:23 PM
I've customized SdAskPathDest to incorporate an edit field, instead of just displaying the path name passed to the dialog, so that the user can change the path by either using the Browse button or directly typing in a path.

(I could have used SdShowDlgEdit1 which has the edit field, but it doesn't have the Browse functionality -- too bad there isn't a standard dialog that has both!)

When I just invoked the SdAskDestPath function, I could manipulate the title and message fields by passing the strings I wanted to the function, but then I couldn't get the information back from the edit field.

Now, I'm in the process of writing a function to display the customized dialog and retrieve whatever information is typed into the edit field by the user. However, I don't see a way to control the title and message of the dialog via this function. Is there a way do to that?

Thanks!

Ingreyd
08-13-2004, 03:27 PM
This is a routine I wrote for a modified dialog box, In this routine I read the data that is passed into the Text Boxes on the dialog.

function NUMBER DLGSQLServer(szTitle, szMsg)

NUMBER nResult, nDlgResult;
BOOL bDone;
STRING sServer, sUser, sPassword, sDatabase;
LIST lstDatabases;
NUMBER hwndDlg;
begin

EzDefineDialog("TDSQLServer", ISUSER, "TDSQLServer", 0); //Define the custom dialog.

lstDatabases = ListCreate ( STRINGLIST );

while (!bDone)

nDlgResult = WaitOnDialog("TDSQLServer");

switch (nDlgResult)
case DLG_CLOSE:
// The user clicked the window's close button.
bDone = TRUE;
EndDialog ( "TDSQLServer" );
ReleaseDialog ( "TDSQLServer" );

case DLG_INIT: //Setup the Dialog
nResult = CtrlSetText( "TDSQLServer", 1306, "NAS-DINGR" );
nResult = CtrlSetText( "TDSQLServer", 1307, "SA" );
nResult = CtrlSetText( "TDSQLServer", 1308, "" );
nResult = CtrlSetText( "TDSQLServer", 50, szTitle );
nResult = CtrlSetText( "TDSQLServer", 51, szMsg );
#define EM_SETPASSWORDCHAR 0x00CC
#define PASSWORD_CHAR 42 /* character code for asterisk */
hwndDlg = CmdGetHwndDlg ("TDSQLServer");

SendMessage(
_WinSubGetChildWindow(hwndDlg, 1308),
EM_SETPASSWORDCHAR, PASSWORD_CHAR, 0);


case 1: //Next Button

CtrlGetText ( "TDSQLServer", 1306, SQLSERVER );
CtrlGetText ( "TDSQLServer", 1307, SQLUSER );
CtrlGetText ( "TDSQLServer", 1308, SQLPASSWORD );
CtrlGetCurSel ("TDSQLServer", 1309, SQLDATABASE);

if SQLDATABASE != "" then
bDone = TRUE;
EndDialog ( "TDSQLServer" );
ReleaseDialog ( "TDSQLServer" );
return NEXT;
else
MessageBox("You must select a database", INFORMATION);
endif;

case 9: //Cancel Button
nResult = AskYesNo("Are you sure you wish to cancel the setup?",YES);
if nResult = YES then
bDone = TRUE;
EndDialog ( "TDSQLServer" );
ReleaseDialog ( "TDSQLServer" );
abort;
endif;

case 12: //Back Button
bDone = TRUE;
EndDialog ( "TDSQLServer" );
ReleaseDialog ( "TDSQLServer" );
return BACK;

case 1315: //Connect Button Pressed
CtrlGetText ( "TDSQLServer", 1306, sServer );
CtrlGetText ( "TDSQLServer", 1307, sUser );
CtrlGetText ( "TDSQLServer", 1308, sPassword );

lstDatabases = GetSQLDatabases(sServer, sUser, sPassword);
nResult = CtrlSetList( "TDSQLServer", 1309, lstDatabases );
CtrlSetCurSel ( "TDSQLServer", 1309, "MASTER" );
endswitch;

endwhile;

end;

orthodev
08-14-2004, 06:01 PM
Thanks very much for this most helpful example! CtrlGetText is the key to the puzzle.