/*
Dialog - When using a dialog window, points to note.
http://www.ecurb2006. com
When style is 1,
For example: CreateObject(0,MAINWINDOW,1,1,"Test",20,40,620,440,MyWin,0);
When the message processing function of the dialog window class receives GM_Close, the window will be automatically closed and destroyed.
It should be noted that the message distribution mechanism of the GUI is
First send the message to the message function of the object class,
Then send it to the message processing function of the object.
In this case, GM_Close is generated. First, send it to the object class message processing function.
Because style is 1, the window is automatically closed and the object is destroyed, and a new GM_Destroy message will be generated.
At this time, the object class message processing part ends. (The main window MAINWINDOW has the same effect as the dialog window Dialog style)
According to the message distribution mechanism, then the message processing function of the object receives GM_Close, and then receives the GM_Destroy message.
So there will be a situation where GM_Destroy message is received first, and then GM_Close message is received.
Will this cause errors? The answer is that as long as it is used correctly, there will be no problems.
If you want to receive GM_Close and then judge whether to exit the dialog window, you only need to set style to 3.
When style is 2, the message processing function of the dialog window class does not process the GM_Close message.
At this time, in the message processing function of the dialog window, you can use efDialogWin->Quit(HAND); to exit in GM_Close.
If not used, then the dialog window will not exit and will not be destroyed.
After calling efDialogWin->Quit(HAND), a GM_Destroy message will be generated.
You can modify the style value (line 76) in the following example to observe the actual operation effect and more clearly understand how to use the dialog window.
So, after starting a dialog window, GM_Create and GM_Destroy will only be generated once.
When style is 2, GM_Close may be generated multiple times (if efDialogWin->Quit(HAND); is not called to exit)
In this way, when allocating space and establishing private data, please allocate space in GM_Create and destroy (release) in GM_Destroy.
*/
#include "../gui.h"
void MyDialog(HAND hd,MESSAGE msg)
{
void *buf;
if(msg.type == GM_SYSTEM)
switch(msg.message)
{
case GM_Create:
MessageBox(hd,"GM_SYSTEM","GM_Create",0);
return;
case GM_Destroy:
MessageBox(hd,"GM_SYSTEM","GM_Destroy",0);
return;
case GM_Close:
MessageBox(hd,"GM_SYSTEM","GM_Close",0);
return;
default:
return;
}
}
void MyWin(HAND hd,MESSAGE msg)
{
if(msg.type == GM_SYSTEM)
switch(msg.message)
{
case GM_Create:
CreateObject(hd,BUTTON,1,1,"Dialog",10,50,210,75,0,0);
return;
case GM_Destroy:
return;
default:
return;
}
if(msg.type == GM_COMMAND)
switch(msg.message)
{
case 1:/* You can modify the style value below to observe the actual operation effect and more clearly understand how to use the dialog window. */
efDialogWin->Start(hd,1,1,"MyDialog",10,30,180,200,MyDialog,0);
/* efDialogWin->Start(hd,1,2,"MyDialog",10,30,180,200,MyDialog,0); */
return;
case 2:
return;
default:
return;
}
}
int gmain(void *data)
{
CreateObject(0,MAINWINDOW,1,1,"Test",20,40,620,440,MyWin,0);
return 0;
}