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
Send them to a callback (one for a dialog in most cases)
while(GetMessage(&msg, NULL , 0, 0)) //get all messages associated with the current thread
A callback has a complicated (nested) switch statement.
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.
//do stuff when window created
//do stuff when window closed
//a control has been pressed, get its ID number and switch that
//user has presses menu item 'File'
//do stuff for 'file'
}//end of command switch
//any message you do not want to process, let windows do default stuff with it
DefWindowProc(hWnd, message, wParam, lParam);
}//end of message switch