4 * Copyright 2006 Piotr Caban
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
25 void ResizeChild(void)
27 RECT client, stat, tool;
29 MoveWindow(globals.hStatusBar, 0, 0, 0, 0, TRUE);
30 MoveWindow(globals.hToolBar, 0, 0, 0, 0, TRUE);
32 if(IsWindowVisible(globals.hStatusBar))
33 GetClientRect(globals.hStatusBar, &stat);
36 if(IsWindowVisible(globals.hToolBar))
38 GetClientRect(globals.hToolBar, &tool);
43 GetClientRect(globals.hMainWnd, &client);
44 MoveWindow(globals.hPaneWnd, 0, tool.bottom,
45 client.right, client.bottom-tool.bottom-stat.bottom, TRUE);
48 void UpdateStatusBar(int itemID)
50 WCHAR info[MAX_LOAD_STRING];
52 if(!LoadString(globals.hMainInst, itemID, info, sizeof(WCHAR[MAX_LOAD_STRING])))
53 LoadString(globals.hMainInst, IDS_READY, info, sizeof(WCHAR[MAX_LOAD_STRING]));
55 SendMessage(globals.hStatusBar, SB_SETTEXT, 0, (LPARAM)info);
58 LRESULT CALLBACK WndProc(HWND hWnd, UINT uMsg,
59 WPARAM wParam, LPARAM lParam)
65 if(!CreatePanedWindow(hWnd, &globals.hPaneWnd, globals.hMainInst))
73 UpdateStatusBar(LOWORD(wParam));
76 if(wParam == SIZE_MINIMIZED) break;
80 return DefWindowProc(hWnd, uMsg, wParam, lParam);
85 BOOL InitApplication(HINSTANCE hInst)
88 WCHAR wszAppName[MAX_LOAD_STRING];
90 LoadString(hInst, IDS_APPNAME, wszAppName, sizeof(WCHAR[MAX_LOAD_STRING]));
92 memset(&wc, 0, sizeof(WNDCLASS));
93 wc.lpfnWndProc = WndProc;
94 wc.hbrBackground = (HBRUSH)(COLOR_WINDOW+1);
95 wc.lpszMenuName = MAKEINTRESOURCE(IDM_MENU);
96 wc.lpszClassName = wszAppName;
98 if(!RegisterClass(&wc))
104 BOOL InitInstance(HINSTANCE hInst, int nCmdShow)
107 WCHAR wszAppName[MAX_LOAD_STRING];
108 WCHAR wszTitle[MAX_LOAD_STRING];
110 {0, 0, 0, BTNS_SEP, {0, 0}, 0, 0},
111 {0, IDM_BIND, TBSTATE_ENABLED, BTNS_BUTTON, {0, 0}, 0, 0},
112 {1, IDM_TYPELIB, TBSTATE_ENABLED, BTNS_BUTTON, {0, 0}, 0, 0},
113 {0, 0, 0, BTNS_SEP, {0, 0}, 0, 0},
114 {2, IDM_REGEDIT, TBSTATE_ENABLED, BTNS_BUTTON, {0, 0}, 0, 0},
115 {0, 0, 0, BTNS_SEP, {0, 0}, 0, 0},
116 {3, IDM_CREATEINST, TBSTATE_ENABLED, BTNS_BUTTON, {0, 0}, 0, 0},
117 {4, IDM_RELEASEINST, TBSTATE_ENABLED, BTNS_BUTTON, {0, 0}, 0, 0},
118 {0, 0, 0, BTNS_SEP, {0, 0}, 0, 0},
119 {5, IDM_VIEW, TBSTATE_ENABLED, BTNS_BUTTON, {0, 0}, 0, 0}
122 LoadString(hInst, IDS_APPNAME, wszAppName, sizeof(WCHAR[MAX_LOAD_STRING]));
123 LoadString(hInst, IDS_APPTITLE, wszTitle, sizeof(WCHAR[MAX_LOAD_STRING]));
125 hWnd = CreateWindow(wszAppName, wszTitle, WS_OVERLAPPEDWINDOW,
126 CW_USEDEFAULT, 0, CW_USEDEFAULT, 0, NULL, NULL, hInst, NULL);
127 if(!hWnd) return FALSE;
129 globals.hStatusBar = CreateStatusWindow(WS_VISIBLE|WS_CHILD,
130 (LPWSTR)wszTitle, hWnd, 0);
132 globals.hToolBar = CreateToolbarEx(hWnd, WS_CHILD|WS_VISIBLE, 0, 1, hInst,
133 IDB_TOOLBAR, tB, 10, 16, 16, 16, 16, sizeof(TBBUTTON));
134 SendMessage(globals.hToolBar, TB_ENABLEBUTTON, IDM_CREATEINST, FALSE);
135 SendMessage(globals.hToolBar, TB_ENABLEBUTTON, IDM_RELEASEINST, FALSE);
136 SendMessage(globals.hToolBar, TB_ENABLEBUTTON, IDM_VIEW, FALSE);
138 globals.hMainWnd = hWnd;
139 globals.hMainInst = hInst;
141 ShowWindow(hWnd, nCmdShow);
147 int APIENTRY wWinMain(HINSTANCE hInst, HINSTANCE hPrevInst,
148 LPWSTR lpCmdLine, int nCmdShow)
155 if(!InitApplication(hInst))
159 if(!InitInstance(hInst, nCmdShow))
162 hAccelTable = LoadAccelerators(hInst, MAKEINTRESOURCE(IDA_OLEVIEW));
164 while(GetMessage(&msg, NULL, 0, 0))
166 if(TranslateAccelerator(globals.hMainWnd, hAccelTable, &msg)) continue;
168 TranslateMessage(&msg);
169 DispatchMessage(&msg);