|
|
1.1 ! root 1: /*************************************************************************** ! 2: * * ! 3: * MODULE : clinit.c * ! 4: * * ! 5: * PURPOSE : Contains initialization code for Client * ! 6: * * ! 7: ***************************************************************************/ ! 8: ! 9: #include "client.h" ! 10: ! 11: CHAR szFrame[] = "mpframe"; /* Class name for "frame" window */ ! 12: CHAR szChild[] = "mpchild"; /* Class name for MDI window */ ! 13: CHAR szList[] = "mplist"; /* Class name for MDI window */ ! 14: ! 15: /**************************************************************************** ! 16: * * ! 17: * FUNCTION : InitializeApplication () * ! 18: * * ! 19: * PURPOSE : Sets up the class data structures and does a one-time * ! 20: * initialization of the app by registering the window classes* ! 21: * Also registers the Link clipboard format * ! 22: * * ! 23: * RETURNS : TRUE - If successful. * ! 24: * FALSE - otherwise. * ! 25: * * ! 26: ****************************************************************************/ ! 27: ! 28: BOOL APIENTRY InitializeApplication() ! 29: { ! 30: WNDCLASS wc; ! 31: ! 32: fmtLink = RegisterClipboardFormat("Link"); ! 33: ! 34: if (!fmtLink) ! 35: return FALSE; ! 36: ! 37: /* Register the frame class */ ! 38: wc.style = 0; ! 39: wc.lpfnWndProc = FrameWndProc; ! 40: wc.cbClsExtra = 0; ! 41: wc.cbWndExtra = 0; ! 42: wc.hInstance = hInst; ! 43: wc.hIcon = LoadIcon(hInst,MAKEINTRESOURCE(IDCLIENT)); ! 44: wc.hCursor = LoadCursor(NULL,IDC_ARROW); ! 45: wc.hbrBackground = (HBRUSH)(COLOR_APPWORKSPACE+1); ! 46: wc.lpszMenuName = MAKEINTRESOURCE(IDCLIENT); ! 47: wc.lpszClassName = szFrame; ! 48: ! 49: if (!RegisterClass (&wc) ) ! 50: return FALSE; ! 51: ! 52: /* Register the MDI child class */ ! 53: wc.lpfnWndProc = MDIChildWndProc; ! 54: wc.hIcon = LoadIcon(hInst,MAKEINTRESOURCE(IDCONV)); ! 55: wc.lpszMenuName = NULL; ! 56: wc.cbWndExtra = CHILDCBWNDEXTRA; ! 57: wc.lpszClassName = szChild; ! 58: ! 59: if (!RegisterClass(&wc)) ! 60: return FALSE; ! 61: ! 62: wc.hIcon = LoadIcon(hInst, MAKEINTRESOURCE(IDLIST)); ! 63: wc.lpszClassName = szList; ! 64: ! 65: if (!RegisterClass(&wc)) ! 66: return FALSE; ! 67: ! 68: return TRUE; ! 69: ! 70: } ! 71: ! 72: /**************************************************************************** ! 73: * * ! 74: * FUNCTION : InitializeInstance () * ! 75: * * ! 76: * PURPOSE : Performs a per-instance initialization of Client. * ! 77: * - Enlarges message queue to handle lots of DDE messages. * ! 78: * - Initializes DDEML for this app * ! 79: * - Creates atoms for our custom formats * ! 80: * - Creates the main frame window * ! 81: * - Loads accelerator table * ! 82: * - Shows main frame window * ! 83: * * ! 84: * RETURNS : TRUE - If initialization was successful. * ! 85: * FALSE - otherwise. * ! 86: * * ! 87: ****************************************************************************/ ! 88: BOOL APIENTRY InitializeInstance( ! 89: DWORD nCmdShow) ! 90: { ! 91: extern HWND hwndMDIClient; ! 92: CHAR sz[80]; ! 93: INT i; ! 94: ! 95: if (DdeInitialize(&idInst, (PFNCALLBACK)MakeProcInstance( ! 96: (FARPROC)DdeCallback, hInst), APPCMD_CLIENTONLY, 0L)) ! 97: return FALSE; ! 98: ! 99: CCFilter.iCodePage = CP_WINANSI; ! 100: ! 101: for (i = 0; i < CFORMATS; i++) { ! 102: if (aFormats[i].fmt == 0) ! 103: aFormats[i].fmt = RegisterClipboardFormat(aFormats[i].sz); ! 104: } ! 105: ! 106: /* Get the base window title */ ! 107: LoadString(hInst, IDS_APPNAME, sz, sizeof(sz)); ! 108: ! 109: /* Create the frame */ ! 110: hwndFrame = CreateWindow (szFrame, ! 111: sz, ! 112: WS_OVERLAPPEDWINDOW | WS_CLIPCHILDREN, ! 113: CW_USEDEFAULT, ! 114: CW_USEDEFAULT, ! 115: 400, ! 116: 200, ! 117: NULL, ! 118: NULL, ! 119: hInst, ! 120: NULL); ! 121: ! 122: if (!hwndFrame || !hwndMDIClient) ! 123: return FALSE; ! 124: ! 125: /* Load main menu accelerators */ ! 126: if (!(hAccel = LoadAccelerators (hInst, MAKEINTRESOURCE(IDCLIENT)))) ! 127: return FALSE; ! 128: ! 129: /* Display the frame window */ ! 130: ShowWindow (hwndFrame, nCmdShow); ! 131: UpdateWindow (hwndFrame); ! 132: ! 133: /* ! 134: * We set this hook up so that we can catch the MSGF_DDEMGR filter ! 135: * which is called when DDEML is in a modal loop during synchronous ! 136: * transaction processing. ! 137: */ ! 138: lpMsgFilterProc = (FARPROC)MakeProcInstance((FARPROC)MyMsgFilterProc, hInst); ! 139: SetWindowsHook(WH_MSGFILTER, lpMsgFilterProc); ! 140: ! 141: return TRUE; ! 142: } ! 143: ! 144: ! 145:
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.