|
|
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: }
1.1.1.2 ! root 105: hszHuge = DdeCreateStringHandle(idInst, "Huge", 0);
1.1 root 106:
107: /* Get the base window title */
108: LoadString(hInst, IDS_APPNAME, sz, sizeof(sz));
109:
110: /* Create the frame */
111: hwndFrame = CreateWindow (szFrame,
112: sz,
113: WS_OVERLAPPEDWINDOW | WS_CLIPCHILDREN,
114: CW_USEDEFAULT,
115: CW_USEDEFAULT,
116: 400,
117: 200,
118: NULL,
119: NULL,
120: hInst,
121: NULL);
122:
123: if (!hwndFrame || !hwndMDIClient)
124: return FALSE;
125:
126: /* Load main menu accelerators */
127: if (!(hAccel = LoadAccelerators (hInst, MAKEINTRESOURCE(IDCLIENT))))
128: return FALSE;
129:
130: /* Display the frame window */
131: ShowWindow (hwndFrame, nCmdShow);
132: UpdateWindow (hwndFrame);
133:
134: /*
135: * We set this hook up so that we can catch the MSGF_DDEMGR filter
136: * which is called when DDEML is in a modal loop during synchronous
137: * transaction processing.
138: */
139: lpMsgFilterProc = (FARPROC)MakeProcInstance((FARPROC)MyMsgFilterProc, hInst);
1.1.1.2 ! root 140: ghhk = SetWindowsHookEx(WH_MSGFILTER, (HOOKPROC)lpMsgFilterProc, NULL,
! 141: GetCurrentThreadId());
1.1 root 142:
143: return TRUE;
144: }
145:
146:
147:
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.