Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * PROJECT: ReactOS Simple Program
- * LICENSE: GPL-2.0+ (https://spdx.org/licenses/GPL-2.0+)
- * PURPOSE: Main file code
- * COPYRIGHT: Copyright ??? (???)
- */
- /* INCLUDES *******************************************************************/
- #include "precomp.h"
- /* GLOBALS ********************************************************************/
- HINSTANCE hGlobalInstance = NULL;
- HICON hIcon = NULL;
- /* FUNCTIONS ******************************************************************/
- BOOL
- DlgInitHandler(_In_ HWND hDlg)
- {
- INT PosX, PosY;
- RECT Rect;
- WCHAR szAppPath[MAX_BUFFER];
- /* Center the dialog on the screen */
- GetWindowRect(hDlg, &Rect);
- PosX = (GetSystemMetrics(SM_CXSCREEN) - Rect.right) / 2;
- PosY = (GetSystemMetrics(SM_CYSCREEN) - Rect.bottom) / 2;
- SetWindowPos(hDlg, 0, PosX, PosY, 0, 0, SWP_NOZORDER | SWP_NOSIZE);
- /* Extract the icon resource from the executable process */
- GetModuleFileNameW(NULL, szAppPath, _countof(szAppPath));
- hIcon = ExtractIconW(hGlobalInstance, szAppPath, 0);
- /* Set the icon within the dialog's title bar */
- if (hIcon)
- {
- SendMessageW(hDlg, WM_SETICON, ICON_SMALL, (LPARAM)hIcon);
- }
- return TRUE;
- }
- INT_PTR CALLBACK
- DlgProc(
- _In_ HWND hDlg,
- _In_ UINT Msg,
- _In_ WPARAM wParam,
- _In_ LPARAM lParam)
- {
- switch (Msg)
- {
- case WM_INITDIALOG:
- return DlgInitHandler(hDlg);
- case WM_CLOSE:
- DestroyIcon(hIcon);
- EndDialog(hDlg, FALSE);
- break;
- case WM_COMMAND:
- {
- switch (LOWORD(wParam))
- {
- case IDC_SIMPLE_BUTTON:
- DestroyIcon(hIcon);
- EndDialog(hDlg, FALSE);
- break;
- default:
- break;
- }
- break;
- }
- }
- return 0;
- }
- int WINAPI
- wWinMain(
- _In_ HINSTANCE hInstance,
- _In_ HINSTANCE hPrevInstance,
- _In_ LPWSTR pCmdLine,
- _In_ int nCmdShow)
- {
- UNREFERENCED_PARAMETER(hPrevInstance);
- UNREFERENCED_PARAMETER(pCmdLine);
- UNREFERENCED_PARAMETER(nCmdShow);
- /* Cache the handle instance of our program */
- hGlobalInstance = hInstance;
- /* Create the dialog box */
- DialogBoxW(
- hInstance,
- MAKEINTRESOURCEW(IDD_SIMPLE_DIALOG),
- GetDesktopWindow(),
- DlgProc);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement