* Several changes to the Rainmeter context menu (including handle leak fix)

* Rainmeter now opens text files with associated text editor (with fallback to Notepad) if ConfigEditor is not specifed
This commit is contained in:
Birunthan Mohanathas 2010-06-23 12:36:39 +00:00
parent 063cabe9ed
commit 38409f2d05
7 changed files with 183 additions and 170 deletions

View File

@ -28,8 +28,8 @@ LANGUAGE LANG_FINNISH, SUBLANG_DEFAULT
//
VS_VERSION_INFO VERSIONINFO
FILEVERSION 1,3,0,444
PRODUCTVERSION 1,3,0,444
FILEVERSION 1,3,0,448
PRODUCTVERSION 1,3,0,448
FILEFLAGSMASK 0x17L
#ifdef _DEBUG
FILEFLAGS 0x1L

View File

@ -37,7 +37,6 @@ BEGIN
MENUITEM "Refresh All", ID_CONTEXT_REFRESH
MENUITEM "Show Log File", ID_CONTEXT_SHOWLOGFILE
MENUITEM SEPARATOR
MENUITEM SEPARATOR
MENUITEM "Exit", ID_CONTEXT_QUIT
END
END
@ -46,74 +45,56 @@ IDR_SKIN_MENU MENU DISCARDABLE
BEGIN
POPUP "Skin Menu"
BEGIN
POPUP "Position"
POPUP "Settings"
BEGIN
MENUITEM "Stay Topmost", ID_CONTEXT_SKINMENU_VERYTOPMOST
MENUITEM "Topmost", ID_CONTEXT_SKINMENU_TOPMOST
MENUITEM "Normal", ID_CONTEXT_SKINMENU_NORMAL
MENUITEM "Bottom", ID_CONTEXT_SKINMENU_BOTTOM
MENUITEM "On Desktop", ID_CONTEXT_SKINMENU_ONDESKTOP
POPUP "Position"
BEGIN
POPUP "Display Monitor"
BEGIN
MENUITEM "Use default: Primary monitor", ID_CONTEXT_SKINMENU_MONITOR_PRIMARY
MENUITEM "@0: Virtual screen", ID_MONITOR_FIRST
MENUITEM SEPARATOR
MENUITEM SEPARATOR
MENUITEM "Auto-select based on window position", ID_CONTEXT_SKINMENU_MONITOR_AUTOSELECT
END
MENUITEM SEPARATOR
MENUITEM "Stay Topmost", ID_CONTEXT_SKINMENU_VERYTOPMOST
MENUITEM "Topmost", ID_CONTEXT_SKINMENU_TOPMOST
MENUITEM "Normal", ID_CONTEXT_SKINMENU_NORMAL
MENUITEM "Bottom", ID_CONTEXT_SKINMENU_BOTTOM
MENUITEM "On Desktop", ID_CONTEXT_SKINMENU_ONDESKTOP
MENUITEM SEPARATOR
MENUITEM "From Right", ID_CONTEXT_SKINMENU_FROMRIGHT
MENUITEM "From Bottom", ID_CONTEXT_SKINMENU_FROMBOTTOM
MENUITEM "X as Percentage", ID_CONTEXT_SKINMENU_XPERCENTAGE
MENUITEM "Y as Percentage", ID_CONTEXT_SKINMENU_YPERCENTAGE
END
POPUP "Transparency"
BEGIN
MENUITEM "0%", ID_CONTEXT_SKINMENU_TRANSPARENCY_0
MENUITEM "10%", ID_CONTEXT_SKINMENU_TRANSPARENCY_10
MENUITEM "20%", ID_CONTEXT_SKINMENU_TRANSPARENCY_20
MENUITEM "30%", ID_CONTEXT_SKINMENU_TRANSPARENCY_30
MENUITEM "40%", ID_CONTEXT_SKINMENU_TRANSPARENCY_40
MENUITEM "50%", ID_CONTEXT_SKINMENU_TRANSPARENCY_50
MENUITEM "60%", ID_CONTEXT_SKINMENU_TRANSPARENCY_60
MENUITEM "70%", ID_CONTEXT_SKINMENU_TRANSPARENCY_70
MENUITEM "80%", ID_CONTEXT_SKINMENU_TRANSPARENCY_80
MENUITEM "90%", ID_CONTEXT_SKINMENU_TRANSPARENCY_90
MENUITEM SEPARATOR
MENUITEM "Fade in", ID_CONTEXT_SKINMENU_TRANSPARENCY_FADEIN
MENUITEM "Fade out", ID_CONTEXT_SKINMENU_TRANSPARENCY_FADEOUT
END
MENUITEM SEPARATOR
MENUITEM "From Right", ID_CONTEXT_SKINMENU_FROMRIGHT
MENUITEM "From Bottom", ID_CONTEXT_SKINMENU_FROMBOTTOM
MENUITEM "X as Percentage", ID_CONTEXT_SKINMENU_XPERCENTAGE
MENUITEM "Y as Percentage", ID_CONTEXT_SKINMENU_YPERCENTAGE
MENUITEM "Hide on Mouse Over", ID_CONTEXT_SKINMENU_HIDEONMOUSE
MENUITEM "Draggable", ID_CONTEXT_SKINMENU_DRAGGABLE
MENUITEM "Save Position", ID_CONTEXT_SKINMENU_REMEMBERPOSITION
MENUITEM "Snap to Edges", ID_CONTEXT_SKINMENU_SNAPTOEDGES
MENUITEM "Click Through", ID_CONTEXT_SKINMENU_CLICKTHROUGH
MENUITEM "Keep on Screen", ID_CONTEXT_SKINMENU_KEEPONSCREEN
END
POPUP "Transparency"
BEGIN
MENUITEM "0%", ID_CONTEXT_SKINMENU_TRANSPARENCY_0
MENUITEM "10%", ID_CONTEXT_SKINMENU_TRANSPARENCY_10
MENUITEM "20%", ID_CONTEXT_SKINMENU_TRANSPARENCY_20
MENUITEM "30%", ID_CONTEXT_SKINMENU_TRANSPARENCY_30
MENUITEM "40%", ID_CONTEXT_SKINMENU_TRANSPARENCY_40
MENUITEM "50%", ID_CONTEXT_SKINMENU_TRANSPARENCY_50
MENUITEM "60%", ID_CONTEXT_SKINMENU_TRANSPARENCY_60
MENUITEM "70%", ID_CONTEXT_SKINMENU_TRANSPARENCY_70
MENUITEM "80%", ID_CONTEXT_SKINMENU_TRANSPARENCY_80
MENUITEM "90%", ID_CONTEXT_SKINMENU_TRANSPARENCY_90
MENUITEM SEPARATOR
MENUITEM "Fade in", ID_CONTEXT_SKINMENU_TRANSPARENCY_FADEIN
MENUITEM "FadeOut", ID_CONTEXT_SKINMENU_TRANSPARENCY_FADEOUT
END
MENUITEM SEPARATOR
MENUITEM "Hide on Mouse Over", ID_CONTEXT_SKINMENU_HIDEONMOUSE
MENUITEM "Draggable", ID_CONTEXT_SKINMENU_DRAGGABLE
MENUITEM "Save Position", ID_CONTEXT_SKINMENU_REMEMBERPOSITION
MENUITEM "Snap to Edges", ID_CONTEXT_SKINMENU_SNAPTOEDGES
MENUITEM "Click Through", ID_CONTEXT_SKINMENU_CLICKTHROUGH
MENUITEM "Keep on Screen", ID_CONTEXT_SKINMENU_KEEPONSCREEN
MENUITEM SEPARATOR
MENUITEM "Edit Skin...", ID_CONTEXT_SKINMENU_EDITSKIN
MENUITEM "Open Skin's folder", ID_CONTEXT_SKINMENU_OPENSKINSFOLDER
MENUITEM "Refresh Skin", ID_CONTEXT_SKINMENU_REFRESH
MENUITEM SEPARATOR
MENUITEM "Close Skin", ID_CONTEXT_CLOSESKIN

View File

@ -262,7 +262,7 @@
/>
<Tool
Name="VCLinkerTool"
AdditionalDependencies="comctl32.lib Wininet.lib Winmm.lib gdiplus.lib Iphlpapi.lib odbc32.lib odbccp32.lib"
AdditionalDependencies="comctl32.lib Wininet.lib Winmm.lib gdiplus.lib Iphlpapi.lib shlwapi.lib odbc32.lib odbccp32.lib"
OutputFile="../TestBench/x32/Release/Rainmeter.dll"
LinkIncremental="1"
SuppressStartupBanner="true"
@ -539,7 +539,7 @@
<Tool
Name="VCLinkerTool"
AdditionalOptions="/machine:AMD64 /LTCG "
AdditionalDependencies=" comctl32.lib Wininet.lib Winmm.lib gdiplus.lib Iphlpapi.lib odbc32.lib odbccp32.lib"
AdditionalDependencies=" comctl32.lib Wininet.lib Winmm.lib gdiplus.lib Iphlpapi.lib shlwapi.lib odbc32.lib odbccp32.lib"
OutputFile="../TestBench/x64/Release/Rainmeter.dll"
LinkIncremental="1"
SuppressStartupBanner="true"

View File

@ -32,6 +32,7 @@
#include <fstream>
#include <iostream>
#include <shlobj.h>
#include <shlwapi.h>
using namespace Gdiplus;
@ -1986,13 +1987,30 @@ void CRainmeter::ReadGeneralSettings(std::wstring& iniFile)
c_GlobalConfig.netInSpeed = parser.ReadFloat(L"Rainmeter", L"NetInSpeed", 0.0);
c_GlobalConfig.netOutSpeed = parser.ReadFloat(L"Rainmeter", L"NetOutSpeed", 0.0);
m_ConfigEditor = parser.ReadString(L"Rainmeter", L"ConfigEditor", L"Notepad");
m_ConfigEditor = parser.ReadString(L"Rainmeter", L"ConfigEditor", L"");
if (m_ConfigEditor.empty())
{
// Get the program path associated with .ini files
WCHAR buffer[MAX_PATH+1] = {0};
DWORD cchOut = MAX_PATH;
HRESULT hr = AssocQueryString(ASSOCF_NOTRUNCATE, ASSOCSTR_EXECUTABLE, L".ini", L"open", buffer, &cchOut);
if (SUCCEEDED(hr) && cchOut > 0)
{
m_ConfigEditor = buffer;
}
else
{
m_ConfigEditor = L"Notepad";
}
}
if (!m_ConfigEditor.empty() && m_ConfigEditor[0] != L'\"')
{
m_ConfigEditor.insert(0,L"\"");
m_ConfigEditor.insert(0, L"\"");
m_ConfigEditor.append(L"\"");
}
if (c_Debug) DebugLog(L"ConfigEditor: %s", m_ConfigEditor.c_str());
m_TrayExecuteL = parser.ReadString(L"Rainmeter", L"TrayExecuteL", L"", false);
m_TrayExecuteR = parser.ReadString(L"Rainmeter", L"TrayExecuteR", L"", false);
m_TrayExecuteM = parser.ReadString(L"Rainmeter", L"TrayExecuteM", L"", false);
@ -2237,13 +2255,11 @@ void CRainmeter::ShowContextMenu(POINT pos, CMeterWindow* meterWindow)
if(menu)
{
HMENU configMenu = NULL;
HMENU subMenu = GetSubMenu(menu, 0);
if(subMenu)
{
if (!GetDummyLitestep())
{
{
// Disable Quit if ran as a Litestep plugin
EnableMenuItem(subMenu, ID_CONTEXT_QUIT, MF_BYCOMMAND | MF_GRAYED);
EnableMenuItem(subMenu, ID_CONTEXT_SHOWLOGFILE, MF_BYCOMMAND | MF_GRAYED);
@ -2268,18 +2284,14 @@ void CRainmeter::ShowContextMenu(POINT pos, CMeterWindow* meterWindow)
if (meterWindow)
{
HMENU skinMenu = CreateSkinMenu(meterWindow, 0);
InsertMenu(subMenu, 10, MF_BYPOSITION | MF_POPUP, (UINT_PTR)skinMenu, L"Skin Menu");
HMENU rainmeterMenu = subMenu;
subMenu = CreateSkinMenu(meterWindow, 0);
InsertMenu(subMenu, 7, MF_BYPOSITION | MF_SEPARATOR, 0, NULL);
InsertMenu(subMenu, 8, MF_BYPOSITION | MF_POPUP, (UINT_PTR)rainmeterMenu, L"Rainmeter Menu");
}
else
{
UINT configPos = 10;
//Put Update notifications in the Tray menu
if (m_NewVersion)
{
configPos += 1;
InsertMenu(subMenu, 2, MF_BYPOSITION | MF_ENABLED, ID_CONTEXT_NEW_VERSION, L"New Version Available");
}
InsertMenu(subMenu, 10, MF_BYPOSITION | MF_SEPARATOR, 0, NULL);
// Create a menu for all active configs
std::map<std::wstring, CMeterWindow*>::const_iterator iter = Rainmeter->GetAllMeterWindows().begin();
@ -2289,9 +2301,17 @@ void CRainmeter::ShowContextMenu(POINT pos, CMeterWindow* meterWindow)
{
CMeterWindow* mw = ((*iter).second);
HMENU skinMenu = CreateSkinMenu(mw, index);
InsertMenu(subMenu, configPos, MF_BYPOSITION | MF_POPUP, (UINT_PTR)skinMenu, mw->GetSkinName().c_str());
InsertMenu(subMenu, 10, MF_BYPOSITION | MF_POPUP, (UINT_PTR)skinMenu, mw->GetSkinName().c_str());
++index;
}
// Put Update notifications in the Tray menu
if (m_NewVersion)
{
InsertMenu(subMenu, 0, MF_BYPOSITION, ID_CONTEXT_NEW_VERSION, L"New Version Available");
InsertMenu(subMenu, 1, MF_BYPOSITION | MF_SEPARATOR, 0, NULL);
SetMenuDefaultItem(subMenu, ID_CONTEXT_NEW_VERSION, MF_BYCOMMAND);
}
}
@ -2304,6 +2324,11 @@ void CRainmeter::ShowContextMenu(POINT pos, CMeterWindow* meterWindow)
meterWindow ? meterWindow->GetWindow() : m_TrayWindow->GetWindow(),
NULL
);
if (meterWindow)
{
DestroyMenu(subMenu);
}
}
DestroyMenu(menu);
@ -2378,58 +2403,61 @@ HMENU CRainmeter::CreateSkinMenu(CMeterWindow* meterWindow, int index)
if (skinMenu)
{
// Tick the position
HMENU posMenu = GetSubMenu(skinMenu, 0);
if (posMenu)
HMENU settingsMenu = GetSubMenu(skinMenu, 0);
if (settingsMenu)
{
switch(meterWindow->GetWindowZPosition())
HMENU posMenu = GetSubMenu(settingsMenu, 0);
if (posMenu)
{
case ZPOSITION_ONDESKTOP:
CheckMenuItem(posMenu, ID_CONTEXT_SKINMENU_ONDESKTOP, MF_BYCOMMAND | MF_CHECKED);
break;
switch(meterWindow->GetWindowZPosition())
{
case ZPOSITION_ONDESKTOP:
CheckMenuItem(posMenu, ID_CONTEXT_SKINMENU_ONDESKTOP, MF_BYCOMMAND | MF_CHECKED);
break;
case ZPOSITION_ONBOTTOM:
CheckMenuItem(posMenu, ID_CONTEXT_SKINMENU_BOTTOM, MF_BYCOMMAND | MF_CHECKED);
break;
case ZPOSITION_ONBOTTOM:
CheckMenuItem(posMenu, ID_CONTEXT_SKINMENU_BOTTOM, MF_BYCOMMAND | MF_CHECKED);
break;
case ZPOSITION_ONTOP:
CheckMenuItem(posMenu, ID_CONTEXT_SKINMENU_TOPMOST, MF_BYCOMMAND | MF_CHECKED);
break;
case ZPOSITION_ONTOP:
CheckMenuItem(posMenu, ID_CONTEXT_SKINMENU_TOPMOST, MF_BYCOMMAND | MF_CHECKED);
break;
case ZPOSITION_ONTOPMOST:
CheckMenuItem(posMenu, ID_CONTEXT_SKINMENU_VERYTOPMOST, MF_BYCOMMAND | MF_CHECKED);
break;
case ZPOSITION_ONTOPMOST:
CheckMenuItem(posMenu, ID_CONTEXT_SKINMENU_VERYTOPMOST, MF_BYCOMMAND | MF_CHECKED);
break;
default:
CheckMenuItem(posMenu, ID_CONTEXT_SKINMENU_NORMAL, MF_BYCOMMAND | MF_CHECKED);
}
default:
CheckMenuItem(posMenu, ID_CONTEXT_SKINMENU_NORMAL, MF_BYCOMMAND | MF_CHECKED);
}
if(meterWindow->GetXFromRight()) CheckMenuItem(posMenu, ID_CONTEXT_SKINMENU_FROMRIGHT, MF_BYCOMMAND | MF_CHECKED);
if(meterWindow->GetYFromBottom()) CheckMenuItem(posMenu, ID_CONTEXT_SKINMENU_FROMBOTTOM, MF_BYCOMMAND | MF_CHECKED);
if(meterWindow->GetXPercentage()) CheckMenuItem(posMenu, ID_CONTEXT_SKINMENU_XPERCENTAGE, MF_BYCOMMAND | MF_CHECKED);
if(meterWindow->GetYPercentage()) CheckMenuItem(posMenu, ID_CONTEXT_SKINMENU_YPERCENTAGE, MF_BYCOMMAND | MF_CHECKED);
if(meterWindow->GetXFromRight()) CheckMenuItem(posMenu, ID_CONTEXT_SKINMENU_FROMRIGHT, MF_BYCOMMAND | MF_CHECKED);
if(meterWindow->GetYFromBottom()) CheckMenuItem(posMenu, ID_CONTEXT_SKINMENU_FROMBOTTOM, MF_BYCOMMAND | MF_CHECKED);
if(meterWindow->GetXPercentage()) CheckMenuItem(posMenu, ID_CONTEXT_SKINMENU_XPERCENTAGE, MF_BYCOMMAND | MF_CHECKED);
if(meterWindow->GetYPercentage()) CheckMenuItem(posMenu, ID_CONTEXT_SKINMENU_YPERCENTAGE, MF_BYCOMMAND | MF_CHECKED);
if (!c_DummyLitestep)
{
EnableMenuItem(posMenu, ID_CONTEXT_SKINMENU_ONDESKTOP, MF_BYCOMMAND | MF_GRAYED);
}
if (!c_DummyLitestep)
{
EnableMenuItem(posMenu, ID_CONTEXT_SKINMENU_ONDESKTOP, MF_BYCOMMAND | MF_GRAYED);
}
HMENU monitorMenu = CreateMonitorMenu(meterWindow);
if (monitorMenu)
{
InsertMenu(posMenu, 0, MF_BYPOSITION | MF_POPUP, (UINT_PTR)monitorMenu, L"Display Monitor");
InsertMenu(posMenu, 1, MF_BYPOSITION | MF_SEPARATOR, 0, NULL);
HMENU monitorMenu = GetSubMenu(posMenu, 0);
if (monitorMenu)
{
CreateMonitorMenu(monitorMenu, meterWindow);
}
}
}
// Tick the transparency
if (!meterWindow->GetNativeTransparency())
{
EnableMenuItem(skinMenu, 1, MF_BYPOSITION | MF_GRAYED);
EnableMenuItem(skinMenu, ID_CONTEXT_SKINMENU_CLICKTHROUGH, MF_BYCOMMAND | MF_GRAYED);
EnableMenuItem(settingsMenu, 1, MF_BYPOSITION | MF_GRAYED);
EnableMenuItem(settingsMenu, ID_CONTEXT_SKINMENU_CLICKTHROUGH, MF_BYCOMMAND | MF_GRAYED);
}
else
{
HMENU alphaMenu = GetSubMenu(skinMenu, 1);
HMENU alphaMenu = GetSubMenu(settingsMenu, 1);
if (alphaMenu)
{
int value = (int)(10 - (meterWindow->GetAlphaValue() / 255.0) * 10.0);
@ -2458,95 +2486,87 @@ HMENU CRainmeter::CreateSkinMenu(CMeterWindow* meterWindow, int index)
// Tick the configs
if (meterWindow->GetWindowHide() == HIDEMODE_HIDE)
{
CheckMenuItem(skinMenu, ID_CONTEXT_SKINMENU_HIDEONMOUSE, MF_BYCOMMAND | MF_CHECKED);
CheckMenuItem(settingsMenu, ID_CONTEXT_SKINMENU_HIDEONMOUSE, MF_BYCOMMAND | MF_CHECKED);
}
else if (meterWindow->GetWindowHide() != HIDEMODE_NONE)
{
EnableMenuItem(skinMenu, ID_CONTEXT_SKINMENU_HIDEONMOUSE, MF_BYCOMMAND | MF_GRAYED);
EnableMenuItem(settingsMenu, ID_CONTEXT_SKINMENU_HIDEONMOUSE, MF_BYCOMMAND | MF_GRAYED);
}
if (meterWindow->GetSnapEdges())
{
CheckMenuItem(skinMenu, ID_CONTEXT_SKINMENU_SNAPTOEDGES, MF_BYCOMMAND | MF_CHECKED);
CheckMenuItem(settingsMenu, ID_CONTEXT_SKINMENU_SNAPTOEDGES, MF_BYCOMMAND | MF_CHECKED);
}
if (meterWindow->GetSavePosition())
{
CheckMenuItem(skinMenu, ID_CONTEXT_SKINMENU_REMEMBERPOSITION, MF_BYCOMMAND | MF_CHECKED);
CheckMenuItem(settingsMenu, ID_CONTEXT_SKINMENU_REMEMBERPOSITION, MF_BYCOMMAND | MF_CHECKED);
}
if (meterWindow->GetWindowDraggable())
{
CheckMenuItem(skinMenu, ID_CONTEXT_SKINMENU_DRAGGABLE, MF_BYCOMMAND | MF_CHECKED);
CheckMenuItem(settingsMenu, ID_CONTEXT_SKINMENU_DRAGGABLE, MF_BYCOMMAND | MF_CHECKED);
}
if (meterWindow->GetClickThrough())
{
CheckMenuItem(skinMenu, ID_CONTEXT_SKINMENU_CLICKTHROUGH, MF_BYCOMMAND | MF_CHECKED);
CheckMenuItem(settingsMenu, ID_CONTEXT_SKINMENU_CLICKTHROUGH, MF_BYCOMMAND | MF_CHECKED);
}
if (meterWindow->GetKeepOnScreen())
{
CheckMenuItem(skinMenu, ID_CONTEXT_SKINMENU_KEEPONSCREEN, MF_BYCOMMAND | MF_CHECKED);
CheckMenuItem(settingsMenu, ID_CONTEXT_SKINMENU_KEEPONSCREEN, MF_BYCOMMAND | MF_CHECKED);
}
// Add the name of the Skin to the menu and disable the item
InsertMenu(skinMenu, 0, MF_BYPOSITION, 0, meterWindow->GetSkinName().c_str());
const std::wstring& skinName = meterWindow->GetSkinName();
InsertMenu(skinMenu, 0, MF_BYPOSITION, ID_CONTEXT_SKINMENU_OPENSKINSFOLDER, skinName.c_str());
InsertMenu(skinMenu, 1, MF_BYPOSITION | MF_SEPARATOR, 0, NULL);
SetMenuDefaultItem(skinMenu, 0, MF_BYPOSITION);
EnableMenuItem(skinMenu, 0, MF_BYPOSITION | MF_GRAYED);
ChangeSkinIndex(skinMenu, index);
// Add the variants menu
for (size_t i = 0; i < m_ConfigStrings.size(); ++i)
{
const CONFIG& config = m_ConfigStrings[i];
if (wcsicmp(config.config.c_str(), skinName.c_str()) == 0)
{
HMENU variantsMenu = CreatePopupMenu();
for (size_t j = 0; j < config.iniFiles.size(); ++j)
{
InsertMenu(variantsMenu, j, MF_BYPOSITION, config.commands[j], config.iniFiles[j].c_str());
if (config.active == j + 1)
{
CheckMenuItem(variantsMenu, j, MF_BYPOSITION | MF_CHECKED);
}
}
InsertMenu(skinMenu, 2, MF_BYPOSITION | MF_POPUP, (UINT_PTR)variantsMenu, L"Variants");
break;
}
}
}
return skinMenu;
}
HMENU CRainmeter::CreateMonitorMenu(CMeterWindow* meterWindow)
void CRainmeter::CreateMonitorMenu(HMENU monitorMenu, CMeterWindow* meterWindow)
{
WCHAR buffer[256];
std::wstring item;
UINT flags;
HMENU monitorMenu = CreatePopupMenu();
bool screenDefined = meterWindow->GetXScreenDefined();
int screenIndex = meterWindow->GetXScreen();
// for the "Primary monitor"
flags = 0;
if (!screenDefined)
{
flags |= MF_CHECKED;
}
AppendMenu(monitorMenu, flags, ID_CONTEXT_SKINMENU_MONITOR_PRIMARY, L"Use default: Primary monitor");
// for the "Virtual screen" (@0)
flags = 0;
if (screenDefined && screenIndex == 0)
{
flags |= MF_CHECKED;
}
AppendMenu(monitorMenu, flags, ID_MONITOR_FIRST, L"@0: Virtual screen");
// for the "Specified monitor" (@n)
if (CSystem::GetMonitorCount() > 0)
{
AppendMenu(monitorMenu, MF_SEPARATOR, 0, NULL);
const MULTIMONITOR_INFO& multimonInfo = CSystem::GetMultiMonitorInfo();
const std::vector<MONITOR_INFO>& monitors = multimonInfo.monitors;
for (size_t i = 0; i < monitors.size(); ++i)
{
WCHAR buffer[256];
wsprintf(buffer, L"@%i: ", i + 1);
item = buffer;
flags = 0;
if (screenDefined && screenIndex == (int)i + 1)
{
flags |= MF_CHECKED;
}
std::wstring item = buffer;
size_t len = wcslen(monitors[i].monitorName);
if (len > 32)
@ -2559,25 +2579,36 @@ HMENU CRainmeter::CreateMonitorMenu(CMeterWindow* meterWindow)
item += monitors[i].monitorName;
}
if (!monitors[i].active)
UINT pos = i + 3;
InsertMenu(monitorMenu, pos, MF_BYPOSITION, ID_MONITOR_FIRST + i + 1, item.c_str());
if (screenDefined && screenIndex == (int)i + 1)
{
flags |= MF_GRAYED;
CheckMenuItem(monitorMenu, pos, MF_BYPOSITION | MF_CHECKED);
}
AppendMenu(monitorMenu, flags, ID_MONITOR_FIRST + i + 1, item.c_str());
if (!monitors[i].active)
{
EnableMenuItem(monitorMenu, pos, MF_BYPOSITION | MF_GRAYED);
}
}
}
AppendMenu(monitorMenu, MF_SEPARATOR, 0, NULL);
// Tick the configs
if (!screenDefined)
{
CheckMenuItem(monitorMenu, ID_CONTEXT_SKINMENU_MONITOR_PRIMARY, MF_BYCOMMAND | MF_CHECKED);
}
if (screenDefined && screenIndex == 0)
{
CheckMenuItem(monitorMenu, ID_MONITOR_FIRST, MF_BYCOMMAND | MF_CHECKED);
}
flags = 0;
if (meterWindow->GetAutoSelectScreen())
{
flags |= MF_CHECKED;
CheckMenuItem(monitorMenu, ID_CONTEXT_SKINMENU_MONITOR_AUTOSELECT, MF_BYCOMMAND | MF_CHECKED);
}
AppendMenu(monitorMenu, flags, ID_CONTEXT_SKINMENU_MONITOR_AUTOSELECT, L"Auto-select based on window position");
return monitorMenu;
}
void CRainmeter::ChangeSkinIndex(HMENU menu, int index)

View File

@ -198,7 +198,7 @@ private:
int ScanForConfigsRecursive(std::wstring& path, std::wstring base, int index, std::vector<CONFIGMENU>& menu, bool DontRecurse);
HMENU CreateConfigMenu(std::vector<CONFIGMENU>& configMenuData);
HMENU CreateThemeMenu();
HMENU CreateMonitorMenu(CMeterWindow* meterWindow);
void CreateMonitorMenu(HMENU monitorMenu, CMeterWindow* meterWindow);
void CreateDefaultConfigFile(std::wstring strFile);
void TestSettingsFile(bool bDefaultIniLocation);
void CheckSkinVersions();

View File

@ -37,6 +37,7 @@
#include <shellapi.h>
#include <Mmsystem.h>
#include <shlobj.h>
#include <shlwapi.h>
#include <winperf.h>
#include <Windns.h>
#include <Ipexport.h>

View File

@ -1,2 +1,2 @@
#pragma once
const int revision_number = 444;
const int revision_number = 448;