Jump to content
Sign in to follow this  
ZNorQ

Controls - I just don't get it..

Recommended Posts

I'm trying to make a dialog, but I'm having some difficulties manipulating the controls. I've just started creating the dialog, so there is only 2 controls for now - one CT_STATIC (class name lblGMSelection) and one CT_COMBO (class name cmbGMSelection).

Question A; Why won't the control accept the changes?

They do work (shows when I'm activating the dialog), but before I activate them I try to add 2 lines of information in the combo and changing the text of the label using the following statements;

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">_lbOK = lbAdd[102, "This is a test - 1"];

_lbOK = lbAdd[102, "This is a test - 2"];

ctrlSetText[101, "The label text have been changed.."];

_dlgGM = createDialog "dlgGameMaster";

waitUntil {!dialog};

And, yes, I've made sure that the CT_STATIC's idc is 101, and CT_COMBO's idc is 102.

Question B; I get an error when I try using the alternative version of the lbAdd/ctrlSetText (introduced in ArmA)

I also tried the alternative version of the GUI functions introduced in ArmA, but I get an error there;

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">_lbOK = 102 lbAdd "This is a test -1";

_lbOK = 102 lbAdd "This is a test -2";

101 ctrlSetText "The label text have been changed..";

_dlgGM = createDialog "dlgGameMaster";

waitUntil {!dialog};

This is the error I receive..;

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">Error lbadd: Type number, expected control.

ZNorQ

Share this post


Link to post
Share on other sites

dialog.sqf (_nul=[] execvm "dialog.sqf")

if (!(createDialog "dlgGameMaster")) exitwith {hint "fatal erorr!"};

lbAdd[102, "This is a test - 1"];

lbAdd[102, "This is a test - 2"];

ctrlSetText[101, "The label text have been changed.."];

waitUntil {!dialog};

p.s. my english very bad

Share this post


Link to post
Share on other sites

Question A:

Like vova_fox said, createDialog needs to be called first.

Question B:

If it ever says 'expected control', it needs a control not an IDC number. So use:

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">_IDD_MyDialog = 999; // whatever IDD number you used in class

_display = findDisplay _IDD_MyDialog;

_IDC = 102;

_ctrl = _display displayCtrl _IDC;

_ctrl lbAdd "text";

Share this post


Link to post
Share on other sites
dialog.sqf (_nul=[] execvm "dialog.sqf")

if (!(createDialog "dlgGameMaster")) exitwith {hint "fatal erorr!"};

lbAdd[102, "This is a test - 1"];

lbAdd[102, "This is a test - 2"];

ctrlSetText[101, "The label text have been changed.."];

waitUntil {!dialog};

p.s. my english very bad

Ah, ok. I really thougth that since the dialogs are already defined in the description.ext, that you could change the attributes before creating the display.

Thanks for the feedback.

ZNorQ

Share this post


Link to post
Share on other sites
Question B:

If it ever says 'expected control', it needs a control not an IDC number. So use:

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">_IDD_MyDialog = 999; // whatever IDD number you used in class

_display = findDisplay _IDD_MyDialog;

_IDC = 102;

_ctrl = _display displayCtrl _IDC;

_ctrl lbAdd "text";

Ok, I get it. I thought that the IDD/IDC number was the same as control. Thanks for the help.

ZNorQ

Share this post


Link to post
Share on other sites

Think of it this way. The description.ext entries for dialogs (and the dialogs controls, backgrounds and objects) are just templates, they don't exist until a dialog is instantiated.

For those who aren't sure what I mean, I'll make it a little more plain:

A dialog definition in description.ext says what pieces are part of the dialog, what types of controls and the various attributes each control will have. That's it. The dialog doesn't exist or become valid until it's created using createDialog "<dialogname>". The same way a tank is described in the config file but doesn't exist until it's dropped in the editor or created on the fly with createVehicle. You can't have guys get into a tank definition, but you can once a particular type of tank has been created. Same thing.

Also: if you look at the 3rd letter of IDD and IDC it tells you what "type" of ID it is, ID"D" is a dialog ID and ID"C" is a control ID. If I understood your last question about what the IDx is; yes, the IDC is the reference number for the control.

Hope that helps someone.

Share this post


Link to post
Share on other sites
Think of it this way. The description.ext entries for dialogs (and the dialogs controls, backgrounds and objects) are just templates, they don't exist until a dialog is instantiated.

For those who aren't sure what I mean, I'll make it a little more plain:

A dialog definition in description.ext says what pieces are part of the dialog, what types of controls and the various attributes each control will have. That's it. The dialog doesn't exist or become valid until it's created using createDialog "<dialogname>". The same way a tank is described in the config file but doesn't exist until it's dropped in the editor or created on the fly with createVehicle. You can't have guys get into a tank definition, but you can once a particular type of tank has been created. Same thing.

Very informative, Quantum - thanks.

Also: if you look at the 3rd letter of IDD and IDC it tells you what "type" of ID it is, ID"D" is a dialog ID and ID"C" is a control ID.

Hehe, yeah, I understand that - did so back in the old OFP days.. smile_o.gif *Slightly insulted* tounge2.gif

If I understood your last question about what the IDx is; yes, the IDC is the reference number for the control.

(Related to question B) Thats what I though, but I think it's abit silly that you can't use constants (or basic variables) on some of those new ArmA versions of the script commands that allows you to manipulate controls. I find it abit akward that you have to create a "control handle" using first of all findDisplay to create a display handle, then displayCtrl to create control handles - and then you'll be able to use these new ArmA script commands. Wouldn't it be easier to just be able to use constants or ordinary variables? I think I'm misunderstanding some basic concept principles here, I guess.

Hope that helps someone.

Sure did, mate.

(Sorry about that slow response... Been busy with lots of things..)

ZNorQ

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

×