The main message loop for an MDI application is similar to a normal message loop, except that the MDI application uses the TranslateMDISysAccel function to translate child-window accelerator keys.
The System-menu accelerator keys for an MDI child window are similar to those in a normal window's System menu. The difference is that child-window accelerator keys respond to the CTRL key rather than the ALT (Menu) key.
A typical MDI application's message loop looks like this:
while (GetMessage(&msg, NULL, 0, 0)) {
if (!TranslateMDISysAccel(hwndMDIClient, &msg)
&& !TranslateAccelerator(hwndFrame, hAccel, &msg)) {
TranslateMessage(&msg);
DispatchMessage(&msg);
}
}
This loop is similar to a normal message loop that handles accelerator keys. The difference is that the MDI message loop calls TranslateMDISysAccel before checking for application-defined accelerator keys or dispatching the message as usual.
The TranslateMDISysAccel function translates WM_KEYDOWN messages into WM_SYSCOMMAND messages to the active MDI child window. The function returns FALSE if the message is not an MDI accelerator message; in that case, the application uses the TranslateAccelerator function to determine whether any of the application-defined accelerator keys were pressed. If not, the loop dispatches the message to the appropriate window procedure.