13.07.2015 Views

REFERENCE GUIDE

REFERENCE GUIDE

REFERENCE GUIDE

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

structures for the window and to return a unique integer value,called a window handle, that the application can use to identifythe window in subsequent function calls.The first message most windows process is WM_ CREATE, thewindow-creation message. Again, the CreateWindow functionsends this message to inform the window function that it can nowperform any initialization, such as allocating memory andpreparing data files. The wParam parameter is not used, but theIParam parameter contains a long pointer to a CREATESTRUCTdata structure, whose fields correspond to the parameters passedto CreateWindow.Both the WM_CREATE and WM_NCCREATE messages are sentdirectly to the window function, bypassing the application queue.This means an application will create a window and process theWM_CREATE message before it enters the main program loop.After a window has been created, it must be opened (displayed)before it can be used. An application can open the window in oneof two ways: it can specify the WS_ VISIBLE window style in theCreateWindow function to open the window immediately aftercreation, or it can wait until later and call the ShowWindowfunction to open the window. When creating a main window, anapplication should not specify WS_ VISIBLE, but should callShowWindow from the WinMain function with the nCmdShowparameter set to the desired value.When the window is no longer needed or the application isterminated, the window must be destroyed. This is done by usingthe DestroyWindow function. DestroyWindow removes thewindow from the system display and invalidates the windowhandle. It also sends WM_DESTROY and WM_NCDESTROYmessages to the window function.The WM_DESTROY message is usually the last message awindow function processes. This occurs when theDestroyWindow function is called or when a WM_CLOSEmessage is processed by the DefWindowProc function. When awindow function receives a WM_DESTROY message, it shouldfree any allocated memory and close any open data files.The window used as the application's main user interface shouldalways be the last window destroyed and should always causethe application to terminate. When this window receives aWM_DESTROY message, it should call the PostQuitMessagefunction. This function copies a WM_ QUIT message to theChapter 7, Window manager interface functions 41

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!