For correct work of the program using objects(internal elements), dialogs or screens, it is necessary to process messages.
In main user program there should be a reference to the procedure processing of all messages from objects, dialogs, screens.
GPTERM.StartMESSAGEMAP(INITSUB, EndSUB, DELAYSUB, UNKNOWN)
* INITSUB - function of initialization
* ENDSUB - function, called at end of work of procedure STARTMESSAGEMAP
* DELAYSUB - function ofdelay processing
* UNKNOWN - function of processing of the unrecognized input (pressing of a key
of events which is not processed by object)
CAll GPTERM.StartMESSAGEMAP ("MY.INITDIALOG", "MY.EndMP", "MY.DELAYMP", "MY.UNKNOWNMP")
SUB MY.DELAYMP
CRT(3,3): "Simple system.Current time":OCONV(TIME(),"MTHS")
RETURN
SUB MY.EndMP(CH)
INCLUDE GPTERM.COMMON
CAll GP.MENUREMOVEALL
EXECUTE"CLS"
MPStartEnd=0
RETURN
SUB MY.UNKNOWNMP(CH)
INCLUDE GPTERM.COMMON
CRT(3,5):" the Unidentified sequence -#":CH:"#"
RETURN
At creation of object the user should take care of processing of messages of object. In procedure of initialization should take care of addition of processable messages of each created object.
SUB MY.INITDIALOG()
/* creation of dialog
CAll GP.CreateDlg(1,0,"STYLE=WS_VISIBLE; RECT=200,100,615,435;
TEXT=Caption of dialog;", RET)
CAll GP.ADDDlgMESSAGE(1, "OnClose", "MY.DIALOGSREMAP")
/* creation of object "button 1"
CAll GP.DlgCreateOBJ(1,1, "BUTTON", " SIZING=0, ENEN; STYLE=WS_VISIBLE;
ENABLE=TRUE; TEXT=button 1; RECT=279,7,400,30")< BR> CAll GP.DlgObjAddMessage(1,1,
"OnCLICKED", "MY.DIALOGSREMAP")
/* creation of object " the button 2 "
CAll GP.DlgCreateOBJ(1,2, "BUTTON", " SIZING=0, ENEN; STYLE=WS_VISIBLE;
ENABLE=TRUE; TEXT=button 2; RECT=279,35,400,58")< BR> CAll GP.DlgObjAddMessage(1,2,
"OnCLICKED", "MY.DIALOGSREMAP")
RETURN
ProcedureSTARTMESSAGEMAP starts processing of events and working in an operating time. Procedure MY.INITDIALOG creates dialog in which two buttons are created. Procedures GP.ADDDLGMESSAGE, GP.DlgObjAddMessage add in a messages map event which are necessary for processing. "OnClose" for dialog and "ONCLICKED" for "button 1" and "button 2". This messages should process events procedure MY.DIALOGSREMAP.
If during work of the program there is some Event. Managements of processing it is transferred to procedure MY.DIALOGSREMAP. If Event was not identified, processing of such Event is transferred to procedure MY.UNKNOWNMP. PROBA.ENDMP finishes processing a map of messages.During work of procedure GPTERM.STARTMESSAGEMAP the data array in which each event added by procedure such as ADDMESSAGE is described is formed. When there was some event the terminal forms a dynamic array(CH) which contains Description of event in the following format:
On a double click by mouse on a line of the list(object LISTBOX) forms the following array:
| CH<1> | OpenFile | |
| CH<2> | ListFiles | |
| CH<3> | 51 | |
| CH<4> | 1 | |
| CH<5> | 5 | |
| CH<6> | OnDblClicked | |
| CH<7> | AJ.TERM.VERSION | the current line of the list |
| CH<8> | 15 | an index of the current line in the list |
| CH<9> | GetLocale() | value of the codepage |
| CH<10> | GetItemData(Sel) | |
| CH<11> | 0] 240] 234] 256 | coordinates of the rectangular - cursor on the current line of the list(coordinates enter the name as subvalues attribute |
For event of other object the contents of attributes with 7-th and further can differ.
Procedure GPTERM.REMAPINGMESSAGEMAP processes the given dynamic array and by results of processing processing user procedure (for example MY.DIALOGREMAP), or procedure of processing of unknown input MY.UNKNOWNMP.
| Bits | Value | Description |
| 0 | 1 | to work |
| 1 | 1 | to print the message after processing |
| 2 | 1 | to print the message before processing |
CALL GPTERM.SendPICKEvent(TYPE, IDSCRDlg, IDObject, EVENT, PARAM)
| Parameter | Description | ||||||||||||||
| TYPE |
type of event
|
||||||||||||||
| IDSCRDlg | the identifier of the screen(or windows) | ||||||||||||||
| IDObject | the identifier of object | ||||||||||||||
| EVENT | the name of event | ||||||||||||||
| PARAM | parameters of event(at processing event are formed, since 7-th Attribute) |
3.To execute processing event
GPTERM.PostPICKEventTYPE, IDSCRDlg, IDObject, EVENT, PARAM)
4.To suspend messaging from the client on the server.
GPTERM.PauseEvents
5.To restore messaging from the client on the server.
GPTERM.ReleaseEvents