From 93ca902e1ffcf29616393a7428a9fa76d9caf8f0 Mon Sep 17 00:00:00 2001 From: Brady McDermott Date: Sat, 19 Oct 2024 23:24:53 -0600 Subject: [PATCH] add: startup sound when set as default shell rename global variables for easier identification --- progmgr/dialog.c | 20 ++++++------ progmgr/group.c | 22 ++++++------- progmgr/progmgr.c | 78 +++++++++++++++++++++++----------------------- progmgr/progmgr.h | 27 ++++++++-------- progmgr/registry.c | 10 +++--- progmgr/wndproc.c | 30 ++++++++++-------- 6 files changed, 96 insertions(+), 91 deletions(-) diff --git a/progmgr/dialog.c b/progmgr/dialog.c index 4517205..2b3752c 100644 --- a/progmgr/dialog.c +++ b/progmgr/dialog.c @@ -60,18 +60,18 @@ BOOL CALLBACK NewGroupDlgProc(HWND hWndDlg, UINT message, WPARAM wParam, LPARAM // grp.pItemArray = 0; TODO: idk make sure this ain't all screwed up // Set the window title - LoadString(hAppInstance, IDS_DLT_GRP_NEW, szDlgTitle, ARRAYSIZE(szDlgTitle)); + LoadString(g_hAppInstance, IDS_DLT_GRP_NEW, szDlgTitle, ARRAYSIZE(szDlgTitle)); SetWindowText(hWndDlg, szDlgTitle); // Populate the icon with the default path and index. - GetModuleFileName(hAppInstance, (LPWSTR)&grp.szIconPath, ARRAYSIZE(grp.szIconPath)); + GetModuleFileName(g_hAppInstance, (LPWSTR)&grp.szIconPath, ARRAYSIZE(grp.szIconPath)); grp.iIconIndex = IDI_PROGGRP - 1; // Get the default hIcon so we can delete it later hIconDef = (HICON)SendDlgItemMessage(hWndDlg, IDD_STAT_ICON, STM_GETICON, 0, 0); // Set the icon in the dialog - hIconDlg = ExtractIcon(hAppInstance, (LPWSTR)&grp.szIconPath, grp.iIconIndex); + hIconDlg = ExtractIcon(g_hAppInstance, (LPWSTR)&grp.szIconPath, grp.iIconIndex); SendDlgItemMessage(hWndDlg, IDD_STAT_ICON, STM_SETICON, (WPARAM)hIconDlg, 0); // Set the maximum input length of the text boxes @@ -81,7 +81,7 @@ BOOL CALLBACK NewGroupDlgProc(HWND hWndDlg, UINT message, WPARAM wParam, LPARAM EnableWindow(GetDlgItem(hWndDlg, IDD_OK), bOKEnabled); // Enable the common group checkbox if perms are good - EnableWindow(GetDlgItem(hWndDlg, IDD_COMMGROUP), bPermAdmin); + EnableWindow(GetDlgItem(hWndDlg, IDD_COMMGROUP), g_bPermAdmin); break; @@ -106,7 +106,7 @@ BOOL CALLBACK NewGroupDlgProc(HWND hWndDlg, UINT message, WPARAM wParam, LPARAM if (PickIconDlg(hWndDlg, (LPWSTR)&grp.szIconPath, ARRAYSIZE(grp.szIconPath), &grp.iIconIndex) == TRUE) { // Since we've got the new icon... - hIconDlg = ExtractIcon(hAppInstance, (LPWSTR)&grp.szIconPath, grp.iIconIndex); + hIconDlg = ExtractIcon(g_hAppInstance, (LPWSTR)&grp.szIconPath, grp.iIconIndex); SendDlgItemMessage(hWndDlg, IDD_STAT_ICON, STM_SETICON, (WPARAM)hIconDlg, 0); } @@ -202,7 +202,7 @@ BOOL CALLBACK NewItemDlgProc(HWND hWndDlg, UINT message, WPARAM wParam, LPARAM l itm.uiHotkeyVirtualKey = 0; // Set the window title - LoadString(hAppInstance, IDS_DLT_ITEM_NEW, szDlgTitle, ARRAYSIZE(szDlgTitle)); + LoadString(g_hAppInstance, IDS_DLT_ITEM_NEW, szDlgTitle, ARRAYSIZE(szDlgTitle)); SetWindowText(hWndDlg, szDlgTitle); // Populate the icon with the default path and index. @@ -213,7 +213,7 @@ BOOL CALLBACK NewItemDlgProc(HWND hWndDlg, UINT message, WPARAM wParam, LPARAM l hIconDef = (HICON)SendDlgItemMessage(hWndDlg, IDD_STAT_ICON, STM_GETICON, 0, 0); // Set the icon in the dialog - hIconDlg = ExtractIcon(hAppInstance, (LPWSTR)&itm.szIconPath, itm.iIconIndex); + hIconDlg = ExtractIcon(g_hAppInstance, (LPWSTR)&itm.szIconPath, itm.iIconIndex); SendDlgItemMessage(hWndDlg, IDD_STAT_ICON, STM_SETICON, (WPARAM)hIconDlg, 0); // Set the maximum input length of the text boxes @@ -314,14 +314,14 @@ BOOL CALLBACK NewItemDlgProc(HWND hWndDlg, UINT message, WPARAM wParam, LPARAM l SetDlgItemText(hWndDlg, IDD_NAME, (LPWSTR)szNameBuffer); // let's get the icon now - if (ExtractIcon(hAppInstance, (LPWSTR)szFileBuffer, -1) > 0) + if (ExtractIcon(g_hAppInstance, (LPWSTR)szFileBuffer, -1) > 0) { // file contains at least one icon, set the itm struct values StringCchCopy(itm.szIconPath, ARRAYSIZE(itm.szIconPath), szFileBuffer); itm.iIconIndex = 0; // update icon - hIconDlg = ExtractIcon(hAppInstance, (LPWSTR)itm.szIconPath, itm.iIconIndex); + hIconDlg = ExtractIcon(g_hAppInstance, (LPWSTR)itm.szIconPath, itm.iIconIndex); SendDlgItemMessage(hWndDlg, IDD_STAT_ICON, STM_SETICON, (WPARAM)hIconDlg, 0); } @@ -360,7 +360,7 @@ BOOL CALLBACK NewItemDlgProc(HWND hWndDlg, UINT message, WPARAM wParam, LPARAM l if (PickIconDlg(hWndDlg, (LPWSTR)&itm.szIconPath, ARRAYSIZE(itm.szIconPath), &itm.iIconIndex) == TRUE) { // Since we've got the new icon... - hIconDlg = ExtractIcon(hAppInstance, (LPWSTR)itm.szIconPath, itm.iIconIndex); + hIconDlg = ExtractIcon(g_hAppInstance, (LPWSTR)itm.szIconPath, itm.iIconIndex); SendDlgItemMessage(hWndDlg, IDD_STAT_ICON, STM_SETICON, (WPARAM)hIconDlg, 0); } diff --git a/progmgr/group.c b/progmgr/group.c index 57174cf..9c5a81b 100644 --- a/progmgr/group.c +++ b/progmgr/group.c @@ -43,22 +43,22 @@ BOOL InitializeGroups(VOID) RECT rcFrame; // Create the MDI Client Window - ccs.hWindowMenu = GetSubMenu(GetMenu(hWndProgMgr), 2); + ccs.hWindowMenu = GetSubMenu(GetMenu(g_hWndProgMgr), 2); ccs.idFirstChild = IDM_WINDOW_CHILDSTART; - GetClientRect(hWndProgMgr, &rcFrame); + GetClientRect(g_hWndProgMgr, &rcFrame); if ((hWndMDIClient = CreateWindowEx(WS_EX_COMPOSITED, TEXT("MDIClient"), NULL, WS_CLIPCHILDREN | WS_CHILD | WS_VSCROLL | WS_HSCROLL | WS_VISIBLE, rcFrame.left, rcFrame.top, rcFrame.right, rcFrame.bottom, - hWndProgMgr, (HMENU)1, hAppInstance, (LPWSTR)&ccs)) == NULL) + g_hWndProgMgr, (HMENU)1, g_hAppInstance, (LPWSTR)&ccs)) == NULL) { return FALSE; } // Load the group class string - LoadString(hAppInstance, IDS_GRPCLASS, + LoadString(g_hAppInstance, IDS_GRPCLASS, szGrpClass, ARRAYSIZE(szGrpClass)); // Register the group window class @@ -67,8 +67,8 @@ BOOL InitializeGroups(VOID) wce.lpfnWndProc = GroupWndProc; wce.cbClsExtra = 0; wce.cbWndExtra = 0; - wce.hInstance = hAppInstance; - wce.hIcon = hGroupIcon = LoadImage(hAppInstance, + wce.hInstance = g_hAppInstance; + wce.hIcon = g_hGroupIcon = LoadImage(g_hAppInstance, MAKEINTRESOURCE(IDI_PROGGRP), IMAGE_ICON, 0, 0, LR_DEFAULTSIZE | LR_SHARED); wce.hCursor = LoadCursor(NULL, IDC_ARROW); @@ -131,7 +131,7 @@ HWND CreateGroup(_In_ PGROUP pg) mcs.szClass = szGrpClass; mcs.szTitle = pg->szName; - mcs.hOwner = hAppInstance; + mcs.hOwner = g_hAppInstance; if ((pg->rcGroup.left == CW_USEDEFAULT) & (pg->rcGroup.right == CW_USEDEFAULT)) { mcs.x = mcs.y = mcs.cx = mcs.cy = CW_USEDEFAULT; @@ -175,7 +175,7 @@ HWND CreateGroup(_In_ PGROUP pg) WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | WS_CLIPCHILDREN | LVS_ICON | LVS_SINGLESEL | LVS_AUTOARRANGE, mcs.x, mcs.y, mcs.cx, mcs.cy, - hWndGroup, NULL, hAppInstance, NULL)) == NULL) + hWndGroup, NULL, g_hAppInstance, NULL)) == NULL) return NULL; // ((LVS_AUTOARRANGE & bAutoArrange) * LVS_AUTOARRANGE) @@ -290,7 +290,7 @@ PITEM CreateItem(_In_ HWND hWndGroup, _In_ PITEM pi) hImageList = ListView_GetImageList(hWndListView, LVSIL_NORMAL); // extract that icon son!! - hIcon = ExtractIcon(hAppInstance, (LPWSTR)pItem->szIconPath, pItem->iIconIndex); + hIcon = ExtractIcon(g_hAppInstance, (LPWSTR)pItem->szIconPath, pItem->iIconIndex); // populate the listview with the relevant information lvi.mask = LVIF_TEXT | LVIF_IMAGE | LVIF_PARAM; @@ -363,7 +363,7 @@ BOOL LoadItems(_In_ HWND hWndGroup) pItem = pGroup->pItemArray + cItemIndex; // extract that icon son!! - hIcon = ExtractIcon(hAppInstance, (LPWSTR)pItem->szIconPath, pItem->iIconIndex); + hIcon = ExtractIcon(g_hAppInstance, (LPWSTR)pItem->szIconPath, pItem->iIconIndex); // populate the listview with the relevant information lvi.mask = LVIF_TEXT | LVIF_IMAGE | LVIF_PARAM; @@ -415,7 +415,7 @@ BOOL RemoveItem(_In_ PITEM pi) BOOL ExecuteItem(_In_ PITEM pi) { // TODO: nCmdShow from program item flags - ShellExecute(hWndProgMgr, TEXT("open"), + ShellExecute(g_hWndProgMgr, TEXT("open"), pi->szExecPath, NULL, (pi->szWorkPath != TEXT("")) ? pi->szWorkPath : NULL, SW_NORMAL); diff --git a/progmgr/progmgr.c b/progmgr/progmgr.c index 191144f..190ad89 100644 --- a/progmgr/progmgr.c +++ b/progmgr/progmgr.c @@ -19,27 +19,27 @@ /* Variables */ // Global #ifdef _DEBUG -BOOL bIsDebugBuild = TRUE; +BOOL g_bIsDebugBuild = TRUE; #else -BOOL bIsDebugBuild = FALSE; +BOOL g_bIsDebugBuild = FALSE; #endif -BOOL bIsDefaultShell = FALSE; +BOOL g_bIsDefaultShell = FALSE; // Handles -HINSTANCE hAppInstance; -HANDLE hAppHeap; -HWND hWndProgMgr = NULL; +HINSTANCE g_hAppInstance; +HANDLE g_hAppHeap; +HWND g_hWndProgMgr = NULL; // Icons -HICON hProgMgrIcon = NULL; -HICON hGroupIcon = NULL; +HICON g_hProgMgrIcon = NULL; +HICON g_hGroupIcon = NULL; // Global Strings -WCHAR szAppTitle[64]; -WCHAR szProgMgr[] = TEXT("progmgr"); -WCHAR szWebsite[64]; -WCHAR szClass[16]; +WCHAR g_szAppTitle[64]; +WCHAR g_szProgMgr[] = TEXT("progmgr"); +WCHAR g_szWebsite[64]; +WCHAR g_szClass[16]; // Permissions -BOOL bPermAdmin; // Has Administrator permissions -BOOL bPermGuest; // Has Guest permissions -BOOL bPermPower; // Has power option permissions +BOOL g_bPermAdmin; // Has Administrator permissions +BOOL g_bPermGuest; // Has Guest permissions +BOOL g_bPermPower; // Has power option permissions /* Functions */ @@ -54,9 +54,9 @@ BOOL bPermPower; // Has power option permissions BOOL UpdatePermissions(VOID) { // SE_SHUTDOWN_NAME - bPermAdmin = FALSE; - bPermGuest = FALSE; - bPermPower = FALSE; + g_bPermAdmin = FALSE; + g_bPermGuest = FALSE; + g_bPermPower = FALSE; return FALSE; } @@ -76,35 +76,35 @@ int WINAPI wWinMain(_In_ HINSTANCE hInstance, _In_opt_ HINSTANCE hPrevInstance, POINT ptOffset = { 0 }; // Initialize the instance - hAppInstance = hInstance; + g_hAppInstance = hInstance; // Create our global heap handle - hAppHeap = GetProcessHeap(); + g_hAppHeap = GetProcessHeap(); // Create Strings - LoadString(hAppInstance, IDS_PMCLASS, szClass, ARRAYSIZE(szClass)); - LoadString(hAppInstance, IDS_APPTITLE, szAppTitle, ARRAYSIZE(szAppTitle)); - LoadString(hAppInstance, IDS_WEBSITE, szWebsite, ARRAYSIZE(szWebsite)); + LoadString(g_hAppInstance, IDS_PMCLASS, g_szClass, ARRAYSIZE(g_szClass)); + LoadString(g_hAppInstance, IDS_APPTITLE, g_szAppTitle, ARRAYSIZE(g_szAppTitle)); + LoadString(g_hAppInstance, IDS_WEBSITE, g_szWebsite, ARRAYSIZE(g_szWebsite)); // Get Desktop background color //CreateSolidBrush(GetBackgroundColor // Register the Frame Window Class wc.lpfnWndProc = WndProc; - wc.hInstance = hAppInstance; - wc.hIcon = hProgMgrIcon = LoadImage(hAppInstance, MAKEINTRESOURCE(IDI_PROGMGR), IMAGE_ICON, + wc.hInstance = g_hAppInstance; + wc.hIcon = g_hProgMgrIcon = LoadImage(g_hAppInstance, MAKEINTRESOURCE(IDI_PROGMGR), IMAGE_ICON, 0, 0, LR_DEFAULTSIZE | LR_SHARED); wc.hCursor = LoadCursor(NULL, IDC_ARROW); // wc.hbrBackground = (HBRUSH)(COLOR_BACKGROUND); wc.hbrBackground = NULL; wc.lpszMenuName = MAKEINTRESOURCE(IDM_MAIN); - wc.lpszClassName = szClass; + wc.lpszClassName = g_szClass; if (!RegisterClass(&wc)) return FALSE; // Load the Accelerator table - hAccel = LoadAccelerators(hAppInstance, MAKEINTRESOURCE(IDA_ACCELS)); + hAccel = LoadAccelerators(g_hAppInstance, MAKEINTRESOURCE(IDA_ACCELS)); if (!hAccel) return FALSE; @@ -112,7 +112,7 @@ int WINAPI wWinMain(_In_ HINSTANCE hInstance, _In_opt_ HINSTANCE hPrevInstance, if (!InitializeRegistryKeys()) return FALSE; - bIsDefaultShell = IsProgMgrDefaultShell(); + g_bIsDefaultShell = IsProgMgrDefaultShell(); // Load configuration, but don't load groups yet if(LoadConfig(TRUE, TRUE, FALSE) != RCE_SUCCESS) @@ -127,23 +127,23 @@ int WINAPI wWinMain(_In_ HINSTANCE hInstance, _In_opt_ HINSTANCE hPrevInstance, // Create main window with a default size // TODO: i pulled 320x240 out of my ass, make this dynamic later - if ((hWndProgMgr = CreateWindowW(wc.lpszClassName, szAppTitle, + if ((g_hWndProgMgr = CreateWindowW(wc.lpszClassName, g_szAppTitle, WS_OVERLAPPEDWINDOW | WS_VISIBLE, rcRoot.left + ptOffset.x, rcRoot.top + ptOffset.y, rcRoot.left + ptOffset.x + 320, rcRoot.top + ptOffset.y + 240, - 0, 0, hAppInstance, NULL)) == NULL) + 0, 0, g_hAppInstance, NULL)) == NULL) return 2; // Set the window size from the registry, but only if the coords make sense if ((rcMainWindow.left != rcMainWindow.right) && (rcMainWindow.top != rcMainWindow.bottom)) - SetWindowPos(hWndProgMgr, NULL, + SetWindowPos(g_hWndProgMgr, NULL, rcMainWindow.left, rcMainWindow.top, rcMainWindow.right - rcMainWindow.left, rcMainWindow.bottom - rcMainWindow.top, SWP_NOZORDER); // Load the menus... - hMenu = GetMenu(hWndProgMgr); - hSystemMenu = GetSystemMenu(hWndProgMgr, FALSE); + hMenu = GetMenu(g_hWndProgMgr); + hSystemMenu = GetSystemMenu(g_hWndProgMgr, FALSE); // Update relevant parts of the window UpdateChecks(bAutoArrange, IDM_OPTIONS, IDM_OPTIONS_AUTOARRANGE); @@ -156,21 +156,21 @@ int WINAPI wWinMain(_In_ HINSTANCE hInstance, _In_opt_ HINSTANCE hPrevInstance, // Update settings based on their values if (bTopMost) - SetWindowPos(hWndProgMgr, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE); + SetWindowPos(g_hWndProgMgr, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE); - if (bIsDefaultShell) + if (g_bIsDefaultShell) { // Modify the context menus since we're the default shell DeleteMenu(hSystemMenu, SC_CLOSE, MF_BYCOMMAND); - LoadString(hAppInstance, IDS_SHUTDOWN, szBuffer, ARRAYSIZE(szBuffer)); + LoadString(g_hAppInstance, IDS_SHUTDOWN, szBuffer, ARRAYSIZE(szBuffer)); InsertMenu(hSystemMenu, 6, MF_BYPOSITION | MF_STRING, IDM_SHUTDOWN, szBuffer); ModifyMenu(hMenu, IDM_FILE_EXIT, MF_BYCOMMAND | MF_STRING, IDM_SHUTDOWN, szBuffer); - LoadString(hAppInstance, IDS_RUN, szBuffer, ARRAYSIZE(szBuffer)); + LoadString(g_hAppInstance, IDS_RUN, szBuffer, ARRAYSIZE(szBuffer)); InsertMenu(hSystemMenu, 6, MF_BYPOSITION | MF_STRING, IDM_FILE_RUN, szBuffer); - LoadString(hAppInstance, IDS_TASKMGR, szBuffer, ARRAYSIZE(szBuffer)); + LoadString(g_hAppInstance, IDS_TASKMGR, szBuffer, ARRAYSIZE(szBuffer)); InsertMenu(hSystemMenu, 6, MF_BYPOSITION | MF_STRING, IDM_TASKMGR, szBuffer); // Create the desktop window... @@ -184,7 +184,7 @@ int WINAPI wWinMain(_In_ HINSTANCE hInstance, _In_opt_ HINSTANCE hPrevInstance, while (GetMessage(&msg, NULL, 0, 0) > 0) { if (!TranslateMDISysAccel(hWndMDIClient, &msg) && - !TranslateAccelerator(hWndProgMgr, hAccel, &msg)) + !TranslateAccelerator(g_hWndProgMgr, hAccel, &msg)) { DispatchMessage(&msg); } diff --git a/progmgr/progmgr.h b/progmgr/progmgr.h index 0d6ecc3..ffce891 100644 --- a/progmgr/progmgr.h +++ b/progmgr/progmgr.h @@ -15,6 +15,7 @@ #pragma comment(lib, "Secur32.lib") #pragma comment(lib, "UxTheme.lib") #pragma comment(lib, "Version.lib") +#pragma comment(lib, "Winmm.lib") /* Macros and Defines */ #define GET_WM_COMMAND_ID(wParam, lParam) LOWORD(wParam) @@ -30,23 +31,23 @@ #define RF_RETRY 0x0002 // Cancel the operation, but leave the dialog open /* Global Variables */ -extern BOOL bIsDefaultShell; +extern BOOL g_bIsDefaultShell; // Handles -extern HINSTANCE hAppInstance; -extern HANDLE hAppHeap; -extern HWND hWndProgMgr; +extern HINSTANCE g_hAppInstance; +extern HANDLE g_hAppHeap; +extern HWND g_hWndProgMgr; // Icons -extern HICON hProgMgrIcon; -extern HICON hGroupIcon; +extern HICON g_hProgMgrIcon; +extern HICON g_hGroupIcon; // Strings -extern WCHAR szAppTitle[64]; -extern WCHAR szProgMgr[]; -extern WCHAR szWebsite[64]; -extern WCHAR szClass[16]; +extern WCHAR g_szAppTitle[64]; +extern WCHAR g_szProgMgr[]; +extern WCHAR g_szWebsite[64]; +extern WCHAR g_szClass[16]; // Permissions -extern BOOL bPermAdmin; // Has Administrator permissions -extern BOOL bPermGuest; // Has Guest permissions -extern BOOL bPermPower; // Has power option permissions +extern BOOL g_bPermAdmin; // Has Administrator permissions +extern BOOL g_bPermGuest; // Has Guest permissions +extern BOOL g_bPermPower; // Has power option permissions /* Function Prototypes */ BOOL UpdatePermissions(VOID); diff --git a/progmgr/registry.c b/progmgr/registry.c index 5e96411..736cc96 100644 --- a/progmgr/registry.c +++ b/progmgr/registry.c @@ -54,13 +54,13 @@ PWSTR pszSettingsMask = TEXT("SettingsMask"); \* * * */ BOOL InitializeRegistryKeys(VOID) { - if (!RegCreateKeyEx(HKEY_CURRENT_USER, PROGMGR_KEY, 0, szProgMgr, 0, + if (!RegCreateKeyEx(HKEY_CURRENT_USER, PROGMGR_KEY, 0, g_szProgMgr, 0, KEY_READ | KEY_WRITE, NULL, &hKeyProgramManager, NULL)) { // Create Program Groups and Settings keys - RegCreateKeyEx(hKeyProgramManager, pszProgramGroups, 0, szProgMgr, 0, + RegCreateKeyEx(hKeyProgramManager, pszProgramGroups, 0, g_szProgMgr, 0, KEY_READ | KEY_WRITE, NULL, &hKeyProgramGroups, NULL); - RegCreateKeyEx(hKeyProgramManager, pszSettings, 0, szProgMgr, 0, + RegCreateKeyEx(hKeyProgramManager, pszSettings, 0, g_szProgMgr, 0, KEY_READ | KEY_WRITE, NULL, &hKeySettings, NULL); return TRUE; @@ -88,7 +88,7 @@ BOOL IsProgMgrDefaultShell(VOID) if (RegQueryValueEx(hKeyWinlogon, TEXT("Shell"), 0, &dwType, (LPBYTE)szShell, &dwBufferSize) == ERROR_SUCCESS) { - if (StrStr(szShell, szProgMgr)) + if (StrStr(szShell, g_szProgMgr)) { // ProgMgr detected >:) RegCloseKey(hKeyWinlogon); @@ -170,7 +170,7 @@ DWORD SaveConfig(_In_ BOOL bSettings, _In_ BOOL bPos, _In_ BOOL bGroups, _In_ BO // Get and save window position wpProgMgr.length = sizeof(WINDOWPLACEMENT); - GetWindowPlacement(hWndProgMgr, &wpProgMgr); + GetWindowPlacement(g_hWndProgMgr, &wpProgMgr); CopyRect(&rcWindow, &wpProgMgr.rcNormalPosition); if (!RegSetValueEx(hKeySettings, pszSettingsWindow, 0, REG_BINARY, diff --git a/progmgr/wndproc.c b/progmgr/wndproc.c index 70e16eb..c3bd992 100644 --- a/progmgr/wndproc.c +++ b/progmgr/wndproc.c @@ -15,6 +15,7 @@ #include #include #include +#include #include "progmgr.h" #include "dialog.h" #include "group.h" @@ -36,6 +37,9 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) case WM_CREATE: { + // Play the logon sound. (But only if we're the default shell) + if (g_bIsDefaultShell) + PlaySound(TEXT("WindowsLogon"), NULL, SND_ALIAS | SND_ASYNC); return TRUE; } @@ -46,7 +50,7 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) { if (wParam == IDM_TASKMGR) { - ShellExecute(hWndProgMgr, TEXT("open"), TEXT("TASKMGR.EXE"), NULL, NULL, SW_NORMAL); + ShellExecute(g_hWndProgMgr, TEXT("open"), TEXT("TASKMGR.EXE"), NULL, NULL, SW_NORMAL); return 0; } @@ -67,7 +71,7 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) if (bSaveSettings) SaveConfig(TRUE, TRUE, TRUE, TRUE); - if (bIsDefaultShell && (GetShellWindow() != NULL)) + if (g_bIsDefaultShell && (GetShellWindow() != NULL)) SetShellWindow(0); PostQuitMessage(0); @@ -96,15 +100,15 @@ LRESULT CALLBACK CmdProc(HWND hWnd, WPARAM wParam, LPARAM lParam) { case IDM_SHUTDOWN: - DialogBox(hAppInstance, MAKEINTRESOURCE(DLG_POWER), hWnd, (DLGPROC)ShutdownDlgProc); + DialogBox(g_hAppInstance, MAKEINTRESOURCE(DLG_POWER), hWnd, (DLGPROC)ShutdownDlgProc); break; case IDM_FILE_NEW_GROUP: - DialogBox(hAppInstance, MAKEINTRESOURCE(DLG_GROUP), hWnd, (DLGPROC)NewGroupDlgProc); + DialogBox(g_hAppInstance, MAKEINTRESOURCE(DLG_GROUP), hWnd, (DLGPROC)NewGroupDlgProc); break; case IDM_FILE_NEW_ITEM: - DialogBox(hAppInstance, MAKEINTRESOURCE(DLG_ITEM), hWnd, (DLGPROC)NewItemDlgProc); + DialogBox(g_hAppInstance, MAKEINTRESOURCE(DLG_ITEM), hWnd, (DLGPROC)NewItemDlgProc); break; case IDM_FILE_RUN: @@ -127,7 +131,7 @@ LRESULT CALLBACK CmdProc(HWND hWnd, WPARAM wParam, LPARAM lParam) case IDM_OPTIONS_TOPMOST: bTopMost = !bTopMost; - SetWindowPos(hWndProgMgr, bTopMost ? HWND_TOPMOST : HWND_NOTOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE); + SetWindowPos(g_hWndProgMgr, bTopMost ? HWND_TOPMOST : HWND_NOTOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE); UpdateChecks(bTopMost, IDM_OPTIONS, IDM_OPTIONS_TOPMOST); goto SaveConfig; @@ -164,15 +168,15 @@ LRESULT CALLBACK CmdProc(HWND hWnd, WPARAM wParam, LPARAM lParam) break; case IDM_HELP_INDEX: - ShellExecute(NULL, TEXT("open"), szWebsite, NULL, NULL, SW_SHOWNORMAL); + ShellExecute(NULL, TEXT("open"), g_szWebsite, NULL, NULL, SW_SHOWNORMAL); break; case IDM_HELP_ABOUT: { WCHAR szTitle[40]; - LoadString(hAppInstance, IDS_APPTITLE, szTitle, ARRAYSIZE(szTitle)); - ShellAbout(hWndProgMgr, szTitle, NULL, hProgMgrIcon); + LoadString(g_hAppInstance, IDS_APPTITLE, szTitle, ARRAYSIZE(szTitle)); + ShellAbout(g_hWndProgMgr, szTitle, NULL, g_hProgMgrIcon); break; } @@ -205,7 +209,7 @@ VOID UpdateChecks(BOOL bVarMenu, UINT uSubMenu, UINT uID) { HMENU hMenu; - hMenu = GetMenu(hWndProgMgr); + hMenu = GetMenu(g_hWndProgMgr); CheckMenuItem(hMenu, uID, (WORD)(bVarMenu ? MF_CHECKED : MF_UNCHECKED)); return; @@ -222,13 +226,13 @@ VOID UpdateWindowTitle(VOID) { WCHAR szUsername[UNLEN + 1] = TEXT(""); DWORD dwUsernameLen = UNLEN; - WCHAR szWindowTitle[UNLEN + ARRAYSIZE(szAppTitle) + 4] = TEXT(""); + WCHAR szWindowTitle[UNLEN + ARRAYSIZE(g_szAppTitle) + 4] = TEXT(""); // Get user and domain name GetUserNameEx(NameSamCompatible, szUsername, &dwUsernameLen); // Add username to window title if settings permit - StringCchCopy(szWindowTitle, ARRAYSIZE(szAppTitle), szAppTitle); + StringCchCopy(szWindowTitle, ARRAYSIZE(g_szAppTitle), g_szAppTitle); if (bShowUsername) { @@ -236,7 +240,7 @@ VOID UpdateWindowTitle(VOID) StringCchCat(szWindowTitle, ARRAYSIZE(szWindowTitle), szUsername); } - SetWindowText(hWndProgMgr, (LPCWSTR)&szWindowTitle); + SetWindowText(g_hWndProgMgr, (LPCWSTR)&szWindowTitle); return; }