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