Cheat Engine Forum Index Cheat Engine
The Official Site of Cheat Engine
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 


Win32 Tutorial Part 2c- Creating Window

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming
View previous topic :: View next topic  
Author Message
Freiza
Grandmaster Cheater
Reputation: 22

Joined: 28 Jun 2010
Posts: 662

PostPosted: Thu Feb 23, 2012 2:33 am    Post subject: Win32 Tutorial Part 2c- Creating Window Reply with quote

Some theory :

In windows operating system architecture we share resources. Windows is an multitasking operating system. It can run many process concurrently.
When an event occurs windows operating system keep track of that event as message in their message Queue. And sends those messages to the running application/processes. Then application sends the message to its appropriate window.

To understand the working scenario of windows operating system. Let us take an example:

1) Suppose we have two powerpoint window running at the same time. Namely X and Y.
2) X is active and Y is inactive.
3) We press a key from the keyboard. (Windows operating system will recognize this key press as keypress event and will store it in its message queue. Since our window X is active so windows operating system will recognize and send this message to window X.

4) As we notice powerpoint have multiple area. Out of which one is main working area and many other areas. Each of these area is considered different window. Suppose keypress is designated to main working window. Powerpoint application will receive messages from operating system and again forward message to appropriate window.

Note:- Not all messages are passed this way. But in context of our tutorial this is true.

Q) So, How is messages retrieved by application from Operating system.
Ans) Through Message loops.

Code:
MSG msg = { };
   while (GetMessage(&msg, NULL, 0, 0))
   {
      TranslateMessage(&msg);
      DispatchMessage(&msg);
   }

Messages are retrieved from operating system's message queue with the help of GetMessage function.

First parameter - when message is retrieved from operating system it is stored in msg structure.

Second parameter - we pass HANDLE of the window we want the message to be processed. Suppose if there are n window in an application. and we are only
interested in retrieving message for only a particular window. then we pass HANDLE of that window here. If it is set to NULL
that means all the window in current application are eligible for receiving messages.

3rd and 4th parameter - We ignore it since it is not relevant to our beginners tutorial.

***************************************************************************



MSG Structure is an important structure it also have some important members.

typedef struct tagMSG { // msg
HWND hwnd;
UINT message;
WPARAM wParam;
LPARAM lParam;
DWORD time;
POINT pt;
} MSG;


it is documented like this is msdn.


First member contain handle to window to whom the message belongs.

second parameter - Is a unsigned integer that uniquely identifies the type of message. (for ex:- keypress message, left mouse button down message, window move message etc.)

3rd and 4th parameter gives additonal information about messages (for ex:- for mouse messages it will contain screen coordinate etc. We will discuss about it later in details.)

5th - the time when the message was posted

6th - Contains the Coordinates of the message

We will use top four messages in this tutorial.
Back to top
View user's profile Send private message Send e-mail
Display posts from previous:   
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group

CE Wiki   IRC (#CEF)   Twitter
Third party websites