|
|
1.1 ! root 1: ! 2: /*************************************************************************** ! 3: * * ! 4: * MODULE : MpInit.c * ! 5: * * ! 6: * PURPOSE : Contains initialization code for MultiPad. * ! 7: * * ! 8: * FUNCTIONS : InitializeApplication() - Sets up Class data structure * ! 9: * and registers window class. * ! 10: * * ! 11: * InitializeInstance () - Does a per-instance initial- * ! 12: * ization of MultiPad. Creates * ! 13: * the "frame" and MDI client. * ! 14: * * ! 15: ***************************************************************************/ ! 16: #include "multipad.h" ! 17: ! 18: CHAR szFrame[] = "mpframe"; /* Class name for "frame" window */ ! 19: CHAR szChild[] = "mpchild"; /* Class name for MDI window */ ! 20: ! 21: /**************************************************************************** ! 22: * * ! 23: * FUNCTION : InitializeApplication () * ! 24: * * ! 25: * PURPOSE : Sets up the class data structures and does a one-time * ! 26: * initialization of the app by registering the window classes* ! 27: * * ! 28: * RETURNS : TRUE - If RegisterClass() was successful for both classes.* ! 29: * FALSE - otherwise. * ! 30: * * ! 31: ****************************************************************************/ ! 32: ! 33: BOOL APIENTRY InitializeApplication() ! 34: { ! 35: WNDCLASS wc; ! 36: ! 37: /* Register the frame class */ ! 38: wc.style = 0; ! 39: wc.lpfnWndProc = (WNDPROC) MPFrameWndProc; ! 40: wc.cbClsExtra = 0; ! 41: wc.cbWndExtra = 0; ! 42: wc.hInstance = hInst; ! 43: wc.hIcon = LoadIcon(hInst,IDMULTIPAD); ! 44: wc.hCursor = LoadCursor(NULL,IDC_ARROW); ! 45: wc.hbrBackground = (HBRUSH) (COLOR_APPWORKSPACE+1); ! 46: wc.lpszMenuName = IDMULTIPAD; ! 47: wc.lpszClassName = szFrame; ! 48: ! 49: if (!RegisterClass (&wc) ) ! 50: return FALSE; ! 51: ! 52: /* Register the MDI child class */ ! 53: wc.lpfnWndProc = (WNDPROC) MPMDIChildWndProc; ! 54: wc.hIcon = LoadIcon(hInst,IDNOTE); ! 55: wc.lpszMenuName = NULL; ! 56: wc.cbWndExtra = CBWNDEXTRA; ! 57: wc.lpszClassName = szChild; ! 58: ! 59: if (!RegisterClass(&wc)) ! 60: return FALSE; ! 61: ! 62: return TRUE; ! 63: ! 64: } ! 65: ! 66: /**************************************************************************** ! 67: * * ! 68: * FUNCTION : InitializeInstance () * ! 69: * * ! 70: * PURPOSE : Performs a per-instance initialization of MultiPad. It * ! 71: * also creates the frame and an MDI window. * ! 72: * * ! 73: * RETURNS : TRUE - If initialization was successful. * ! 74: * FALSE - otherwise. * ! 75: * * ! 76: ****************************************************************************/ ! 77: BOOL APIENTRY InitializeInstance(LPSTR lpCmdLine, INT nCmdShow) ! 78: { ! 79: extern HWND hwndMDIClient; ! 80: CHAR sz[80], *pCmdLine; ! 81: HDC hdc; ! 82: HMENU hmenu; ! 83: ! 84: /* Get the base window title */ ! 85: LoadString (hInst, IDS_APPNAME, sz, sizeof(sz)); ! 86: ! 87: /* Create the frame */ ! 88: hwndFrame = CreateWindow (szFrame, ! 89: sz, ! 90: WS_OVERLAPPEDWINDOW | WS_CLIPCHILDREN, ! 91: CW_USEDEFAULT, ! 92: 0, ! 93: CW_USEDEFAULT, ! 94: 0, ! 95: NULL, ! 96: NULL, ! 97: hInst, ! 98: NULL); ! 99: ! 100: if ((!hwndFrame) || (!hwndMDIClient)) ! 101: return FALSE; ! 102: ! 103: /* Load main menu accelerators */ ! 104: if (!(hAccel = LoadAccelerators (hInst, IDMULTIPAD))) ! 105: return FALSE; ! 106: ! 107: /* Display the frame window */ ! 108: ShowWindow (hwndFrame, nCmdShow); ! 109: UpdateWindow (hwndFrame); ! 110: ! 111: /* If the command line string is empty, nullify the pointer to it ! 112: ** else copy command line into our data segment ! 113: */ ! 114: if ( lpCmdLine && !(*lpCmdLine)) ! 115: pCmdLine = NULL; ! 116: else { ! 117: pCmdLine = (CHAR *) LocalAlloc(LPTR, lstrlen(lpCmdLine) + 1); ! 118: if (pCmdLine) ! 119: lstrcpy(pCmdLine, lpCmdLine); ! 120: } ! 121: ! 122: /* Add the first MDI window */ ! 123: AddFile (pCmdLine); ! 124: ! 125: /* if we allocated a buffer then free it */ ! 126: if (pCmdLine) ! 127: LocalFree((LOCALHANDLE) pCmdLine); ! 128: ! 129: /* Default to minimized windows after the first. */ ! 130: styleDefault = 0L; ! 131: ! 132: return TRUE; ! 133: UNREFERENCED_PARAMETER(hmenu); ! 134: UNREFERENCED_PARAMETER(hdc); ! 135: ! 136: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.