Updated with progress. Still far to go....
[reactos.git] / rosapps / regedit / main.c
1 /*
2 * ReactOS regedit
3 *
4 * main.c
5 *
6 * Copyright (C) 2002 Robert Dickenson <robd@reactos.org>
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21 */
22
23 #ifdef _MSC_VER
24 #include "stdafx.h"
25 #else
26 #define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers
27 #include <windows.h>
28 #include <commctrl.h>
29 #include <stdlib.h>
30 #include <malloc.h>
31 #include <memory.h>
32 #include <tchar.h>
33 #include <process.h>
34 #include <stdio.h>
35 #endif
36
37 #include "main.h"
38 #include "framewnd.h"
39
40 #include "treeview.h"
41 #include "listview.h"
42 #include <shellapi.h>
43 //#include <winspool.h>
44
45
46 ////////////////////////////////////////////////////////////////////////////////
47 // Global Variables:
48 HINSTANCE hInst;
49 HWND hMainWnd;
50 HWND hStatusBar;
51
52 TCHAR szTitle[MAX_LOADSTRING];
53 TCHAR szFrameClass[MAX_LOADSTRING];
54 //TCHAR szWindowClass[MAX_LOADSTRING];
55
56
57 ////////////////////////////////////////////////////////////////////////////////
58 //
59 //
60 // FUNCTION: InitInstance(HANDLE, int)
61 //
62 // PURPOSE: Saves instance handle and creates main window
63 //
64 // COMMENTS:
65 //
66 // In this function, we save the instance handle in a global variable and
67 // create and display the main program window.
68 //
69 BOOL InitInstance(HINSTANCE hInstance, int nCmdShow)
70 {
71 int nParts[3];
72 WNDCLASSEX wcex;
73
74 wcex.cbSize = sizeof(WNDCLASSEX);
75 wcex.style = CS_HREDRAW | CS_VREDRAW;
76 wcex.lpfnWndProc = (WNDPROC)FrameWndProc;
77 wcex.cbClsExtra = 0;
78 wcex.cbWndExtra = 0;
79 wcex.hInstance = hInstance;
80 wcex.hIcon = LoadIcon(hInstance, (LPCTSTR)IDI_REGEDIT);
81 wcex.hCursor = LoadCursor(NULL, IDC_ARROW);
82 wcex.hbrBackground = (HBRUSH)SS_BLACKRECT/*(COLOR_WINDOW+1)*/;
83 // wcex.lpszMenuName = (LPCSTR)IDC_REGEDIT;
84 wcex.lpszMenuName = (LPCSTR)IDR_REGEDIT_MENU;
85 wcex.lpszClassName = szFrameClass;
86 wcex.hIconSm = LoadIcon((HINSTANCE)wcex.hInstance, (LPCTSTR)IDI_SMALL);
87 RegisterClassEx(&wcex);
88
89 // Initialize the Windows Common Controls DLL
90 InitCommonControls();
91
92 hInst = hInstance; // Store instance handle in our global variable
93 hMainWnd = CreateWindow(szFrameClass, szTitle, WS_OVERLAPPEDWINDOW,
94 CW_USEDEFAULT, 0, CW_USEDEFAULT, 0, NULL, NULL, hInstance, NULL);
95 if (!hMainWnd) {
96 return FALSE;
97 }
98
99 // Get the minimum window sizes
100 // GetWindowRect(hMainWnd, &rc);
101 // nMinimumWidth = (rc.right - rc.left);
102 // nMinimumHeight = (rc.bottom - rc.top);
103
104 // Create the status bar
105 hStatusBar = CreateStatusWindow(WS_VISIBLE|WS_CHILD|WS_CLIPSIBLINGS|SBT_NOBORDERS,
106 _T(""), hMainWnd, STATUS_WINDOW);
107 if (!hStatusBar)
108 return FALSE;
109
110 // Create the status bar panes
111 nParts[0] = 100;
112 nParts[1] = 210;
113 nParts[2] = 400;
114 SendMessage(hStatusBar, SB_SETPARTS, 3, (long)nParts);
115
116 /*
117 hSplitWnd = CreateWindow(szFrameClass, "splitter window", WS_VISIBLE|WS_CHILD,
118 CW_USEDEFAULT, 0, CW_USEDEFAULT, 0,
119 hMainWnd, (HMENU)SPLIT_WINDOW, hInstance, NULL);
120 if (!hSplitWnd)
121 return FALSE;
122 */
123 ShowWindow(hMainWnd, nCmdShow);
124 UpdateWindow(hMainWnd);
125 return TRUE;
126 }
127
128 ////////////////////////////////////////////////////////////////////////////////
129
130 void ExitInstance(void)
131 {
132 // DestroyMenu(hMenuFrame);
133 }
134
135
136 int APIENTRY WinMain(HINSTANCE hInstance,
137 HINSTANCE hPrevInstance,
138 LPSTR lpCmdLine,
139 int nCmdShow)
140 {
141 MSG msg;
142 HACCEL hAccel;
143
144 // Initialize global strings
145 LoadString(hInstance, IDS_APP_TITLE, szTitle, MAX_LOADSTRING);
146 LoadString(hInstance, IDC_REGEDIT_FRAME, szFrameClass, MAX_LOADSTRING);
147 // LoadString(hInstance, IDC_REGEDIT, szWindowClass, MAX_LOADSTRING);
148
149 // Store instance handle in our global variable
150 hInst = hInstance;
151
152 // Perform application initialization:
153 if (!InitInstance(hInstance, nCmdShow)) {
154 return FALSE;
155 }
156 hAccel = LoadAccelerators(hInstance, (LPCTSTR)IDC_REGEDIT);
157
158 // Main message loop:
159 while (GetMessage(&msg, (HWND)NULL, 0, 0)) {
160 if (!TranslateAccelerator(msg.hwnd, hAccel, &msg)) {
161 TranslateMessage(&msg);
162 DispatchMessage(&msg);
163 }
164 }
165 ExitInstance();
166 return msg.wParam;
167 }