2 * PROJECT: ReactOS Applications Manager
3 * LICENSE: GPL - See COPYING in the top level directory
4 * FILE: base/applications/rapps/winmain.c
5 * PURPOSE: Main program
6 * PROGRAMMERS: Dmitry Chapyshev (dmitry@reactos.org)
13 HIMAGELIST hImageTreeView
= NULL
;
14 INT SelectedEnumType
= ENUM_ALL_COMPONENTS
;
15 SETTINGS_INFO SettingsInfo
;
19 FillDefaultSettings(PSETTINGS_INFO pSettingsInfo
)
21 pSettingsInfo
->bSaveWndPos
= TRUE
;
22 pSettingsInfo
->bUpdateAtStart
= FALSE
;
23 pSettingsInfo
->bLogEnabled
= TRUE
;
24 wcscpy(pSettingsInfo
->szDownloadDir
, L
"C:\\Downloads");
25 pSettingsInfo
->bDelInstaller
= FALSE
;
27 pSettingsInfo
->Maximized
= FALSE
;
28 pSettingsInfo
->Left
= 0;
29 pSettingsInfo
->Top
= 0;
30 pSettingsInfo
->Right
= 680;
31 pSettingsInfo
->Bottom
= 450;
40 if (RegOpenKeyExW(HKEY_LOCAL_MACHINE
, L
"Software\\ReactOS\\rapps", 0, KEY_READ
, &hKey
) == ERROR_SUCCESS
)
42 dwSize
= sizeof(SETTINGS_INFO
);
43 if (RegQueryValueExW(hKey
, L
"Settings", NULL
, NULL
, (LPBYTE
)&SettingsInfo
, &dwSize
) == ERROR_SUCCESS
)
56 SaveSettings(HWND hwnd
)
61 if (SettingsInfo
.bSaveWndPos
)
63 wp
.length
= sizeof(WINDOWPLACEMENT
);
64 GetWindowPlacement(hwnd
, &wp
);
66 SettingsInfo
.Left
= wp
.rcNormalPosition
.left
;
67 SettingsInfo
.Top
= wp
.rcNormalPosition
.top
;
68 SettingsInfo
.Right
= wp
.rcNormalPosition
.right
;
69 SettingsInfo
.Bottom
= wp
.rcNormalPosition
.bottom
;
70 SettingsInfo
.Maximized
= (IsZoomed(hwnd
) || (wp
.flags
& WPF_RESTORETOMAXIMIZED
));
73 if (RegCreateKeyExW(HKEY_LOCAL_MACHINE
, L
"Software\\ReactOS\\rapps", 0, NULL
,
74 REG_OPTION_NON_VOLATILE
, KEY_WRITE
, NULL
, &hKey
, NULL
) == ERROR_SUCCESS
)
76 RegSetValueEx(hKey
, L
"Settings", 0, REG_BINARY
, (LPBYTE
)&SettingsInfo
, sizeof(SETTINGS_INFO
));
82 FreeInstalledAppList(VOID
)
84 INT Count
= ListView_GetItemCount(hListView
) - 1;
89 Info
= ListViewGetlParam(Count
);
92 RegCloseKey(Info
->hSubKey
);
93 HeapFree(GetProcessHeap(), 0, Info
);
101 EnumInstalledAppProc(INT ItemIndex
, LPWSTR lpName
, INSTALLED_INFO Info
)
103 PINSTALLED_INFO ItemInfo
;
104 WCHAR szText
[MAX_PATH
];
107 ItemInfo
= HeapAlloc(GetProcessHeap(), 0, sizeof(INSTALLED_INFO
));
108 if (!ItemInfo
) return FALSE
;
112 Index
= ListViewAddItem(ItemIndex
, 0, lpName
, (LPARAM
)ItemInfo
);
114 /* Get version info */
115 GetApplicationString((HKEY
)ItemInfo
->hSubKey
, L
"DisplayVersion", szText
);
116 ListView_SetItemText(hListView
, Index
, 1, szText
);
118 GetApplicationString((HKEY
)ItemInfo
->hSubKey
, L
"Comments", szText
);
119 ListView_SetItemText(hListView
, Index
, 2, szText
);
125 FreeAvailableAppList(VOID
)
127 INT Count
= ListView_GetItemCount(hListView
) - 1;
132 Info
= ListViewGetlParam(Count
);
134 HeapFree(GetProcessHeap(), 0, Info
);
141 EnumAvailableAppProc(APPLICATION_INFO Info
)
143 PAPPLICATION_INFO ItemInfo
;
146 /* Only add a ListView entry if...
147 - no RegName was supplied (so we cannot determine whether the application is installed or not) or
148 - a RegName was supplied and the application is not installed
150 if (!*Info
.szRegName
|| (!IsInstalledApplication(Info
.szRegName
, FALSE
) && !IsInstalledApplication(Info
.szRegName
, TRUE
)))
152 ItemInfo
= HeapAlloc(GetProcessHeap(), 0, sizeof(APPLICATION_INFO
));
153 if (!ItemInfo
) return FALSE
;
157 Index
= ListViewAddItem(Info
.Category
, 0, Info
.szName
, (LPARAM
)ItemInfo
);
158 ListView_SetItemText(hListView
, Index
, 1, Info
.szVersion
);
159 ListView_SetItemText(hListView
, Index
, 2, Info
.szDesc
);
166 UpdateApplicationsList(INT EnumType
)
168 WCHAR szBuffer1
[MAX_STR_LEN
], szBuffer2
[MAX_STR_LEN
];
170 HIMAGELIST hImageListView
;
172 (VOID
) ListView_DeleteAllItems(hListView
);
174 /* Create image list */
175 hImageListView
= ImageList_Create(LISTVIEW_ICON_SIZE
,
177 GetSystemColorDepth() | ILC_MASK
,
180 hIcon
= LoadImage(hInst
,
181 MAKEINTRESOURCE(IDI_MAIN
),
185 LR_CREATEDIBSECTION
);
187 ImageList_AddIcon(hImageListView
, hIcon
);
190 if (EnumType
== -1) EnumType
= SelectedEnumType
;
192 if (IS_INSTALLED_ENUM(SelectedEnumType
))
193 FreeInstalledAppList();
194 else if (IS_AVAILABLE_ENUM(SelectedEnumType
))
195 FreeAvailableAppList();
197 if (IS_INSTALLED_ENUM(EnumType
))
199 /* Enum installed applications and updates */
200 EnumInstalledApplications(EnumType
, TRUE
, EnumInstalledAppProc
);
201 EnumInstalledApplications(EnumType
, FALSE
, EnumInstalledAppProc
);
203 else if (IS_AVAILABLE_ENUM(EnumType
))
205 /* Enum availabled applications */
206 EnumAvailableApplications(EnumType
, EnumAvailableAppProc
);
209 /* Set image list for ListView */
210 hImageListView
= ListView_SetImageList(hListView
, hImageListView
, LVSIL_SMALL
);
212 /* Destroy old image list */
214 ImageList_Destroy(hImageListView
);
216 SelectedEnumType
= EnumType
;
218 LoadStringW(hInst
, IDS_APPS_COUNT
, szBuffer2
, sizeof(szBuffer2
) / sizeof(WCHAR
));
219 swprintf(szBuffer1
, szBuffer2
, ListView_GetItemCount(hListView
));
220 SetStatusBarText(szBuffer1
);
226 InitApplicationsList(VOID
)
228 WCHAR szText
[MAX_STR_LEN
];
230 /* Add columns to ListView */
231 LoadStringW(hInst
, IDS_APP_NAME
, szText
, sizeof(szText
) / sizeof(WCHAR
));
232 ListViewAddColumn(0, szText
, 200, LVCFMT_LEFT
);
234 LoadStringW(hInst
, IDS_APP_INST_VERSION
, szText
, sizeof(szText
) / sizeof(WCHAR
));
235 ListViewAddColumn(1, szText
, 90, LVCFMT_RIGHT
);
237 LoadStringW(hInst
, IDS_APP_DESCRIPTION
, szText
, sizeof(szText
) / sizeof(WCHAR
));
238 ListViewAddColumn(3, szText
, 250, LVCFMT_LEFT
);
240 UpdateApplicationsList(ENUM_ALL_COMPONENTS
);
244 AddCategory(HTREEITEM hRootItem
, UINT TextIndex
, UINT IconIndex
)
246 WCHAR szText
[MAX_STR_LEN
];
250 hIcon
= LoadImage(hInst
,
251 MAKEINTRESOURCE(IconIndex
),
255 LR_CREATEDIBSECTION
);
257 Index
= ImageList_AddIcon(hImageTreeView
, hIcon
);
260 LoadStringW(hInst
, TextIndex
, szText
, sizeof(szText
) / sizeof(TCHAR
));
262 return TreeViewAddItem(hRootItem
, szText
, Index
, Index
, TextIndex
);
266 InitCategoriesList(VOID
)
268 HTREEITEM hRootItem1
, hRootItem2
;
270 /* Create image list */
271 hImageTreeView
= ImageList_Create(TREEVIEW_ICON_SIZE
,
273 GetSystemColorDepth() | ILC_MASK
,
276 hRootItem1
= AddCategory(TVI_ROOT
, IDS_INSTALLED
, IDI_CATEGORY
);
277 AddCategory(hRootItem1
, IDS_APPLICATIONS
, IDI_APPS
);
278 AddCategory(hRootItem1
, IDS_UPDATES
, IDI_APPUPD
);
280 hRootItem2
= AddCategory(TVI_ROOT
, IDS_AVAILABLEFORINST
, IDI_CATEGORY
);
281 AddCategory(hRootItem2
, IDS_CAT_AUDIO
, IDI_CAT_AUDIO
);
282 AddCategory(hRootItem2
, IDS_CAT_VIDEO
, IDI_CAT_VIDEO
);
283 AddCategory(hRootItem2
, IDS_CAT_GRAPHICS
, IDI_CAT_GRAPHICS
);
284 AddCategory(hRootItem2
, IDS_CAT_GAMES
, IDI_CAT_GAMES
);
285 AddCategory(hRootItem2
, IDS_CAT_INTERNET
, IDI_CAT_INTERNET
);
286 AddCategory(hRootItem2
, IDS_CAT_OFFICE
, IDI_CAT_OFFICE
);
287 AddCategory(hRootItem2
, IDS_CAT_DEVEL
, IDI_CAT_DEVEL
);
288 AddCategory(hRootItem2
, IDS_CAT_EDU
, IDI_CAT_EDU
);
289 AddCategory(hRootItem2
, IDS_CAT_ENGINEER
, IDI_CAT_ENGINEER
);
290 AddCategory(hRootItem2
, IDS_CAT_FINANCE
, IDI_CAT_FINANCE
);
291 AddCategory(hRootItem2
, IDS_CAT_SCIENCE
, IDI_CAT_SCIENCE
);
292 AddCategory(hRootItem2
, IDS_CAT_TOOLS
, IDI_CAT_TOOLS
);
293 AddCategory(hRootItem2
, IDS_CAT_DRIVERS
, IDI_CAT_DRIVERS
);
294 AddCategory(hRootItem2
, IDS_CAT_LIBS
, IDI_CAT_LIBS
);
295 AddCategory(hRootItem2
, IDS_CAT_OTHER
, IDI_CAT_OTHER
);
297 (VOID
) TreeView_SetImageList(hTreeView
, hImageTreeView
, TVSIL_NORMAL
);
299 (VOID
) TreeView_Expand(hTreeView
, hRootItem2
, TVE_EXPAND
);
300 (VOID
) TreeView_Expand(hTreeView
, hRootItem1
, TVE_EXPAND
);
302 (VOID
) TreeView_SelectItem(hTreeView
, hRootItem1
);
306 InitControls(HWND hwnd
)
308 if (SettingsInfo
.bSaveWndPos
)
310 MoveWindow(hwnd
, SettingsInfo
.Left
, SettingsInfo
.Top
,
311 SettingsInfo
.Right
- SettingsInfo
.Left
,
312 SettingsInfo
.Bottom
- SettingsInfo
.Top
, TRUE
);
314 if (SettingsInfo
.Maximized
) ShowWindow(hwnd
, SW_MAXIMIZE
);
317 if (CreateStatusBar(hwnd
) &&
318 CreateToolBar(hwnd
) &&
319 CreateListView(hwnd
) &&
320 CreateTreeView(hwnd
) &&
321 CreateRichEdit(hwnd
) &&
322 CreateVSplitBar(hwnd
) &&
323 CreateHSplitBar(hwnd
))
325 WCHAR szBuffer1
[MAX_STR_LEN
], szBuffer2
[MAX_STR_LEN
];
327 InitApplicationsList();
329 InitCategoriesList();
331 LoadStringW(hInst
, IDS_APPS_COUNT
, szBuffer2
, sizeof(szBuffer2
) / sizeof(WCHAR
));
332 swprintf(szBuffer1
, szBuffer2
, ListView_GetItemCount(hListView
));
333 SetStatusBarText(szBuffer1
);
341 MainWndOnCommand(HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
343 WORD wCommand
= LOWORD(wParam
);
345 if (lParam
== (LPARAM
)hSearchBar
)
347 WCHAR szBuf
[MAX_STR_LEN
];
349 switch (HIWORD(wParam
))
353 WCHAR szWndText
[MAX_STR_LEN
];
355 LoadStringW(hInst
, IDS_SEARCH_TEXT
, szBuf
, sizeof(szBuf
) / sizeof(WCHAR
));
356 GetWindowTextW(hSearchBar
, szWndText
, MAX_STR_LEN
);
357 if (wcscmp(szBuf
, szWndText
) == 0) SetWindowTextW(hSearchBar
, L
"");
363 GetWindowTextW(hSearchBar
, szBuf
, MAX_STR_LEN
);
364 if (wcslen(szBuf
) < 1)
366 LoadStringW(hInst
, IDS_SEARCH_TEXT
, szBuf
, sizeof(szBuf
) / sizeof(WCHAR
));
367 SetWindowTextW(hSearchBar
, szBuf
);
373 /* TODO: Implement search */
383 ShellExecuteW(hwnd
, L
"open", pLink
, NULL
, NULL
, SW_SHOWNOACTIVATE
);
384 HeapFree(GetProcessHeap(), 0, pLink
);
388 CopyTextToClipboard(pLink
);
389 HeapFree(GetProcessHeap(), 0, pLink
);
393 CreateSettingsDlg(hwnd
);
397 PostMessageW(hwnd
, WM_CLOSE
, 0, 0);
401 if (DownloadApplication(-1))
402 /* TODO: Implement install dialog
403 * if (InstallApplication(-1))
405 UpdateApplicationsList(-1);
409 if (UninstallApplication(-1, FALSE
))
410 UpdateApplicationsList(-1);
414 if (UninstallApplication(-1, TRUE
))
415 UpdateApplicationsList(-1);
419 RemoveAppFromRegistry(-1);
423 UpdateApplicationsList(-1);
427 MessageBoxW(hwnd
, L
"Help not implemented yet", NULL
, MB_OK
);
437 MainWndOnSize(HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
439 HDWP hdwp
= BeginDeferWindowPos(5);
440 INT SearchBarWidth
= GetWindowWidth(hSearchBar
);
441 INT RichPos
= GetWindowHeight(hRichEdit
);
442 INT NewPos
= HIWORD(lParam
) - (RichPos
+ SPLIT_WIDTH
+ GetWindowHeight(hStatusBar
));
445 /* Size status bar */
446 SendMessage(hStatusBar
, WM_SIZE
, 0, 0);
449 SendMessage(hToolBar
, TB_AUTOSIZE
, 0, 0);
452 MoveWindow(hSearchBar
, LOWORD(lParam
) - SearchBarWidth
- 4, 5, SearchBarWidth
, 22, TRUE
);
455 * HIWORD(lParam) - Height of main window
456 * LOWORD(lParam) - Width of main window
459 /* Size vertical splitter bar */
463 (VSplitterPos
= GetWindowWidth(hTreeView
)),
464 GetWindowHeight(hToolBar
),
466 HIWORD(lParam
) - GetWindowHeight(hToolBar
) - GetWindowHeight(hStatusBar
),
467 SWP_NOZORDER
|SWP_NOACTIVATE
);
474 GetWindowHeight(hToolBar
),
476 HIWORD(lParam
) - GetWindowHeight(hToolBar
) - GetWindowHeight(hStatusBar
),
477 SWP_NOZORDER
|SWP_NOACTIVATE
);
479 while (NewPos
< SPLIT_WIDTH
+ GetWindowHeight(hToolBar
))
482 NewPos
= HIWORD(lParam
) - (RichPos
+
483 SPLIT_WIDTH
+ GetWindowHeight(hStatusBar
));
485 SetHSplitterPos(NewPos
);
491 VSplitterPos
+ SPLIT_WIDTH
,
492 GetWindowHeight(hToolBar
),
493 LOWORD(lParam
) - (VSplitterPos
+ SPLIT_WIDTH
),
494 GetHSplitterPos() - GetWindowHeight(hToolBar
),
495 SWP_NOZORDER
|SWP_NOACTIVATE
);
501 VSplitterPos
+ SPLIT_WIDTH
,
502 GetHSplitterPos() + SPLIT_WIDTH
,
503 LOWORD(lParam
) - (VSplitterPos
+ SPLIT_WIDTH
),
505 SWP_NOZORDER
|SWP_NOACTIVATE
);
507 /* Size horizontal splitter bar */
511 VSplitterPos
+ SPLIT_WIDTH
,
513 LOWORD(lParam
) - (VSplitterPos
+ SPLIT_WIDTH
),
515 SWP_NOZORDER
|SWP_NOACTIVATE
);
517 EndDeferWindowPos(hdwp
);
521 MainWindowProc(HWND hwnd
, UINT Msg
, WPARAM wParam
, LPARAM lParam
)
526 if (!InitControls(hwnd
))
527 PostMessage(hwnd
, WM_CLOSE
, 0, 0);
529 if (SettingsInfo
.bUpdateAtStart
)
534 MainWndOnCommand(hwnd
, wParam
, lParam
);
539 LPNMHDR data
= (LPNMHDR
)lParam
;
545 if (data
->hwndFrom
== hTreeView
)
547 switch (((LPNMTREEVIEW
)lParam
)->itemNew
.lParam
)
550 UpdateApplicationsList(ENUM_ALL_COMPONENTS
);
553 case IDS_APPLICATIONS
:
554 UpdateApplicationsList(ENUM_APPLICATIONS
);
558 UpdateApplicationsList(ENUM_UPDATES
);
561 case IDS_AVAILABLEFORINST
:
562 UpdateApplicationsList(ENUM_ALL_AVAILABLE
);
566 UpdateApplicationsList(ENUM_CAT_AUDIO
);
570 UpdateApplicationsList(ENUM_CAT_DEVEL
);
573 case IDS_CAT_DRIVERS
:
574 UpdateApplicationsList(ENUM_CAT_DRIVERS
);
578 UpdateApplicationsList(ENUM_CAT_EDU
);
581 case IDS_CAT_ENGINEER
:
582 UpdateApplicationsList(ENUM_CAT_ENGINEER
);
585 case IDS_CAT_FINANCE
:
586 UpdateApplicationsList(ENUM_CAT_FINANCE
);
590 UpdateApplicationsList(ENUM_CAT_GAMES
);
593 case IDS_CAT_GRAPHICS
:
594 UpdateApplicationsList(ENUM_CAT_GRAPHICS
);
597 case IDS_CAT_INTERNET
:
598 UpdateApplicationsList(ENUM_CAT_INTERNET
);
602 UpdateApplicationsList(ENUM_CAT_LIBS
);
606 UpdateApplicationsList(ENUM_CAT_OFFICE
);
610 UpdateApplicationsList(ENUM_CAT_OTHER
);
613 case IDS_CAT_SCIENCE
:
614 UpdateApplicationsList(ENUM_CAT_SCIENCE
);
618 UpdateApplicationsList(ENUM_CAT_TOOLS
);
622 UpdateApplicationsList(ENUM_CAT_VIDEO
);
631 LPNMLVKEYDOWN pnkd
= (LPNMLVKEYDOWN
) lParam
;
633 if (pnkd
->hdr
.hwndFrom
== hListView
)
635 INT ItemIndex
= (INT
) SendMessage(hListView
, LVM_GETNEXTITEM
, -1, LVNI_FOCUSED
);
637 if (pnkd
->wVKey
== VK_UP
) ItemIndex
-= 1;
638 if (pnkd
->wVKey
== VK_DOWN
) ItemIndex
+= 1;
640 if (IS_INSTALLED_ENUM(SelectedEnumType
))
641 ShowInstalledAppInfo(ItemIndex
);
642 if (IS_AVAILABLE_ENUM(SelectedEnumType
))
643 ShowAvailableAppInfo(ItemIndex
);
648 case LVN_COLUMNCLICK
:
650 LPNMLISTVIEW pnmv
= (LPNMLISTVIEW
) lParam
;
652 (VOID
) ListView_SortItems(hListView
, ListViewCompareFunc
, pnmv
->iSubItem
);
653 bAscending
= !bAscending
;
658 if (data
->hwndFrom
== hListView
)
660 if (IS_INSTALLED_ENUM(SelectedEnumType
))
661 ShowInstalledAppInfo(-1);
662 if (IS_AVAILABLE_ENUM(SelectedEnumType
))
663 ShowAvailableAppInfo(-1);
668 if (data
->hwndFrom
== hListView
)
669 ShowPopupMenu(hListView
, IDR_APPLICATIONMENU
);
673 RichEditOnLink(hwnd
, (ENLINK
*)lParam
);
676 case TTN_GETDISPINFO
:
677 ToolBarOnGetDispInfo((LPTOOLTIPTEXT
)lParam
);
688 if ((GetClientWindowHeight(hMainWnd
) - GetWindowHeight(hStatusBar
) - SPLIT_WIDTH
) < GetHSplitterPos())
690 INT NewSplitPos
= GetClientWindowHeight(hwnd
) - 100 - GetWindowHeight(hStatusBar
) - SPLIT_WIDTH
;
691 if (NewSplitPos
> GetWindowHeight(hToolBar
) + SPLIT_WIDTH
)
692 SetHSplitterPos(NewSplitPos
);
695 MainWndOnSize(hwnd
, wParam
, lParam
);
701 int RichEditHeight
= GetWindowHeight(hRichEdit
);
702 LPRECT pRect
= (LPRECT
)lParam
;
704 while (RichEditHeight
<= 100)
706 if (GetHSplitterPos() - 1 < GetWindowHeight(hToolBar
) + GetWindowHeight(hListView
) + SPLIT_WIDTH
)
708 SetHSplitterPos(GetHSplitterPos() - 1);
712 if (pRect
->right
-pRect
->left
< 565)
713 pRect
->right
= pRect
->left
+ 565;
715 if (pRect
->bottom
-pRect
->top
< 300)
716 pRect
->bottom
= pRect
->top
+ 300;
720 case WM_SYSCOLORCHANGE
:
722 /* Forward WM_SYSCOLORCHANGE to common controls */
723 SendMessage(hListView
, WM_SYSCOLORCHANGE
, 0, 0);
724 SendMessage(hTreeView
, WM_SYSCOLORCHANGE
, 0, 0);
725 SendMessage(hToolBar
, WM_SYSCOLORCHANGE
, 0, 0);
726 SendMessageW(hRichEdit
, EM_SETBKGNDCOLOR
, 0, GetSysColor(COLOR_BTNFACE
));
732 ShowWindow(hwnd
, SW_HIDE
);
737 if (IS_AVAILABLE_ENUM(SelectedEnumType
))
738 FreeAvailableAppList();
739 if (IS_INSTALLED_ENUM(SelectedEnumType
))
740 FreeInstalledAppList();
741 if (hImageTreeView
) ImageList_Destroy(hImageTreeView
);
749 return DefWindowProc(hwnd
, Msg
, wParam
, lParam
);
753 wWinMain(HINSTANCE hInstance
, HINSTANCE hPrevInstance
, LPWSTR lpCmdLine
, int nShowCmd
)
755 WNDCLASSEXW WndClass
= {0};
756 WCHAR szWindowClass
[] = L
"ROSAPPMGR";
757 WCHAR szWindowName
[MAX_STR_LEN
];
758 WCHAR szErrorText
[MAX_STR_LEN
];
759 HANDLE hMutex
= NULL
;
764 if (!IsUserAnAdmin())
766 LoadStringW(hInst
, IDS_USER_NOT_ADMIN
, szErrorText
, sizeof(szErrorText
) / sizeof(WCHAR
));
767 MessageBox(0, szErrorText
, NULL
, MB_OK
| MB_ICONWARNING
);
771 hMutex
= CreateMutexW(NULL
, FALSE
, szWindowClass
);
772 if ((!hMutex
) || (GetLastError() == ERROR_ALREADY_EXISTS
))
774 /* If already started, it is found its window */
775 HWND hWindow
= FindWindowW(szWindowClass
, NULL
);
777 /* Activate window */
778 ShowWindow(hWindow
, SW_SHOWNORMAL
);
779 SetForegroundWindow(hWindow
);
785 FillDefaultSettings(&SettingsInfo
);
790 InitCommonControls();
792 /* Create the window */
793 WndClass
.cbSize
= sizeof(WNDCLASSEXW
);
794 WndClass
.lpszClassName
= szWindowClass
;
795 WndClass
.lpfnWndProc
= MainWindowProc
;
796 WndClass
.hInstance
= hInstance
;
797 WndClass
.hIcon
= LoadIcon(hInstance
, MAKEINTRESOURCE(IDI_MAIN
));
798 WndClass
.hCursor
= LoadCursor(NULL
, IDC_ARROW
);
799 WndClass
.hbrBackground
= (HBRUSH
)(COLOR_BTNFACE
+ 1);
800 WndClass
.lpszMenuName
= MAKEINTRESOURCEW(IDR_MAINMENU
);
802 if (RegisterClassExW(&WndClass
) == (ATOM
)0) goto Exit
;
804 LoadStringW(hInst
, IDS_APPTITLE
, szWindowName
, sizeof(szWindowName
) / sizeof(WCHAR
));
806 hMainWnd
= CreateWindowExW(WS_EX_WINDOWEDGE
,
809 WS_OVERLAPPEDWINDOW
| WS_CLIPCHILDREN
| WS_CLIPSIBLINGS
,
819 if (!hMainWnd
) goto Exit
;
822 ShowWindow(hMainWnd
, SW_SHOW
);
823 UpdateWindow(hMainWnd
);
826 while (GetMessage(&Msg
, NULL
, 0, 0))
828 TranslateMessage(&Msg
);
829 DispatchMessage(&Msg
);
833 if (hMutex
) CloseHandle(hMutex
);