//************************************************************* // File name: superini.c // // Description: // Contains initialization code for supermdi. // // History: Date Author Comment // 1/1/92 JJJ Created // // Written by Microsoft Product Support Services, Windows Developer Support // Copyright (c) 1992 Microsoft Corporation. All rights reserved. //************************************************************* #include "Global.h" //------------------------ global variables ------------------------- char szFrame[] = "Frame"; // Class name for "frame" window char szChild[] = "Child"; // Class name for MDI window char szClient[] = "NewClient"; // Class name for the new client window FARPROC lpfnOldClient=NULL; // Pointer to the old MDI client proc //************************************************************* // // InitializeApplication () // // Purpose: // Sets up the class data structures and does a one-time // initialization of the app by registering the window classes // // Parameters: // // Return: // TRUE - If RegisterClass() was successful for both classes. // FALSE - otherwise. // // Comments: // // History: Date Author Comment // 1/1/92 JJJ Created // //************************************************************* BOOL FAR PASCAL InitializeApplication() { WNDCLASS wc; // SuperClass the MDI client window. This involves getting the info // of the original class and then making the necessary modifications GetClassInfo(NULL,"mdiclient",&wc); wc.style |= CS_DBLCLKS; lpfnOldClient = (FARPROC)wc.lpfnWndProc; // Save old proc wc.lpszClassName = szClient; // Change the class name wc.hInstance = ghInst; // Change the instance so that // the class gets unregistered // when the app terminates wc.lpfnWndProc = MyNewClientProc; // Our new proc // Register the puppy if (!RegisterClass(&wc)) return (FALSE); // Register the frame class wc.style = 0; wc.lpfnWndProc = FrameWndProc; wc.cbClsExtra = 0; wc.cbWndExtra = 0; wc.hInstance = ghInst; wc.hIcon = LoadIcon(ghInst, "FrameIcon"); wc.hCursor = LoadCursor(NULL,IDC_ARROW); wc.hbrBackground = GetStockObject(LTGRAY_BRUSH); wc.lpszMenuName = "MainMenu"; wc.lpszClassName = szFrame; if (RegisterClass (&wc)) { // Register the MDI child class wc.hbrBackground = GetStockObject(WHITE_BRUSH); wc.lpfnWndProc = ChildWndProc; wc.hIcon = LoadIcon(ghInst, "ChildIcon"); wc.lpszMenuName = NULL; wc.cbWndExtra = CBWNDEXTRA; wc.lpszClassName = szChild; if (RegisterClass(&wc)) return TRUE; } return FALSE; } //************************************************************* // // InitializeInstance () // // Purpose: // Performs a initialization of supermdi. It // also creates the frame and one MDI child window. // // Parameters: // // Return: // TRUE - If initialization for all classes were successful. // FALSE - otherwise. // // Comments: // // History: Date Author Comment // 1/1/92 JJJ Created // //************************************************************* BOOL FAR PASCAL InitializeInstance(LPSTR lpCmdLine, WORD nCmdShow) { char sz[80]; LoadString (ghInst, IDS_APPNAME, sz, sizeof(sz)); // Create the frame // MDI Client window is created in frame's WM_CREATE case ghFrame = CreateWindow (szFrame,sz,WS_OVERLAPPEDWINDOW | WS_CLIPCHILDREN, CW_USEDEFAULT,0,CW_USEDEFAULT,0,NULL,NULL,ghInst,NULL); CheckMenuItem(GetMenu(ghFrame),nColor,MF_BYCOMMAND|MF_CHECKED); if (ghFrame && ghClient) { // Display the frame window ShowWindow (ghFrame, nCmdShow); UpdateWindow (ghFrame); // Make the first MDI child window MakeNewChild ("Initial Window"); return TRUE; } return FALSE; } //************************************************************* // // MakeNewChild () // // Purpose: // Makes new MDI child // // Parameters: // // Return: // HWND - A handle to the new window. // // Comments: // // History: Date Author Comment // 1/1/92 JJJ Created // //************************************************************* HWND FAR PASCAL MakeNewChild(char *pName) { HWND hwnd; char sz[160]; MDICREATESTRUCT mcs; if (!pName) { // pName parameter is NULL -- load the "Untitled" string // from STRINGTABLE LoadString (ghInst, IDS_UNTITLED, sz, sizeof(sz)); mcs.szTitle = (LPSTR)sz; } else mcs.szTitle = (LPSTR)pName; /* Fully qualified pathname*/ mcs.szClass = szChild; mcs.hOwner = ghInst; mcs.x = mcs.cx = CW_USEDEFAULT; // Use the default size for the window mcs.y = mcs.cy = CW_USEDEFAULT; mcs.style = styleDefault; // Set the style DWORD of the window to default // tell the MDI Client to create the child hwnd = (WORD)SendMessage (ghClient,WM_MDICREATE,0,(LONG)(LPMDICREATESTRUCT)&mcs); ShowWindow(hwnd, SW_SHOW); return (hwnd); }