PDA

View Full Version : dynamic check box



floflo
11-13-2003, 09:58 AM
Hi,
I'm new to devstudio so I hope someone could help me.
I need to retreive the adresse a pop server for all e mail account in outlook or mozilla in the window's registery has I have make an anti-spam software and would like to automaticaly configure it during installation.
I would like to make check box so users could choose whitch account to auto-configure.

My problem is that I get an array with all the account's name but the askoption need string variable. I can't use string as I don't know how many account a user have.

I have try to make a custom dialog box but don't find a way to dynamically draw check box.

Can someone help me please :) i don't any other idea.Thanks a lot in advance

DevinEllingson
11-13-2003, 07:14 PM
floflo,

Unfortunately, currently we don't have a dialog that takes an array, it's not very elegant, but here is some sample code to accomplish what you are trying to do:



// Included header files ----------------------------------------------------
#include "ifx.h"

prototype _AskOptionsArray( byval number, byval string, byref variant, byval variant );

BOOL bArray( 4 );
string szArray( 4 );
string szResult;

program

// Initialize sample array.
szArray( 0 ) = "Option 0";
szArray( 1 ) = "Option 1";
szArray( 2 ) = "Option 2";
szArray( 3 ) = "Option 3";
bArray( 1 ) = TRUE;
bArray( 3 ) = TRUE;

_AskOptionsArray( NONEXCLUSIVE, "", bArray, szArray );

// Show the results.
Sprintf( szResult, "%ld%ld%ld%ld", bArray( 0 ), bArray( 1 ), bArray( 2 ), bArray( 3 ) );
MessageBox( szResult, INFORMATION );

endprogram

function _AskOptionsArray( nValue, szMsg, bArray, szArray )
BOOL b0, b1, b2, b3, b4, b5, b6, b7;
string sz0, sz1, sz2, sz3, sz4, sz5, sz6, sz7;
int iSize, iCurrent;
begin

// Get the size of the array.
iSize = SizeOf( bArray );

// Populate variables.
iCurrent = 0;
while( iCurrent < iSize )

if( iCurrent = 0 ) then b0 = bArray( 0 ); sz0 = szArray( 0 ); endif;
if( iCurrent = 1 ) then b1 = bArray( 1 ); sz1 = szArray( 1 ); endif;
if( iCurrent = 2 ) then b2 = bArray( 2 ); sz2 = szArray( 2 ); endif;
if( iCurrent = 3 ) then b3 = bArray( 3 ); sz3 = szArray( 3 ); endif;
if( iCurrent = 4 ) then b4 = bArray( 4 ); sz4 = szArray( 4 ); endif;
if( iCurrent = 5 ) then b5 = bArray( 5 ); sz5 = szArray( 5 ); endif;
if( iCurrent = 6 ) then b6 = bArray( 6 ); sz6 = szArray( 6 ); endif;
if( iCurrent = 7 ) then b7 = bArray( 7 ); sz7 = szArray( 7 ); endif;

iCurrent++;

endwhile;

// Show the appropriate dialog.
if( iSize = 1 ) then AskOptions( nValue, szMsg, sz0, b0 ); endif;
if( iSize = 2 ) then AskOptions( nValue, szMsg, sz0, b0, sz1, b1 ); endif;
if( iSize = 3 ) then AskOptions( nValue, szMsg, sz0, b0, sz1, b1, sz2, b2 ); endif;
if( iSize = 4 ) then AskOptions( nValue, szMsg, sz0, b0, sz1, b1, sz2, b2, sz3, b3 ); endif;
if( iSize = 5 ) then AskOptions( nValue, szMsg, sz0, b0, sz1, b1, sz2, b2, sz3, b3, sz4, b4 ); endif;
if( iSize = 6 ) then AskOptions( nValue, szMsg, sz0, b0, sz1, b1, sz2, b2, sz3, b3, sz4, b4, sz5, b5 ); endif;
if( iSize = 7 ) then AskOptions( nValue, szMsg, sz0, b0, sz1, b1, sz2, b2, sz3, b3, sz4, b4, sz5, b5, sz6, b6 ); endif;
if( iSize = 8 ) then AskOptions( nValue, szMsg, sz0, b0, sz1, b1, sz2, b2, sz3, b3, sz4, b4, sz5, b5, sz6, b6, sz7, b7 ); endif;

// Get the results.
iCurrent = 0;
while( iCurrent < iSize )

if( iCurrent = 0 ) then bArray( 0 ) = b0; endif;
if( iCurrent = 1 ) then bArray( 1 ) = b1; endif;
if( iCurrent = 2 ) then bArray( 2 ) = b2; endif;
if( iCurrent = 3 ) then bArray( 3 ) = b3; endif;
if( iCurrent = 4 ) then bArray( 4 ) = b4; endif;
if( iCurrent = 5 ) then bArray( 5 ) = b5; endif;
if( iCurrent = 6 ) then bArray( 6 ) = b6; endif;
if( iCurrent = 7 ) then bArray( 7 ) = b7; endif;

iCurrent++;

endwhile;

end;


Devin Ellingson
InstallShield Software Corporation

floflo
11-14-2003, 08:30 AM
ok thanks hope there is no one with more then seven mail account :)
By the way, is there some drawing function's including in installscript like a small window's GDI? As I could only draw check box inside a dialog.
thanks for tips It will help me.

DevinEllingson
11-15-2003, 05:38 AM
floflo,

You could use SdAskOptionsList if you wanted, this would allow you to show any # of options (this would actually be more efficient, let me know if you need an example.)

Also we don't have any API's for drawing checkboxes via. script, typically in the AskOptions style dialog you would just add controls to the dialog for the maximum # of options and then show/hide controls depending on the # of options available. (This is how the dialog works internally.)

Devin Ellingson
InstallShield Software Corporation