Skip to content

Commit

Permalink
removed menu because it looked dumb with mica
Browse files Browse the repository at this point in the history
  • Loading branch information
rounk-ctrl committed Feb 9, 2022
1 parent ff2adb7 commit 7f0df11
Show file tree
Hide file tree
Showing 5 changed files with 4 additions and 111 deletions.
110 changes: 2 additions & 108 deletions MicaForEveryone/MicaForEveryone.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,108 +64,6 @@ BOOL RtlGetVersion(OSVERSIONINFOEX* os) {
FreeLibrary(hMod);
return TRUE;
}
// processes messages related to UAH / custom menubar drawing.
// return true if handled, false to continue with normal processing in your wndproc
bool UAHDarkModeWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam, LRESULT* lr)
{
switch (message)
{
case WM_UAHDRAWMENU:
{
UAHMENU* pUDM = (UAHMENU*)lParam;
RECT rc = { 0 };

// get the menubar rect
{
MENUBARINFO mbi = { sizeof(mbi) };
GetMenuBarInfo(hWnd, OBJID_MENU, 0, &mbi);

RECT rcWindow;
GetWindowRect(hWnd, &rcWindow);

// the rcBar is offset by the window rect
rc = mbi.rcBar;
OffsetRect(&rc, -rcWindow.left, -rcWindow.top);

rc.top -= 1;
}

if (!g_menuTheme) {
g_menuTheme = OpenThemeData(hWnd, L"Menu");
}

DrawThemeBackground(g_menuTheme, pUDM->hdc, MENU_POPUPITEM, MPI_NORMAL, &rc, nullptr);

return true;
}
case WM_UAHDRAWMENUITEM:
{
UAHDRAWMENUITEM* pUDMI = (UAHDRAWMENUITEM*)lParam;

// get the menu item string
wchar_t menuString[256] = { 0 };
MENUITEMINFO mii = { sizeof(mii), MIIM_STRING };
{
mii.dwTypeData = menuString;
mii.cch = (sizeof(menuString) / 2) - 1;

GetMenuItemInfo(pUDMI->um.hmenu, pUDMI->umi.iPosition, TRUE, &mii);
}

// get the item state for drawing

DWORD dwFlags = DT_CENTER | DT_SINGLELINE | DT_VCENTER;

int iTextStateID = 0;
int iBackgroundStateID = 0;
{
if ((pUDMI->dis.itemState & ODS_INACTIVE) | (pUDMI->dis.itemState & ODS_DEFAULT)) {
// normal display
iTextStateID = MPI_NORMAL;
iBackgroundStateID = MPI_NORMAL;
}
if (pUDMI->dis.itemState & ODS_HOTLIGHT) {
// hot tracking
iTextStateID = MPI_HOT;
iBackgroundStateID = MPI_HOT;
}
if (pUDMI->dis.itemState & ODS_SELECTED) {
// clicked -- MENU_POPUPITEM has no state for this, though MENU_BARITEM does
iTextStateID = MPI_HOT;
iBackgroundStateID = MPI_HOT;
}
if ((pUDMI->dis.itemState & ODS_GRAYED) || (pUDMI->dis.itemState & ODS_DISABLED)) {
// disabled / grey text
iTextStateID = MPI_DISABLED;
iBackgroundStateID = MPI_DISABLED;
}
if (pUDMI->dis.itemState & ODS_NOACCEL) {
dwFlags |= DT_HIDEPREFIX;
}
}

if (!g_menuTheme) {
g_menuTheme = OpenThemeData(hWnd, L"Menu");
}

DrawThemeBackground(g_menuTheme, pUDMI->um.hdc, MENU_POPUPITEM, iBackgroundStateID, &pUDMI->dis.rcItem, nullptr);
DrawThemeText(g_menuTheme, pUDMI->um.hdc, MENU_POPUPITEM, iTextStateID, menuString, mii.cch, dwFlags, 0, &pUDMI->dis.rcItem);

return true;
}
case WM_THEMECHANGED:
{
if (g_menuTheme) {
CloseThemeData(g_menuTheme);
g_menuTheme = nullptr;
}
// continue processing in main wndproc
return false;
}
default:
return false;
}
}
int APIENTRY wWinMain(_In_ HINSTANCE hInstance, _In_opt_ HINSTANCE hPrevInstance, _In_ LPWSTR lpCmdLine, _In_ int nCmdShow)
{
UNREFERENCED_PARAMETER(hPrevInstance);
Expand Down Expand Up @@ -218,7 +116,7 @@ ATOM MyRegisterClass(HINSTANCE hInstance)
wcex.hIcon = LoadIcon(hInstance, MAKEINTRESOURCE(IDI_MICAFOREVERYONE));
wcex.hCursor = LoadCursor(nullptr, IDC_ARROW);
wcex.hbrBackground = (HBRUSH)(COLOR_WINDOW+1);
wcex.lpszMenuName = MAKEINTRESOURCE(IDR_MENU1);
wcex.lpszMenuName = NULL;
wcex.lpszClassName = szWindowClass;
wcex.hIconSm = LoadIcon(wcex.hInstance, MAKEINTRESOURCE(IDI_MICAFOREVERYONE));

Expand Down Expand Up @@ -325,7 +223,7 @@ void ShowContextMenu(HWND hwnd, POINT pt)
if (os.dwBuildNumber == 22000)
{
EnableMenuItem(hSubMenu, IDM_MICA, MF_ENABLED);
EnableMenuItem(hSubMenu, IDM_ACRYLIC, MF_GRAYED);
EnableMenuItem(hSubMenu, IDM_ACRYLIC, MF_ENABLED);
EnableMenuItem(hSubMenu, IDM_TABBED, MF_GRAYED);
}
if (os.dwBuildNumber >= 22494)
Expand Down Expand Up @@ -618,10 +516,6 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
HBRUSH brush = CreateSolidBrush(darkBkColor);
RtlGetVersion(&os);
static UINT s_uTaskbarRestart;
LRESULT lr = 0;
if (UAHDarkModeWndProc(hWnd, message, wParam, lParam, &lr)) {
return lr;
}
switch (message)
{
case WM_CREATE:
Expand Down
2 changes: 1 addition & 1 deletion MicaForEveryone/MicaForEveryone.h
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ OSVERSIONINFOEX os;
UINT menuItemId = 0;

// Dark mode text and background color
constexpr COLORREF darkBkColor = 0x202020;
constexpr COLORREF darkBkColor = 0x000000;
constexpr COLORREF darkTextColor = 0xFFFFFF;

// icon
Expand Down
Binary file modified MicaForEveryone/MicaForEveryone.rc
Binary file not shown.
1 change: 1 addition & 0 deletions MicaForEveryone/MicaForEveryone.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,7 @@
<GenerateDebugInformation>true</GenerateDebugInformation>
<AdditionalDependencies>kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;dwmapi.lib;uxtheme.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalManifestDependencies>"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='*' publicKeyToken='6595b64144ccf1df' language='*'"</AdditionalManifestDependencies>
<UACUIAccess>false</UACUIAccess>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
Expand Down
2 changes: 0 additions & 2 deletions MicaForEveryone/resource.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
#define IDI_SMALL 108
#define IDC_MICAFOREVERYONE 109
#define IDR_MAINFRAME 128
#define IDR_MENU1 130
#define IDC_SYSLINK1 1001
#define IDC_STATIC_LINK 1003
#define IDC_STATIC_GIT 1004
Expand All @@ -30,7 +29,6 @@
#define IDM_ACRYLIC 32804
#define IDM_TABBED 32805
#define IDM_GUI 32815
#define ID_HELP_ABOUT 32816
#define IDC_STATIC -1

// Next default values for new objects
Expand Down

0 comments on commit 7f0df11

Please sign in to comment.