```
/*
Micro Embedded GUI - Application Development
Website: www.ecurb2006.com
Demonstrates how to create objects and use the TEXTBOX text box.
*/
#include "gui.h"
#define MyWinCommand_A 4 /* ID of the button */
#define MyWinCommand_B 5
/* Private data, can be used to save the handle of the object */
/* The handle is essentially a pointer to a structure (struct) */
typedef struct _MyWinData
{
HAND a;
HAND b;
HAND c;
}MyWinData,*PMyWinData;
/*
USER_PRO is a simple macro definition
#define USER_PRO void
Indicates that it is the object message processing function
HAND is the object handle
MEEAGE is the message structure
For more details, please refer to the Micro Embedded GUI Programming Guide (
http://www.ecurb2006.com)
*/
USER_PRO MyMainWin(HAND hd,MESSAGE msg)
{
if(msg.type == GM_SYSTEM)/* First determine the message type */
switch(msg.message)
{
case GM_Draw:/* This message is generated when the object is displayed (or redrawn)*/
{
HDC hdc; /* HDC is the graphics device handle */
PefGDITag g=efGDI;
/*
efGDI is the drawing class, one of the operation methods of the ef class,
In the entire GUI, the object classes all use this API encapsulation method, with unified and simple interface
*/
hdc=g->Start(hd);/* Start drawing */
g->SetColor(hdc,COLOR_BLACK); /* Set color */
g->DrawText(hdc,5,50,"Input a");/* Output text */
g->DrawText(hdc,5,75,"Input b");
g->DrawText(hdc,5,100,"Show");
g->End(hd,hdc); /* End drawing */
}
return;
case GM_Create: /* Message generated after the object is created, some initialization operations can be completed here */
{
PMyWinData mydata=NULL;
mydata=(PMyWinData)Gmalloc(sizeof(MyWinData),"");/* Allocate memory */
if(!mydata) return; /* return NULL */
mydata->a=CreateObject(hd,TEXTBOX,1,0,"",70,50,200,70,0,0);
mydata->b=CreateObject(hd,TEXTBOX,2,0,"",70,75,200,95,0,0);
mydata->c=CreateObject(hd,TEXTBOX,3,0,"",70,100,200,120,0,0);
CreateObject(hd,BUTTON,MyWinCommand_A,0,"Show A",10,130,90,155,0,0);
CreateObject(hd,BUTTON,MyWinCommand_B,0,"Show B",100,130,180,155,0,0);
SetObjVar(hd,(HAND)mydata);/* Set the private data pointer of the object */
}
return;
case GM_Destroy:
{
PMyWinData mydata=NULL;
mydata=(PMyWinData)GetObjVar(hd);/* Get Object Var */
Gfree(mydata,sizeof(MyWinData));
}
return;
default:return;
}
if(msg.type == GM_COMMAND)
{
char strbuf;
PMyWinData mydata=NULL;
mydata=(PMyWinData)GetObjVar(hd);/* Get the private data pointer of the object */
if(!mydata) return;
memset(strbuf,0,257);
switch(msg.message)
{
case MyWinCommand_A:
efTextBox->Text(mydata->a,strbuf);/* Get the content of the text box*/
efTextBox->Set(mydata->c,strbuf);/* Set the content of the text box */
return;
case MyWinCommand_B:
efTextBox->Text(mydata->b,strbuf);
efTextBox->Set(mydata->c,strbuf);
return;
default:return;
}
}
}
int gmain(void*data) /* Entry of the GUI application, equivalent to the main function */
{
CreateObject(0,MAINWINDOW,1,1,"Hello,World",10,10,400,400,MyMainWin,data);/* Create object */
return 0;
}
```