summaryrefslogtreecommitdiffstats
path: root/private/nw/convert/logview/fvinit.c
blob: 11330fb2a00d88c0b98a7f5090073a0f743cbd2f (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
/*
  +-------------------------------------------------------------------------+
  |                        Initialization Code                              |
  +-------------------------------------------------------------------------+
  |                        (c) Copyright 1993                               |
  |                          Microsoft Corp.                                |
  |                        All rights reserved                              |
  |                                                                         |
  | Program               : [mpinit.c]                                      |
  | Programmer            : Arthur Hanson                                   |
  | Original Program Date : [Jul 27, 1993                                   |
  | Last Update           : [Jul 30, 1993]  Time : 18:30                    |
  |                                                                         |
  | Version:  0.10                                                          |
  |                                                                         |
  | Description:                                                            |
  |                                                                         |
  | History:                                                                |
  |   arth  Jul 27, 1993    0.10    Original Version.                       |
  |                                                                         |
  +-------------------------------------------------------------------------+
*/
#include "LogView.h"

CHAR szFrame[] = "mpframe";   // Class name for "frame" window
CHAR szChild[] = "mpchild";   // Class name for MDI window

/*+-------------------------------------------------------------------------+
  | InitializeApplication()                                                 |
  |                                                                         |
  +-------------------------------------------------------------------------+*/
BOOL APIENTRY InitializeApplication() {
    WNDCLASS    wc;

    // Register the frame class
    wc.style         = 0;
    wc.lpfnWndProc   = (WNDPROC) MPFrameWndProc;
    wc.cbClsExtra    = 0;
    wc.cbWndExtra    = 0;
    wc.hInstance    = hInst;
    wc.hIcon         = LoadIcon(hInst,IDLOGVIEW);
    wc.hCursor       = LoadCursor(NULL,IDC_ARROW);
    wc.hbrBackground = (HBRUSH) (COLOR_APPWORKSPACE+1);
    wc.lpszMenuName  = IDLOGVIEW;
    wc.lpszClassName = szFrame;

    if (!RegisterClass (&wc) )
        return FALSE;

    // Register the MDI child class
    wc.lpfnWndProc   = (WNDPROC) MPMDIChildWndProc;
    wc.hIcon         = LoadIcon(hInst,IDNOTE);
    wc.lpszMenuName  = NULL;
    wc.cbWndExtra    = CBWNDEXTRA;
    wc.lpszClassName = szChild;

    if (!RegisterClass(&wc))
        return FALSE;

    return TRUE;

} // InitializeApplication


/*+-------------------------------------------------------------------------+
  | InitializeInstance()                                                    |
  |                                                                         |
  +-------------------------------------------------------------------------+*/
BOOL APIENTRY InitializeInstance(LPSTR lpCmdLine, INT nCmdShow) {
   extern HWND  hwndMDIClient;
   CHAR         sz[80], *pCmdLine, *pFileName, *pChar;
   HDC          hdc;
   HMENU        hmenu;

   // Get the base window title
   LoadString (hInst, IDS_APPNAME, sz, sizeof(sz));

    hStdCursor= LoadCursor( NULL,IDC_ARROW );
    hWaitCursor= LoadCursor( NULL, IDC_WAIT );

    // Create the frame
    hwndFrame = CreateWindow (szFrame, sz,  WS_OVERLAPPEDWINDOW | WS_CLIPCHILDREN,
                              CW_USEDEFAULT, 0, CW_USEDEFAULT,  0,  NULL,
                              NULL,  hInst, NULL);

    if ((!hwndFrame) || (!hwndMDIClient))
        return FALSE;

    // Load main menu accelerators
    if (!(hAccel = LoadAccelerators (hInst, IDLOGVIEW)))
        return FALSE;

    // init.fields of the FINDREPLACE struct used by FindText()
    FR.lStructSize = sizeof(FINDREPLACE);
    FR.hwndOwner = hwndFrame;
    FR.Flags = FR_DOWN | FR_HIDEWHOLEWORD;
    FR.lpstrReplaceWith   = (LPTSTR)NULL;
    FR.wReplaceWithLen = 0;
    FR.lpfnHook = NULL;

    /* determine the message number to be used for communication with
     * Find dialog
     */
    if (!(wFRMsg = RegisterWindowMessage ((LPTSTR)FINDMSGSTRING)))
         return FALSE;
    if (!(wHlpMsg = RegisterWindowMessage ((LPTSTR)HELPMSGSTRING)))
         return FALSE;

    // Display the frame window
    ShowWindow (hwndFrame, nCmdShow);
    UpdateWindow (hwndFrame);

    // If the command line string is empty, nullify the pointer to it else copy
    // command line into our data segment 
   if ( lpCmdLine && !(*lpCmdLine)) {
      pCmdLine = NULL;
             
      // Add the first MDI window 
      AddFile (pCmdLine);

   } else {
      pCmdLine = (CHAR *) LocalAlloc(LPTR, lstrlen(lpCmdLine) + 1);
      
      if (pCmdLine) {
         lstrcpy(pCmdLine, lpCmdLine);
           
         pFileName = pChar = pCmdLine;
         
         while (*pChar) {
            if (*pChar == ' ') {
               *pChar = '\0';
               AddFile(pFileName);
               *pChar = ' ';
               pChar++;
               pFileName = pChar;
            } else
               pChar++;
         }
            AddFile(pFileName);
            
      } else
         
      // Add the first MDI window
      AddFile (pCmdLine);
   }

   // if we allocated a buffer then free it
   if (pCmdLine)
      LocalFree((LOCALHANDLE) pCmdLine);

   return TRUE;
   UNREFERENCED_PARAMETER(hmenu);
   UNREFERENCED_PARAMETER(hdc);

} // InitializeInstance