home *** CD-ROM | disk | FTP | other *** search
- // THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
- // ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
- // THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
- // PARTICULAR PURPOSE.
- //
- // Copyright (C) 1993-1995 Microsoft Corporation. All Rights Reserved.
- //
- // MODULE: mdichild.c
- //
- // PURPOSE:
- // To implement the basic mdi child commands.
- //
- // FUNCTIONS:
- // InitMDIChild - To register the MDI child window class.
- // MDIChildWndProc - Processes messages for MDI child windows.
- // MsgMCCommand - Handle the WM_COMMAND messages for mdi children.
- //
- // COMMENTS:
- //
- //
- // SPECIAL INSTRUCTIONS: N/A
- //
-
- #include <windows.h> // required for all Windows applications
- #include <windowsx.h>
- #ifdef WIN16
- #include "win16ext.h" // required only for win16 applications
- #endif
- #include "globals.h" // prototypes specific to this application
- #include "resource.h"
-
-
- static MSD rgmsd[] =
- {
- {WM_COMMAND, MsgMCCommand},
- {WM_DESTROY, MsgMCDestroy}
- };
-
- MSDI msdiChild =
- {
- sizeof(rgmsd) / sizeof(MSD),
- rgmsd,
- edwpMDIChild
- };
-
- static CMD rgcmd[] =
- {
- {0, NULL}
- };
-
- CMDI cmdiChild =
- {
- sizeof(rgcmd) / sizeof(CMD),
- rgcmd,
- edwpMDIChild
- };
-
-
- // Module specific globals
-
- char szChildName[] = "MdiChild";
-
- //
- // FUNCTION: InitMDIChild(HINSTANCE)
- //
- // PURPOSE: To register the MDI child window class.
- //
- // PARAMETERS:
- // hinst - The instance of the application used to register the class.
- //
- // RETURN VALUE:
- // TRUE - Succeeded in registering the class.
- // FALSE - Failed to register the class.
- //
- // COMMENTS:
- //
- //
-
- BOOL InitMDIChild(HINSTANCE hinst)
- {
- #ifdef WIN16
- WNDCLASS wc;
- #else
- WNDCLASSEX wc;
- #endif
-
- #ifndef WIN16
- wc.cbSize = sizeof(WNDCLASSEX);
- wc.hIconSm = LoadImage(hinst, // Load small icon image
- MAKEINTRESOURCE(IDI_CHILDICON),
- IMAGE_ICON,
- 16, 16,
- 0);
- #endif
- wc.style = 0;
- wc.lpfnWndProc = (WNDPROC)MDIChildWndProc;
- wc.cbClsExtra = 0;
- wc.cbWndExtra = 0;
- wc.hInstance = hinst; // Owner of this class
- wc.hIcon = LoadIcon(hinst, MAKEINTRESOURCE(IDI_CHILDICON));
- wc.hCursor = LoadCursor(NULL, IDC_ARROW);
- wc.hbrBackground = (HBRUSH)(COLOR_WINDOW + 1); // Default color
- wc.lpszMenuName = NULL;
- wc.lpszClassName = szChildName;
-
- #ifdef WIN16
- if (!RegisterClass(&wc))
- {
- return FALSE;
- }
- #else
- if (!RegisterClassEx(&wc))
- {
- //Assume we are running on NT where RegisterClassEx() is
- //not implemented, so let's try calling RegisterClass().
-
- if (!RegisterClass((LPWNDCLASS)&wc.style))
- return FALSE;
- }
- #endif
-
- return TRUE;
- }
-
- //
- // FUNCTION: MDIChildWndProc(HWND, UINT, WPARAM, LPARAM)
- //
- // PURPOSE: Processes messages for MDI child windows.
- //
- // PARAMETERS:
- // hwnd - window handle
- // uMessage - message number
- // wparam - additional information (dependant of message number)
- // lparam - additional information (dependant of message number)
- //
- // RETURN VALUE:
- // Depends on the message number.
- //
- // COMMENTS:
- // Uses the combination of the message structure defined in mditable.c
- // and the DispMessage function defined in WndProc.c to handle all
- // messages directed to an MDI child window.
- //
-
- LRESULT CALLBACK MDIChildWndProc(HWND hwnd,
- UINT uMessage,
- WPARAM wparam,
- LPARAM lparam)
- {
- return DispMessage( &msdiChild, hwnd, uMessage, wparam, lparam );
- }
-
-
- //
- // FUNCTION: MsgMCCommand(HWND, UINT, WPARAM, LPARAM)
- //
- // PURPOSE: Handle the WM_COMMAND messages for mdi children.
- //
- // PARAMETERS:
- // hwnd - window handle
- // uMessage - message number (Unused)
- // GET_WM_COMMAND_ID(wparam,lparam) - Command identifier
- // GET_WM_COMMAND_HWND(wparam,lparam) - Control handle
- //
- // RETURN VALUE:
- //
- // COMMENTS:
- // Uses the combination of the command structure defined in mditable.c
- // and the DispCommand function defined in WndProc.c to handle all
- // commands directed to an MDI child window.
- //
- //
-
- #pragma argsused
- LRESULT MsgMCCommand(HWND hwnd, UINT uMessage, WPARAM wparam, LPARAM lparam)
- {
- return DispCommand(&cmdiChild, hwnd, wparam, lparam);
- }
-
-
- //
- // FUNCTION: MsgMCDestroy(HWND, UINT, WPARAM, LPARAM)
- //
- // PURPOSE:
- //
- // PARAMETERS:
- // hwnd - The window handing the message.
- // uMessage - The message number. (unused).
- // wparam - Message specific data (unused).
- // lparam - Message specific data (unused).
- //
- // RETURN VALUE:
- // Always returns 0 - message handled.
- //
- // COMMENTS:
- //
- //
-
- #pragma argsused
- LRESULT MsgMCDestroy(HWND hwnd, UINT uMessage, WPARAM wparam, LPARAM lparam)
- {
- cOpen -= 1;
-
- return 0;
- }
-
-
-