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 /* Only add a ListView entry if...
148 - no RegName was supplied (so we cannot determine whether the application is installed or not) or
149 - a RegName was supplied and the application is not installed
151 if (!*Info
.szRegName
|| (!IsInstalledApplication(Info
.szRegName
, FALSE
) && !IsInstalledApplication(Info
.szRegName
, TRUE
)))
153 ItemInfo
= HeapAlloc(GetProcessHeap(), 0, sizeof(APPLICATION_INFO
));
154 if (!ItemInfo
) return FALSE
;
158 Index
= ListViewAddItem(Info
.Category
, 0, Info
.szName
, (LPARAM
)ItemInfo
);
159 ListView_SetItemText(hListView
, Index
, 1, Info
.szVersion
);
160 ListView_SetItemText(hListView
, Index
, 2, Info
.szDesc
);
167 UpdateApplicationsList(INT EnumType
)
169 WCHAR szBuffer1
[MAX_STR_LEN
], szBuffer2
[MAX_STR_LEN
];
172 if (hImageListView
) ImageList_Destroy(hImageListView
);
173 (VOID
) ListView_DeleteAllItems(hListView
);
175 /* Create image list */
176 hImageListView
= ImageList_Create(LISTVIEW_ICON_SIZE
,
178 GetSystemColorDepth() | ILC_MASK
,
181 hIcon
= LoadImage(hInst
,
182 MAKEINTRESOURCE(IDI_MAIN
),
186 LR_CREATEDIBSECTION
);
188 ImageList_AddIcon(hImageListView
, hIcon
);
191 if (EnumType
== -1) EnumType
= SelectedEnumType
;
193 if (IS_INSTALLED_ENUM(SelectedEnumType
))
194 FreeInstalledAppList();
195 else if (IS_AVAILABLE_ENUM(SelectedEnumType
))
196 FreeAvailableAppList();
198 if (IS_INSTALLED_ENUM(EnumType
))
200 /* Enum installed applications and updates */
201 EnumInstalledApplications(EnumType
, TRUE
, EnumInstalledAppProc
);
202 EnumInstalledApplications(EnumType
, FALSE
, EnumInstalledAppProc
);
204 else if (IS_AVAILABLE_ENUM(EnumType
))
206 /* Enum availabled applications */
207 EnumAvailableApplications(EnumType
, EnumAvailableAppProc
);
210 /* Set image list for ListView */
211 (VOID
) ListView_SetImageList(hListView
, hImageListView
, LVSIL_SMALL
);
213 SelectedEnumType
= EnumType
;
215 LoadStringW(hInst
, IDS_APPS_COUNT
, szBuffer2
, sizeof(szBuffer2
) / sizeof(WCHAR
));
216 swprintf(szBuffer1
, szBuffer2
, ListView_GetItemCount(hListView
));
217 SetStatusBarText(szBuffer1
);
223 InitApplicationsList(VOID
)
225 WCHAR szText
[MAX_STR_LEN
];
227 /* Add columns to ListView */
228 LoadStringW(hInst
, IDS_APP_NAME
, szText
, sizeof(szText
) / sizeof(WCHAR
));
229 ListViewAddColumn(0, szText
, 200, LVCFMT_LEFT
);
231 LoadStringW(hInst
, IDS_APP_INST_VERSION
, szText
, sizeof(szText
) / sizeof(WCHAR
));
232 ListViewAddColumn(1, szText
, 90, LVCFMT_RIGHT
);
234 LoadStringW(hInst
, IDS_APP_DESCRIPTION
, szText
, sizeof(szText
) / sizeof(WCHAR
));
235 ListViewAddColumn(3, szText
, 250, LVCFMT_LEFT
);
237 UpdateApplicationsList(ENUM_ALL_COMPONENTS
);
241 AddCategory(HTREEITEM hRootItem
, UINT TextIndex
, UINT IconIndex
)
243 WCHAR szText
[MAX_STR_LEN
];
247 hIcon
= LoadImage(hInst
,
248 MAKEINTRESOURCE(IconIndex
),
252 LR_CREATEDIBSECTION
);
254 Index
= ImageList_AddIcon(hImageTreeView
, hIcon
);
257 LoadStringW(hInst
, TextIndex
, szText
, sizeof(szText
) / sizeof(TCHAR
));
259 return TreeViewAddItem(hRootItem
, szText
, Index
, Index
, TextIndex
);
263 InitCategoriesList(VOID
)
265 HTREEITEM hRootItem1
, hRootItem2
;
267 /* Create image list */
268 hImageTreeView
= ImageList_Create(TREEVIEW_ICON_SIZE
,
270 GetSystemColorDepth() | ILC_MASK
,
273 hRootItem1
= AddCategory(TVI_ROOT
, IDS_INSTALLED
, IDI_CATEGORY
);
274 AddCategory(hRootItem1
, IDS_APPLICATIONS
, IDI_APPS
);
275 AddCategory(hRootItem1
, IDS_UPDATES
, IDI_APPUPD
);
277 hRootItem2
= AddCategory(TVI_ROOT
, IDS_AVAILABLEFORINST
, IDI_CATEGORY
);
278 AddCategory(hRootItem2
, IDS_CAT_AUDIO
, IDI_CAT_AUDIO
);
279 AddCategory(hRootItem2
, IDS_CAT_VIDEO
, IDI_CAT_VIDEO
);
280 AddCategory(hRootItem2
, IDS_CAT_GRAPHICS
, IDI_CAT_GRAPHICS
);
281 AddCategory(hRootItem2
, IDS_CAT_GAMES
, IDI_CAT_GAMES
);
282 AddCategory(hRootItem2
, IDS_CAT_INTERNET
, IDI_CAT_INTERNET
);
283 AddCategory(hRootItem2
, IDS_CAT_OFFICE
, IDI_CAT_OFFICE
);
284 AddCategory(hRootItem2
, IDS_CAT_DEVEL
, IDI_CAT_DEVEL
);
285 AddCategory(hRootItem2
, IDS_CAT_EDU
, IDI_CAT_EDU
);
286 AddCategory(hRootItem2
, IDS_CAT_ENGINEER
, IDI_CAT_ENGINEER
);
287 AddCategory(hRootItem2
, IDS_CAT_FINANCE
, IDI_CAT_FINANCE
);
288 AddCategory(hRootItem2
, IDS_CAT_SCIENCE
, IDI_CAT_SCIENCE
);
289 AddCategory(hRootItem2
, IDS_CAT_TOOLS
, IDI_CAT_TOOLS
);
290 AddCategory(hRootItem2
, IDS_CAT_DRIVERS
, IDI_CAT_DRIVERS
);
291 AddCategory(hRootItem2
, IDS_CAT_LIBS
, IDI_CAT_LIBS
);
292 AddCategory(hRootItem2
, IDS_CAT_OTHER
, IDI_CAT_OTHER
);
294 (VOID
) TreeView_SetImageList(hTreeView
, hImageTreeView
, TVSIL_NORMAL
);
296 (VOID
) TreeView_Expand(hTreeView
, hRootItem2
, TVE_EXPAND
);
297 (VOID
) TreeView_Expand(hTreeView
, hRootItem1
, TVE_EXPAND
);
299 (VOID
) TreeView_SelectItem(hTreeView
, hRootItem1
);
303 InitControls(HWND hwnd
)
305 if (SettingsInfo
.bSaveWndPos
)
307 MoveWindow(hwnd
, SettingsInfo
.Left
, SettingsInfo
.Top
,
308 SettingsInfo
.Right
- SettingsInfo
.Left
,
309 SettingsInfo
.Bottom
- SettingsInfo
.Top
, TRUE
);
311 if (SettingsInfo
.Maximized
) ShowWindow(hwnd
, SW_MAXIMIZE
);
314 if (CreateStatusBar(hwnd
) &&
315 CreateToolBar(hwnd
) &&
316 CreateListView(hwnd
) &&
317 CreateTreeView(hwnd
) &&
318 CreateRichEdit(hwnd
) &&
319 CreateVSplitBar(hwnd
) &&
320 CreateHSplitBar(hwnd
))
322 WCHAR szBuffer1
[MAX_STR_LEN
], szBuffer2
[MAX_STR_LEN
];
324 InitApplicationsList();
326 InitCategoriesList();
328 LoadStringW(hInst
, IDS_APPS_COUNT
, szBuffer2
, sizeof(szBuffer2
) / sizeof(WCHAR
));
329 swprintf(szBuffer1
, szBuffer2
, ListView_GetItemCount(hListView
));
330 SetStatusBarText(szBuffer1
);
338 MainWndOnCommand(HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
340 WORD wCommand
= LOWORD(wParam
);
342 if (lParam
== (LPARAM
)hSearchBar
)
344 WCHAR szBuf
[MAX_STR_LEN
];
346 switch (HIWORD(wParam
))
350 WCHAR szWndText
[MAX_STR_LEN
];
352 LoadStringW(hInst
, IDS_SEARCH_TEXT
, szBuf
, sizeof(szBuf
) / sizeof(WCHAR
));
353 GetWindowTextW(hSearchBar
, szWndText
, MAX_STR_LEN
);
354 if (wcscmp(szBuf
, szWndText
) == 0) SetWindowTextW(hSearchBar
, L
"");
360 GetWindowTextW(hSearchBar
, szBuf
, MAX_STR_LEN
);
361 if (wcslen(szBuf
) < 1)
363 LoadStringW(hInst
, IDS_SEARCH_TEXT
, szBuf
, sizeof(szBuf
) / sizeof(WCHAR
));
364 SetWindowTextW(hSearchBar
, szBuf
);
370 /* TODO: Implement search */
380 ShellExecuteW(hwnd
, L
"open", pLink
, NULL
, NULL
, SW_SHOWNOACTIVATE
);
381 HeapFree(GetProcessHeap(), 0, pLink
);
385 CopyTextToClipboard(pLink
);
386 HeapFree(GetProcessHeap(), 0, pLink
);
390 CreateSettingsDlg(hwnd
);
394 PostMessageW(hwnd
, WM_CLOSE
, 0, 0);
398 if (DownloadApplication(-1))
399 /* TODO: Implement install dialog
400 * if (InstallApplication(-1))
402 UpdateApplicationsList(-1);
406 if (UninstallApplication(-1, FALSE
))
407 UpdateApplicationsList(-1);
411 if (UninstallApplication(-1, TRUE
))
412 UpdateApplicationsList(-1);
416 RemoveAppFromRegistry(-1);
420 UpdateApplicationsList(-1);
424 MessageBoxW(hwnd
, L
"Help not implemented yet", NULL
, MB_OK
);
434 MainWndOnSize(HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
436 HDWP hdwp
= BeginDeferWindowPos(5);
437 INT SearchBarWidth
= GetWindowWidth(hSearchBar
);
438 INT RichPos
= GetWindowHeight(hRichEdit
);
439 INT NewPos
= HIWORD(lParam
) - (RichPos
+ SPLIT_WIDTH
+ GetWindowHeight(hStatusBar
));
442 /* Size status bar */
443 SendMessage(hStatusBar
, WM_SIZE
, 0, 0);
446 SendMessage(hToolBar
, TB_AUTOSIZE
, 0, 0);
449 MoveWindow(hSearchBar
, LOWORD(lParam
) - SearchBarWidth
- 4, 5, SearchBarWidth
, 22, TRUE
);
452 * HIWORD(lParam) - Height of main window
453 * LOWORD(lParam) - Width of main window
456 /* Size vertical splitter bar */
460 (VSplitterPos
= GetWindowWidth(hTreeView
)),
461 GetWindowHeight(hToolBar
),
463 HIWORD(lParam
) - GetWindowHeight(hToolBar
) - GetWindowHeight(hStatusBar
),
464 SWP_NOZORDER
|SWP_NOACTIVATE
);
471 GetWindowHeight(hToolBar
),
473 HIWORD(lParam
) - GetWindowHeight(hToolBar
) - GetWindowHeight(hStatusBar
),
474 SWP_NOZORDER
|SWP_NOACTIVATE
);
476 while (NewPos
< SPLIT_WIDTH
+ GetWindowHeight(hToolBar
))
479 NewPos
= HIWORD(lParam
) - (RichPos
+
480 SPLIT_WIDTH
+ GetWindowHeight(hStatusBar
));
482 SetHSplitterPos(NewPos
);
488 VSplitterPos
+ SPLIT_WIDTH
,
489 GetWindowHeight(hToolBar
),
490 LOWORD(lParam
) - (VSplitterPos
+ SPLIT_WIDTH
),
491 GetHSplitterPos() - GetWindowHeight(hToolBar
),
492 SWP_NOZORDER
|SWP_NOACTIVATE
);
498 VSplitterPos
+ SPLIT_WIDTH
,
499 GetHSplitterPos() + SPLIT_WIDTH
,
500 LOWORD(lParam
) - (VSplitterPos
+ SPLIT_WIDTH
),
502 SWP_NOZORDER
|SWP_NOACTIVATE
);
504 /* Size horizontal splitter bar */
508 VSplitterPos
+ SPLIT_WIDTH
,
510 LOWORD(lParam
) - (VSplitterPos
+ SPLIT_WIDTH
),
512 SWP_NOZORDER
|SWP_NOACTIVATE
);
514 EndDeferWindowPos(hdwp
);
518 MainWindowProc(HWND hwnd
, UINT Msg
, WPARAM wParam
, LPARAM lParam
)
523 if (!InitControls(hwnd
))
524 PostMessage(hwnd
, WM_CLOSE
, 0, 0);
526 if (SettingsInfo
.bUpdateAtStart
)
531 MainWndOnCommand(hwnd
, wParam
, lParam
);
536 LPNMHDR data
= (LPNMHDR
)lParam
;
542 if (data
->hwndFrom
== hTreeView
)
544 switch (((LPNMTREEVIEW
)lParam
)->itemNew
.lParam
)
547 UpdateApplicationsList(ENUM_ALL_COMPONENTS
);
550 case IDS_APPLICATIONS
:
551 UpdateApplicationsList(ENUM_APPLICATIONS
);
555 UpdateApplicationsList(ENUM_UPDATES
);
558 case IDS_AVAILABLEFORINST
:
559 UpdateApplicationsList(ENUM_ALL_AVAILABLE
);
563 UpdateApplicationsList(ENUM_CAT_AUDIO
);
567 UpdateApplicationsList(ENUM_CAT_DEVEL
);
570 case IDS_CAT_DRIVERS
:
571 UpdateApplicationsList(ENUM_CAT_DRIVERS
);
575 UpdateApplicationsList(ENUM_CAT_EDU
);
578 case IDS_CAT_ENGINEER
:
579 UpdateApplicationsList(ENUM_CAT_ENGINEER
);
582 case IDS_CAT_FINANCE
:
583 UpdateApplicationsList(ENUM_CAT_FINANCE
);
587 UpdateApplicationsList(ENUM_CAT_GAMES
);
590 case IDS_CAT_GRAPHICS
:
591 UpdateApplicationsList(ENUM_CAT_GRAPHICS
);
594 case IDS_CAT_INTERNET
:
595 UpdateApplicationsList(ENUM_CAT_INTERNET
);
599 UpdateApplicationsList(ENUM_CAT_LIBS
);
603 UpdateApplicationsList(ENUM_CAT_OFFICE
);
607 UpdateApplicationsList(ENUM_CAT_OTHER
);
610 case IDS_CAT_SCIENCE
:
611 UpdateApplicationsList(ENUM_CAT_SCIENCE
);
615 UpdateApplicationsList(ENUM_CAT_TOOLS
);
619 UpdateApplicationsList(ENUM_CAT_VIDEO
);
628 LPNMLVKEYDOWN pnkd
= (LPNMLVKEYDOWN
) lParam
;
630 if (pnkd
->hdr
.hwndFrom
== hListView
)
632 INT ItemIndex
= (INT
) SendMessage(hListView
, LVM_GETNEXTITEM
, -1, LVNI_FOCUSED
);
634 if (pnkd
->wVKey
== VK_UP
) ItemIndex
-= 1;
635 if (pnkd
->wVKey
== VK_DOWN
) ItemIndex
+= 1;
637 if (IS_INSTALLED_ENUM(SelectedEnumType
))
638 ShowInstalledAppInfo(ItemIndex
);
639 if (IS_AVAILABLE_ENUM(SelectedEnumType
))
640 ShowAvailableAppInfo(ItemIndex
);
645 case LVN_COLUMNCLICK
:
647 LPNMLISTVIEW pnmv
= (LPNMLISTVIEW
) lParam
;
649 (VOID
) ListView_SortItems(hListView
, ListViewCompareFunc
, pnmv
->iSubItem
);
650 bAscending
= !bAscending
;
655 if (data
->hwndFrom
== hListView
)
657 if (IS_INSTALLED_ENUM(SelectedEnumType
))
658 ShowInstalledAppInfo(-1);
659 if (IS_AVAILABLE_ENUM(SelectedEnumType
))
660 ShowAvailableAppInfo(-1);
665 if (data
->hwndFrom
== hListView
)
666 ShowPopupMenu(hListView
, IDR_APPLICATIONMENU
);
670 RichEditOnLink(hwnd
, (ENLINK
*)lParam
);
673 case TTN_GETDISPINFO
:
674 ToolBarOnGetDispInfo((LPTOOLTIPTEXT
)lParam
);
685 if ((GetClientWindowHeight(hMainWnd
) - GetWindowHeight(hStatusBar
) - SPLIT_WIDTH
) < GetHSplitterPos())
687 INT NewSplitPos
= GetClientWindowHeight(hwnd
) - 100 - GetWindowHeight(hStatusBar
) - SPLIT_WIDTH
;
688 if (NewSplitPos
> GetWindowHeight(hToolBar
) + SPLIT_WIDTH
)
689 SetHSplitterPos(NewSplitPos
);
692 MainWndOnSize(hwnd
, wParam
, lParam
);
698 int RichEditHeight
= GetWindowHeight(hRichEdit
);
699 LPRECT pRect
= (LPRECT
)lParam
;
701 while (RichEditHeight
<= 100)
703 if (GetHSplitterPos() - 1 < GetWindowHeight(hToolBar
) + GetWindowHeight(hListView
) + SPLIT_WIDTH
)
705 SetHSplitterPos(GetHSplitterPos() - 1);
709 if (pRect
->right
-pRect
->left
< 565)
710 pRect
->right
= pRect
->left
+ 565;
712 if (pRect
->bottom
-pRect
->top
< 300)
713 pRect
->bottom
= pRect
->top
+ 300;
719 ShowWindow(hwnd
, SW_HIDE
);
724 if (IS_AVAILABLE_ENUM(SelectedEnumType
))
725 FreeAvailableAppList();
726 if (IS_INSTALLED_ENUM(SelectedEnumType
))
727 FreeInstalledAppList();
728 if (hImageListView
) ImageList_Destroy(hImageListView
);
729 if (hImageTreeView
) ImageList_Destroy(hImageTreeView
);
737 return DefWindowProc(hwnd
, Msg
, wParam
, lParam
);
741 wWinMain(HINSTANCE hInstance
, HINSTANCE hPrevInstance
, LPWSTR lpCmdLine
, int nShowCmd
)
743 WNDCLASSEXW WndClass
= {0};
744 WCHAR szWindowClass
[] = L
"ROSAPPMGR";
745 WCHAR szWindowName
[MAX_STR_LEN
];
746 WCHAR szErrorText
[MAX_STR_LEN
];
747 HANDLE hMutex
= NULL
;
752 if (!IsUserAnAdmin())
754 LoadStringW(hInst
, IDS_USER_NOT_ADMIN
, szErrorText
, sizeof(szErrorText
) / sizeof(WCHAR
));
755 MessageBox(0, szErrorText
, NULL
, MB_OK
| MB_ICONWARNING
);
759 hMutex
= CreateMutexW(NULL
, FALSE
, szWindowClass
);
760 if ((!hMutex
) || (GetLastError() == ERROR_ALREADY_EXISTS
))
762 /* If already started, it is found its window */
763 HWND hWindow
= FindWindowW(szWindowClass
, NULL
);
765 /* Activate window */
766 ShowWindow(hWindow
, SW_SHOWNORMAL
);
767 SetForegroundWindow(hWindow
);
773 FillDafaultSettings(&SettingsInfo
);
778 InitCommonControls();
780 /* Create the window */
781 WndClass
.cbSize
= sizeof(WNDCLASSEXW
);
782 WndClass
.lpszClassName
= szWindowClass
;
783 WndClass
.lpfnWndProc
= MainWindowProc
;
784 WndClass
.hInstance
= hInstance
;
785 WndClass
.style
= CS_HREDRAW
| CS_VREDRAW
;
786 WndClass
.hIcon
= LoadIcon(hInstance
, MAKEINTRESOURCE(IDI_MAIN
));
787 WndClass
.hCursor
= LoadCursor(NULL
, IDC_ARROW
);
788 WndClass
.hbrBackground
= (HBRUSH
)(COLOR_BTNFACE
+ 1);
789 WndClass
.lpszMenuName
= MAKEINTRESOURCEW(IDR_MAINMENU
);
791 if (RegisterClassExW(&WndClass
) == (ATOM
)0) goto Exit
;
793 LoadStringW(hInst
, IDS_APPTITLE
, szWindowName
, sizeof(szWindowName
) / sizeof(WCHAR
));
795 hMainWnd
= CreateWindowExW(WS_EX_WINDOWEDGE
,
798 WS_OVERLAPPEDWINDOW
| WS_CLIPCHILDREN
| WS_CLIPSIBLINGS
,
808 if (!hMainWnd
) goto Exit
;
811 ShowWindow(hMainWnd
, SW_SHOW
);
812 UpdateWindow(hMainWnd
);
815 while (GetMessage(&Msg
, NULL
, 0, 0))
817 TranslateMessage(&Msg
);
818 DispatchMessage(&Msg
);
822 if (hMutex
) CloseHandle(hMutex
);