CreateControlParameters
name :
Controls name. You use this to modify it's properties using the built in callback. Refer to Callback information section.
text :
Text of Control. This can be the caption of a button, label, or default text in a textbox & password textbox.
type :
Refer to the ControlType enumerator defined in the CForm header. Specifies which kind of control you wish to create it as.
x :
Controls x position which is relative to the forms X position.
y :
Controls y position which is relative to the forms y position.
Command :
DWORD that specified the controls command code, read callback section for more information on this parameter.
Enabled :
Useless without CGUIManager class. More description on this paremeter will be posted at later time. For now ignore, and allow the compile set it to true, or set it to true yourself.
Description :
Creates a desired control for the form. This form will then be rendered when the render method within the class is called.
ProcessKey
Parameters
key :
Key which was pressed to be processed. '%' character will cause a deletion of the last character.
Description :Processes a given key. This can cause several actions to occur depending on the active control. It may sometimes be ignored.
CallbackParameters
Read callback section of this post for information on these parameters.
Description :Read callback section of this post for information on these parameters.
MoveBy
Parameters x :
Amount to change X coordination by.
y :
Amount to change Y coordination by.
Description :Moves forms XY coordinations by a desired amount.
MoveToParametersx :
y :
Description :Moves forms XY coordinations to a desired position.
RenderParametersd3dSprite :
Pointer to initialized sprite interface.
Description :Renders form.
UpdateIgnore, useless without CGUIManager.
Callback MethodsA callback method has three parameters, the first is generally the command or the name of an object. Here's an example callback I write that should explain everything you need to know about them.
Form Init :
[php] mainForm = new CForm(FormCallback, "Form1",0,0, "FormDatatexturesdefaultForm.PNG", pd3ddev, d3dFont);
mainForm->CreateControl("cap1", "Login Window", Caption, 5, 5, 0);
mainForm->CreateControl("cap2", "Username:", Caption, 100, 80, 0);
mainForm->CreateControl("cap3", "Password:", Caption, 100, 110, 0);
mainForm->CreateControl("txtUsername", "Insert Username", Textbox, 170, 80, 0);
mainForm->CreateControl("txtPassword", "Insert Password", Password, 170, 110, 0);
mainForm->CreateControl("btnSubmit", "Submit", Button, 230, 130, BTN_SUBMIT);
mainForm->CreateControl("btnTwo", "Quit", Button, 300, 130, BTN_QUIT);
[/php]Callback :
[php]
void FormCallback(DWORD command, DWORD p1, DWORD p2) {
if(command == CONTROL_BUTTON_PRESS) {
if(!strcmp(mainForm->name, (char*)p1)) {
switch(p2) {
case BTN_QUIT:
tinit();
break;
case BTN_SUBMIT:
break;
}
}
}
}[/php]