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 hImageListView
= NULL
;
14 HIMAGELIST hImageTreeView
= NULL
;
15 INT SelectedEnumType
= ENUM_ALL_COMPONENTS
;
16 SETTINGS_INFO SettingsInfo
;
20 FillDafaultSettings(PSETTINGS_INFO pSettingsInfo
)
22 pSettingsInfo
->bSaveWndPos
= TRUE
;
23 pSettingsInfo
->bUpdateAtStart
= FALSE
;
24 pSettingsInfo
->bLogEnabled
= TRUE
;
25 wcscpy(pSettingsInfo
->szDownloadDir
, L
"C:\\Downloads");
26 pSettingsInfo
->bDelInstaller
= FALSE
;
28 pSettingsInfo
->Maximized
= FALSE
;
29 pSettingsInfo
->Left
= 0;
30 pSettingsInfo
->Top
= 0;
31 pSettingsInfo
->Right
= 680;
32 pSettingsInfo
->Bottom
= 450;
41 if (RegOpenKeyExW(HKEY_LOCAL_MACHINE
, L
"Software\\ReactOS\\rapps", 0, KEY_READ
, &hKey
) == ERROR_SUCCESS
)
43 dwSize
= sizeof(SETTINGS_INFO
);
44 if (RegQueryValueExW(hKey
, L
"Settings", NULL
, NULL
, (LPBYTE
)&SettingsInfo
, &dwSize
) == ERROR_SUCCESS
)
57 SaveSettings(HWND hwnd
)
62 if (SettingsInfo
.bSaveWndPos
)
64 wp
.length
= sizeof(WINDOWPLACEMENT
);
65 GetWindowPlacement(hwnd
, &wp
);
67 SettingsInfo
.Left
= wp
.rcNormalPosition
.left
;
68 SettingsInfo
.Top
= wp
.rcNormalPosition
.top
;
69 SettingsInfo
.Right
= wp
.rcNormalPosition
.right
;
70 SettingsInfo
.Bottom
= wp
.rcNormalPosition
.bottom
;
71 SettingsInfo
.Maximized
= (IsZoomed(hwnd
) || (wp
.flags
& WPF_RESTORETOMAXIMIZED
));
74 if (RegCreateKeyExW(HKEY_LOCAL_MACHINE
, L
"Software\\ReactOS\\rapps", 0, NULL
,
75 REG_OPTION_NON_VOLATILE
, KEY_WRITE
, NULL
, &hKey
, NULL
) == ERROR_SUCCESS
)
77 RegSetValueEx(hKey
, L
"Settings", 0, REG_BINARY
, (LPBYTE
)&SettingsInfo
, sizeof(SETTINGS_INFO
));
83 FreeInstalledAppList(VOID
)
85 INT Count
= ListView_GetItemCount(hListView
) - 1;
90 Info
= ListViewGetlParam(Count
);
93 RegCloseKey(Info
->hSubKey
);
94 HeapFree(GetProcessHeap(), 0, Info
);
102 EnumInstalledAppProc(INT ItemIndex
, LPWSTR lpName
, INSTALLED_INFO Info
)
104 PINSTALLED_INFO ItemInfo
;
105 WCHAR szText
[MAX_PATH
];
108 ItemInfo
= HeapAlloc(GetProcessHeap(), 0, sizeof(INSTALLED_INFO
));
109 if (!ItemInfo
) return FALSE
;
113 Index
= ListViewAddItem(ItemIndex
, 0, lpName
, (LPARAM
)ItemInfo
);
115 /* Get version info */
116 GetApplicationString((HKEY
)ItemInfo
->hSubKey
, L
"DisplayVersion", szText
);
117 ListView_SetItemText(hListView
, Index
, 1, szText
);
119 GetApplicationString((HKEY
)ItemInfo
->hSubKey
, L
"Comments", szText
);
120 ListView_SetItemText(hListView
, Index
, 2, szText
);
126 FreeAvailableAppList(VOID
)
128 INT Count
= ListView_GetItemCount(hListView
) - 1;
133 Info
= ListViewGetlParam(Count
);
135 HeapFree(GetProcessHeap(), 0, Info
);
142 EnumAvailableAppProc(APPLICATION_INFO Info
)
144 PAPPLICATION_INFO ItemInfo
;
147 if (!IsInstalledApplication(Info
.szRegName
, FALSE
) &&
148 !IsInstalledApplication(Info
.szRegName
, TRUE
))
150 ItemInfo
= HeapAlloc(GetProcessHeap(), 0, sizeof(APPLICATION_INFO
));
151 if (!ItemInfo
) return FALSE
;
155 Index
= ListViewAddItem(Info
.Category
, 0, Info
.szName
, (LPARAM
)ItemInfo
);
156 ListView_SetItemText(hListView
, Index
, 1, Info
.szVersion
);
157 ListView_SetItemText(hListView
, Index
, 2, Info
.szDesc
);
164 UpdateApplicationsList(INT EnumType
)
166 WCHAR szBuffer1
[MAX_STR_LEN
], szBuffer2
[MAX_STR_LEN
];
169 if (hImageListView
) ImageList_Destroy(hImageListView
);
170 (VOID
) ListView_DeleteAllItems(hListView
);
172 /* Create image list */
173 hImageListView
= ImageList_Create(LISTVIEW_ICON_SIZE
,
175 GetSystemColorDepth() | ILC_MASK
,
178 hIcon
= LoadImage(hInst
,
179 MAKEINTRESOURCE(IDI_MAIN
),
183 LR_CREATEDIBSECTION
);
185 ImageList_AddIcon(hImageListView
, hIcon
);
188 if (EnumType
== -1) EnumType
= SelectedEnumType
;
190 if (IS_INSTALLED_ENUM(SelectedEnumType
))
191 FreeInstalledAppList();
192 else if (IS_AVAILABLE_ENUM(SelectedEnumType
))
193 FreeAvailableAppList();
195 if (IS_INSTALLED_ENUM(EnumType
))
197 /* Enum installed applications and updates */
198 EnumInstalledApplications(EnumType
, TRUE
, EnumInstalledAppProc
);
199 EnumInstalledApplications(EnumType
, FALSE
, EnumInstalledAppProc
);
201 else if (IS_AVAILABLE_ENUM(EnumType
))
203 /* Enum availabled applications */
204 EnumAvailableApplications(EnumType
, EnumAvailableAppProc
);
207 /* Set image list for ListView */
208 (VOID
) ListView_SetImageList(hListView
, hImageListView
, LVSIL_SMALL
);
210 SelectedEnumType
= EnumType
;
212 LoadStringW(hInst
, IDS_APPS_COUNT
, szBuffer2
, sizeof(szBuffer2
) / sizeof(WCHAR
));
213 swprintf(szBuffer1
, szBuffer2
, ListView_GetItemCount(hListView
));
214 SetStatusBarText(szBuffer1
);
220 InitApplicationsList(VOID
)
222 WCHAR szText
[MAX_STR_LEN
];
224 /* Add columns to ListView */
225 LoadStringW(hInst
, IDS_APP_NAME
, szText
, sizeof(szText
) / sizeof(WCHAR
));
226 ListViewAddColumn(0, szText
, 200, LVCFMT_LEFT
);
228 LoadStringW(hInst
, IDS_APP_INST_VERSION
, szText
, sizeof(szText
) / sizeof(WCHAR
));
229 ListViewAddColumn(1, szText
, 90, LVCFMT_RIGHT
);
231 LoadStringW(hInst
, IDS_APP_DESCRIPTION
, szText
, sizeof(szText
) / sizeof(WCHAR
));
232 ListViewAddColumn(3, szText
, 250, LVCFMT_LEFT
);
234 UpdateApplicationsList(ENUM_ALL_COMPONENTS
);
238 AddCategory(HTREEITEM hRootItem
, UINT TextIndex
, UINT IconIndex
)
240 WCHAR szText
[MAX_STR_LEN
];
244 hIcon
= LoadImage(hInst
,
245 MAKEINTRESOURCE(IconIndex
),
249 LR_CREATEDIBSECTION
);
251 Index
= ImageList_AddIcon(hImageTreeView
, hIcon
);
254 LoadStringW(hInst
, TextIndex
, szText
, sizeof(szText
) / sizeof(TCHAR
));
256 return TreeViewAddItem(hRootItem
, szText
, Index
, Index
, TextIndex
);
260 InitCategoriesList(VOID
)
262 HTREEITEM hRootItem1
, hRootItem2
;
264 /* Create image list */
265 hImageTreeView
= ImageList_Create(TREEVIEW_ICON_SIZE
,
267 GetSystemColorDepth() | ILC_MASK
,
270 hRootItem1
= AddCategory(TVI_ROOT
, IDS_INSTALLED
, IDI_CATEGORY
);
271 AddCategory(hRootItem1
, IDS_APPLICATIONS
, IDI_APPS
);
272 AddCategory(hRootItem1
, IDS_UPDATES
, IDI_APPUPD
);
274 hRootItem2
= AddCategory(TVI_ROOT
, IDS_AVAILABLEFORINST
, IDI_CATEGORY
);
275 AddCategory(hRootItem2
, IDS_CAT_AUDIO
, IDI_CAT_AUDIO
);
276 AddCategory(hRootItem2
, IDS_CAT_VIDEO
, IDI_CAT_VIDEO
);
277 AddCategory(hRootItem2
, IDS_CAT_GRAPHICS
, IDI_CAT_GRAPHICS
);
278 AddCategory(hRootItem2
, IDS_CAT_GAMES
, IDI_CAT_GAMES
);
279 AddCategory(hRootItem2
, IDS_CAT_INTERNET
, IDI_CAT_INTERNET
);
280 AddCategory(hRootItem2
, IDS_CAT_OFFICE
, IDI_CAT_OFFICE
);
281 AddCategory(hRootItem2
, IDS_CAT_DEVEL
, IDI_CAT_DEVEL
);
282 AddCategory(hRootItem2
, IDS_CAT_EDU
, IDI_CAT_EDU
);
283 AddCategory(hRootItem2
, IDS_CAT_ENGINEER
, IDI_CAT_ENGINEER
);
284 AddCategory(hRootItem2
, IDS_CAT_FINANCE
, IDI_CAT_FINANCE
);
285 AddCategory(hRootItem2
, IDS_CAT_SCIENCE
, IDI_CAT_SCIENCE
);
286 AddCategory(hRootItem2
, IDS_CAT_TOOLS
, IDI_CAT_TOOLS
);
287 AddCategory(hRootItem2
, IDS_CAT_DRIVERS
, IDI_CAT_DRIVERS
);
288 AddCategory(hRootItem2
, IDS_CAT_LIBS
, IDI_CAT_LIBS
);
289 AddCategory(hRootItem2
, IDS_CAT_OTHER
, IDI_CAT_OTHER
);
291 (VOID
) TreeView_SetImageList(hTreeView
, hImageTreeView
, TVSIL_NORMAL
);
293 (VOID
) TreeView_Expand(hTreeView
, hRootItem2
, TVE_EXPAND
);
294 (VOID
) TreeView_Expand(hTreeView
, hRootItem1
, TVE_EXPAND
);
296 (VOID
) TreeView_SelectItem(hTreeView
, hRootItem1
);
300 InitControls(HWND hwnd
)
302 if (SettingsInfo
.bSaveWndPos
)
304 MoveWindow(hwnd
, SettingsInfo
.Left
, SettingsInfo
.Top
,
305 SettingsInfo
.Right
- SettingsInfo
.Left
,
306 SettingsInfo
.Bottom
- SettingsInfo
.Top
, TRUE
);
308 if (SettingsInfo
.Maximized
) ShowWindow(hwnd
, SW_MAXIMIZE
);
311 if (CreateStatusBar(hwnd
) &&
312 CreateToolBar(hwnd
) &&
313 CreateListView(hwnd
) &&
314 CreateTreeView(hwnd
) &&
315 CreateRichEdit(hwnd
) &&
316 CreateVSplitBar(hwnd
) &&
317 CreateHSplitBar(hwnd
))
319 WCHAR szBuffer1
[MAX_STR_LEN
], szBuffer2
[MAX_STR_LEN
];
321 InitApplicationsList();
323 InitCategoriesList();
325 LoadStringW(hInst
, IDS_APPS_COUNT
, szBuffer2
, sizeof(szBuffer2
) / sizeof(WCHAR
));
326 swprintf(szBuffer1
, szBuffer2
, ListView_GetItemCount(hListView
));
327 SetStatusBarText(szBuffer1
);
335 MainWndOnCommand(HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
337 WORD wCommand
= LOWORD(wParam
);
339 if (lParam
== (LPARAM
)hSearchBar
)
341 WCHAR szBuf
[MAX_STR_LEN
];
343 switch (HIWORD(wParam
))
347 WCHAR szWndText
[MAX_STR_LEN
];
349 LoadStringW(hInst
, IDS_SEARCH_TEXT
, szBuf
, sizeof(szBuf
) / sizeof(WCHAR
));
350 GetWindowTextW(hSearchBar
, szWndText
, MAX_STR_LEN
);
351 if (wcscmp(szBuf
, szWndText
) == 0) SetWindowTextW(hSearchBar
, L
"");
357 GetWindowTextW(hSearchBar
, szBuf
, MAX_STR_LEN
);
358 if (wcslen(szBuf
) < 1)
360 LoadStringW(hInst
, IDS_SEARCH_TEXT
, szBuf
, sizeof(szBuf
) / sizeof(WCHAR
));
361 SetWindowTextW(hSearchBar
, szBuf
);
367 /* TODO: Implement search */
377 ShellExecuteW(hwnd
, L
"open", pLink
, NULL
, NULL
, SW_SHOWNOACTIVATE
);
378 HeapFree(GetProcessHeap(), 0, pLink
);
382 CopyTextToClipboard(pLink
);
383 HeapFree(GetProcessHeap(), 0, pLink
);
387 CreateSettingsDlg(hwnd
);
391 PostMessageW(hwnd
, WM_CLOSE
, 0, 0);
395 if (DownloadApplication(-1))
396 /* TODO: Implement install dialog
397 * if (InstallApplication(-1))
399 UpdateApplicationsList(-1);
403 if (UninstallApplication(-1, FALSE
))
404 UpdateApplicationsList(-1);
408 if (UninstallApplication(-1, TRUE
))
409 UpdateApplicationsList(-1);
413 RemoveAppFromRegistry(-1);
417 UpdateApplicationsList(-1);
421 MessageBoxW(hwnd
, L
"Help not implemented yet", NULL
, MB_OK
);
431 MainWndOnSize(HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
433 HDWP hdwp
= BeginDeferWindowPos(5);
434 INT SearchBarWidth
= GetWindowWidth(hSearchBar
);
435 INT RichPos
= GetWindowHeight(hRichEdit
);
436 INT NewPos
= HIWORD(lParam
) - (RichPos
+ SPLIT_WIDTH
+ GetWindowHeight(hStatusBar
));
439 /* Size status bar */
440 SendMessage(hStatusBar
, WM_SIZE
, 0, 0);
443 SendMessage(hToolBar
, TB_AUTOSIZE
, 0, 0);
446 MoveWindow(hSearchBar
, LOWORD(lParam
) - SearchBarWidth
- 4, 5, SearchBarWidth
, 22, TRUE
);
449 * HIWORD(lParam) - Height of main window
450 * LOWORD(lParam) - Width of main window
453 /* Size vertical splitter bar */
457 (VSplitterPos
= GetWindowWidth(hTreeView
)),
458 GetWindowHeight(hToolBar
),
460 HIWORD(lParam
) - GetWindowHeight(hToolBar
) - GetWindowHeight(hStatusBar
),
461 SWP_NOZORDER
|SWP_NOACTIVATE
);
468 GetWindowHeight(hToolBar
),
470 HIWORD(lParam
) - GetWindowHeight(hToolBar
) - GetWindowHeight(hStatusBar
),
471 SWP_NOZORDER
|SWP_NOACTIVATE
);
473 while (NewPos
< SPLIT_WIDTH
+ GetWindowHeight(hToolBar
))
476 NewPos
= HIWORD(lParam
) - (RichPos
+
477 SPLIT_WIDTH
+ GetWindowHeight(hStatusBar
));
479 SetHSplitterPos(NewPos
);
485 VSplitterPos
+ SPLIT_WIDTH
,
486 GetWindowHeight(hToolBar
),
487 LOWORD(lParam
) - (VSplitterPos
+ SPLIT_WIDTH
),
488 GetHSplitterPos() - GetWindowHeight(hToolBar
),
489 SWP_NOZORDER
|SWP_NOACTIVATE
);
495 VSplitterPos
+ SPLIT_WIDTH
,
496 GetHSplitterPos() + SPLIT_WIDTH
,
497 LOWORD(lParam
) - (VSplitterPos
+ SPLIT_WIDTH
),
499 SWP_NOZORDER
|SWP_NOACTIVATE
);
501 /* Size horizontal splitter bar */
505 VSplitterPos
+ SPLIT_WIDTH
,
507 LOWORD(lParam
) - (VSplitterPos
+ SPLIT_WIDTH
),
509 SWP_NOZORDER
|SWP_NOACTIVATE
);
511 EndDeferWindowPos(hdwp
);
515 MainWindowProc(HWND hwnd
, UINT Msg
, WPARAM wParam
, LPARAM lParam
)
520 if (!InitControls(hwnd
))
521 PostMessage(hwnd
, WM_CLOSE
, 0, 0);
523 if (SettingsInfo
.bUpdateAtStart
)
528 MainWndOnCommand(hwnd
, wParam
, lParam
);
533 LPNMHDR data
= (LPNMHDR
)lParam
;
539 if (data
->hwndFrom
== hTreeView
)
541 switch (((LPNMTREEVIEW
)lParam
)->itemNew
.lParam
)
544 UpdateApplicationsList(ENUM_ALL_COMPONENTS
);
547 case IDS_APPLICATIONS
:
548 UpdateApplicationsList(ENUM_APPLICATIONS
);
552 UpdateApplicationsList(ENUM_UPDATES
);
555 case IDS_AVAILABLEFORINST
:
556 UpdateApplicationsList(ENUM_ALL_AVAILABLE
);
560 UpdateApplicationsList(ENUM_CAT_AUDIO
);
564 UpdateApplicationsList(ENUM_CAT_DEVEL
);
567 case IDS_CAT_DRIVERS
:
568 UpdateApplicationsList(ENUM_CAT_DRIVERS
);
572 UpdateApplicationsList(ENUM_CAT_EDU
);
575 case IDS_CAT_ENGINEER
:
576 UpdateApplicationsList(ENUM_CAT_ENGINEER
);
579 case IDS_CAT_FINANCE
:
580 UpdateApplicationsList(ENUM_CAT_FINANCE
);
584 UpdateApplicationsList(ENUM_CAT_GAMES
);
587 case IDS_CAT_GRAPHICS
:
588 UpdateApplicationsList(ENUM_CAT_GRAPHICS
);
591 case IDS_CAT_INTERNET
:
592 UpdateApplicationsList(ENUM_CAT_INTERNET
);
596 UpdateApplicationsList(ENUM_CAT_LIBS
);
600 UpdateApplicationsList(ENUM_CAT_OFFICE
);
604 UpdateApplicationsList(ENUM_CAT_OTHER
);
607 case IDS_CAT_SCIENCE
:
608 UpdateApplicationsList(ENUM_CAT_SCIENCE
);
612 UpdateApplicationsList(ENUM_CAT_TOOLS
);
616 UpdateApplicationsList(ENUM_CAT_VIDEO
);
625 LPNMLVKEYDOWN pnkd
= (LPNMLVKEYDOWN
) lParam
;
627 if (pnkd
->hdr
.hwndFrom
== hListView
)
629 INT ItemIndex
= (INT
) SendMessage(hListView
, LVM_GETNEXTITEM
, -1, LVNI_FOCUSED
);
631 if (pnkd
->wVKey
== VK_UP
) ItemIndex
-= 1;
632 if (pnkd
->wVKey
== VK_DOWN
) ItemIndex
+= 1;
634 if (IS_INSTALLED_ENUM(SelectedEnumType
))
635 ShowInstalledAppInfo(ItemIndex
);
636 if (IS_AVAILABLE_ENUM(SelectedEnumType
))
637 ShowAvailableAppInfo(ItemIndex
);
642 case LVN_COLUMNCLICK
:
644 LPNMLISTVIEW pnmv
= (LPNMLISTVIEW
) lParam
;
646 (VOID
) ListView_SortItems(hListView
, ListViewCompareFunc
, pnmv
->iSubItem
);
647 bAscending
= !bAscending
;
652 if (data
->hwndFrom
== hListView
)
654 if (IS_INSTALLED_ENUM(SelectedEnumType
))
655 ShowInstalledAppInfo(-1);
656 if (IS_AVAILABLE_ENUM(SelectedEnumType
))
657 ShowAvailableAppInfo(-1);
662 if (data
->hwndFrom
== hListView
)
663 ShowPopupMenu(hListView
, IDR_APPLICATIONMENU
);
667 RichEditOnLink(hwnd
, (ENLINK
*)lParam
);
670 case TTN_GETDISPINFO
:
671 ToolBarOnGetDispInfo((LPTOOLTIPTEXT
)lParam
);
682 if ((GetClientWindowHeight(hMainWnd
) - GetWindowHeight(hStatusBar
) - SPLIT_WIDTH
) < GetHSplitterPos())
684 INT NewSplitPos
= GetClientWindowHeight(hwnd
) - 100 - GetWindowHeight(hStatusBar
) - SPLIT_WIDTH
;
685 if (NewSplitPos
> GetWindowHeight(hToolBar
) + SPLIT_WIDTH
)
686 SetHSplitterPos(NewSplitPos
);
689 MainWndOnSize(hwnd
, wParam
, lParam
);
695 int RichEditHeight
= GetWindowHeight(hRichEdit
);
696 LPRECT pRect
= (LPRECT
)lParam
;
698 while (RichEditHeight
<= 100)
700 if (GetHSplitterPos() - 1 < GetWindowHeight(hToolBar
) + GetWindowHeight(hListView
) + SPLIT_WIDTH
)
702 SetHSplitterPos(GetHSplitterPos() - 1);
706 if (pRect
->right
-pRect
->left
< 565)
707 pRect
->right
= pRect
->left
+ 565;
709 if (pRect
->bottom
-pRect
->top
< 300)
710 pRect
->bottom
= pRect
->top
+ 300;
716 ShowWindow(hwnd
, SW_HIDE
);
721 if (IS_AVAILABLE_ENUM(SelectedEnumType
))
722 FreeAvailableAppList();
723 if (IS_INSTALLED_ENUM(SelectedEnumType
))
724 FreeInstalledAppList();
725 if (hImageListView
) ImageList_Destroy(hImageListView
);
726 if (hImageTreeView
) ImageList_Destroy(hImageTreeView
);
734 return DefWindowProc(hwnd
, Msg
, wParam
, lParam
);
738 wWinMain(HINSTANCE hInstance
, HINSTANCE hPrevInstance
, LPWSTR lpCmdLine
, int nShowCmd
)
740 WNDCLASSEXW WndClass
= {0};
741 WCHAR szWindowClass
[] = L
"ROSAPPMGR";
742 WCHAR szWindowName
[MAX_STR_LEN
];
743 WCHAR szErrorText
[MAX_STR_LEN
];
744 HANDLE hMutex
= NULL
;
749 if (!IsUserAnAdmin())
751 LoadStringW(hInst
, IDS_USER_NOT_ADMIN
, szErrorText
, sizeof(szErrorText
) / sizeof(WCHAR
));
752 MessageBox(0, szErrorText
, NULL
, MB_OK
| MB_ICONWARNING
);
756 hMutex
= CreateMutexW(NULL
, FALSE
, szWindowClass
);
757 if ((!hMutex
) || (GetLastError() == ERROR_ALREADY_EXISTS
))
759 /* If already started, it is found its window */
760 HWND hWindow
= FindWindowW(szWindowClass
, NULL
);
762 /* Activate window */
763 ShowWindow(hWindow
, SW_SHOWNORMAL
);
764 SetForegroundWindow(hWindow
);
770 FillDafaultSettings(&SettingsInfo
);
775 InitCommonControls();
777 /* Create the window */
778 WndClass
.cbSize
= sizeof(WNDCLASSEXW
);
779 WndClass
.lpszClassName
= szWindowClass
;
780 WndClass
.lpfnWndProc
= MainWindowProc
;
781 WndClass
.hInstance
= hInstance
;
782 WndClass
.style
= CS_HREDRAW
| CS_VREDRAW
;
783 WndClass
.hIcon
= LoadIcon(hInstance
, MAKEINTRESOURCE(IDI_MAIN
));
784 WndClass
.hCursor
= LoadCursor(NULL
, IDC_ARROW
);
785 WndClass
.hbrBackground
= (HBRUSH
)(COLOR_BTNFACE
+ 1);
786 WndClass
.lpszMenuName
= MAKEINTRESOURCEW(IDR_MAINMENU
);
788 if (RegisterClassExW(&WndClass
) == (ATOM
)0) goto Exit
;
790 LoadStringW(hInst
, IDS_APPTITLE
, szWindowName
, sizeof(szWindowName
) / sizeof(WCHAR
));
792 hMainWnd
= CreateWindowExW(WS_EX_WINDOWEDGE
,
795 WS_OVERLAPPEDWINDOW
| WS_CLIPCHILDREN
| WS_CLIPSIBLINGS
,
805 if (!hMainWnd
) goto Exit
;
808 ShowWindow(hMainWnd
, SW_SHOW
);
809 UpdateWindow(hMainWnd
);
812 while (GetMessage(&Msg
, NULL
, 0, 0))
814 TranslateMessage(&Msg
);
815 DispatchMessage(&Msg
);
819 if (hMutex
) CloseHandle(hMutex
);