Hi, sometimes these two concept make me confused,
Are Event and message the same meaning ? If not ,what is the
the difference?
In OOP these two words are frequently being used. Need some explaination.
I don't know exactly...
Messages IMO are generaly received from OS and similar while events are hapening inside a program (event driven programing) or by user inervention such as mouse click.
In windows programing main message loop is in the WinMain() function and it is dispached by windows procedure.
In general msg loop or event loop is runing trough whole life of program witing for action.
maybe someone else has better gramar knoweledge about that :)
In my oppinion, I think an event just a specific type of things triggered at the certain moment, and a message is an entity contains some infomation of this type of event.
Everything that happens in a GUI system triggers an event. Most often from the keyboard or mouse. Even when the battery goes low, or the systems tick count rolls over, an event is triggered. These events are processed by the operating system and an appropriate message is generated. As an example, when the mouse is moved, its x,y coordinates and time it was moved are put into a message. These messages are continually stacked in a cue and this is where the application designed message pump or loop reads them one by one. The message number is compared against an application (programmer) designed message map, an if they match, program executes that event handler, otherwise message is discarded.
So in a technical sense, events are being triggered whether there is a loop or not, but without processing the messages, you can't even close, click or do anything with the window.
Therefor, an event driven system requires a message pump (loop) in order to determine if there is a corresponding application designed event handler.