domingo, 31 de marzo de 2013

Win32


Create a window: DirectX API doesn't have the functionality to make windows, that's the reason why we need to use an external GUI libreary to handle the window and additionally the user input. In this case we are going to use Win32 API, which is included in almost all windows platforms.

In your Visual C++  go to File -> New -> Project. And then select "Win32 Project". Give it a name, and click "Ok". Click on "Next" and check the "Empty" box.


int WINAPI WinMain( HINSTANCE hInstance, HINSTANCE prevInstance, PSTR pScmdline, int iCmdshow )
{
}

That is the main(){} for windows applications. Each argument from the WinMain is needed for running correctly.

Inside the WinMain we have important things to keep in mind:
1. hInstance (HINSTANCE): An instance for the application, needed for window creation. 
2. WndProc function: It handles the messages for the window (input)
3. wc (WNDCLASSEX): Is the class for the window. It has some settings to be defined. For example, application name, icon, cursor, and so on.
4. hWnd (HWND): It stores the window. The window is created with the function 
CreateWindowEx( arguments... ) 

The functions with Ex at the end are the new Win32 fuctions.
For example CreateWindow( arguments... ) is a depredicated window creation fuction. In modern cases we use CreateWindowEx( arguments... ).

No hay comentarios:

Publicar un comentario