First up you create a window or dialog with CreateWindow() Ex() ect.
Messages are sent from the OS (Windows) to your app. You recieve them with a loop like
Code:
while(GetMessage(&msg, NULL , 0, 0)) //get all messages associated with the current thread
{
TranslateMessage(&msg) ;
DispatchMessage(&msg) ;
}
Send them to a callback (one for a dialog in most cases)
A callback has a complicated (nested) switch statement.
Code:
switch (message)
{
case WM_CREATE:
//do stuff when window created
break;
case WM_DESTROY:
//do stuff when window closed
break:
case WM_COMMAND:
//a control has been pressed, get its ID number and switch that
idControl=GET_WM_COMMAND_ID(wParam,lParam) ;
switch(idControl)
{
case IDM_FILE:
//user has presses menu item 'File'
//do stuff for 'file'
break;
//ect
}//end of command switch
default:
//any message you do not want to process, let windows do default stuff with it
DefWindowProc(hWnd, message, wParam, lParam);
break;
}//end of message switch
All contols / dialogs have an ID number (an int index for the control) and a HWND (handle to the window). These data types are info on how to comunicate with the control. All controls are considered children of the dialog they are on. All dialogs are considered children of the main window.