Skip to content

Commit

Permalink
添加各插件设置
Browse files Browse the repository at this point in the history
  • Loading branch information
xfgryujk committed Jan 15, 2017
1 parent eec9d05 commit ba18750
Show file tree
Hide file tree
Showing 17 changed files with 271 additions and 52 deletions.
7 changes: 6 additions & 1 deletion CDConfig/CDConfigDlg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -155,12 +155,17 @@ void CCDConfigDlg::OnBnClickedButton1()

SHELLEXECUTEINFO info = {};
info.cbSize = sizeof(info);
info.fMask = SEE_MASK_NOASYNC;
info.fMask = SEE_MASK_NOCLOSEPROCESS;
info.lpVerb = _T("open");
info.lpFile = _T("Inject.exe");
info.nShow = SW_SHOWNORMAL;

ShellExecuteEx(&info);
WaitForSingleObject(info.hProcess, INFINITE);
CloseHandle(info.hProcess);
ShellExecuteEx(&info);
WaitForSingleObject(info.hProcess, INFINITE);
CloseHandle(info.hProcess);
}

void CCDConfigDlg::OnOK()
Expand Down
43 changes: 42 additions & 1 deletion Plugin/DesktopBrowser/DesktopBrowser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,13 @@
#include <CDAPI.h>
#include "Config.h"
#include <CommCtrl.h>
#include <thread>
#include <shellapi.h>


DesktopBrowser::DesktopBrowser(HMODULE hModule) :
m_module(hModule)
m_module(hModule),
m_menuID(cd::GetMenuID())
{
cd::g_fileListWndProcEvent.AddListener(std::bind(&DesktopBrowser::OnFileListWndProc, this, std::placeholders::_1,
std::placeholders::_2, std::placeholders::_3, std::placeholders::_4), m_module);
Expand All @@ -22,6 +25,8 @@ DesktopBrowser::DesktopBrowser(HMODULE hModule) :
cd::g_preDrawBackgroundEvent.AddListener([](HDC&){ return false; }, m_module);
cd::g_desktopCoveredEvent.AddListener([this]{ m_pauseFlag = true; return true; }, m_module);
cd::g_desktopUncoveredEvent.AddListener([this]{ m_pauseFlag = false; return true; }, m_module);
cd::g_appendTrayMenuEvent.AddListener(std::bind(&DesktopBrowser::OnAppendTrayMenu, this, std::placeholders::_1), m_module);
cd::g_chooseMenuItemEvent.AddListener(std::bind(&DesktopBrowser::OnChooseMenuItem, this, std::placeholders::_1), m_module);

cd::ExecInMainThread([this]{
SIZE size;
Expand Down Expand Up @@ -88,3 +93,39 @@ bool DesktopBrowser::OnPostDrawBackground(HDC& hdc)
m_browser->Draw(hdc, rect);
return true;
}


bool DesktopBrowser::OnAppendTrayMenu(HMENU menu)
{
AppendMenu(menu, MF_STRING, m_menuID, APPNAME);
return true;
}

bool DesktopBrowser::OnChooseMenuItem(UINT menuID)
{
if (menuID != m_menuID)
return true;

std::thread([this]{
SHELLEXECUTEINFOW info = {};
info.cbSize = sizeof(info);
info.fMask = SEE_MASK_NOCLOSEPROCESS | SEE_MASK_NOASYNC;
info.lpVerb = L"open";
info.lpFile = L"notepad.exe";
std::wstring param = cd::GetPluginDir() + L"\\Data\\DesktopBrowser.ini";
info.lpParameters = param.c_str();
info.nShow = SW_SHOWNORMAL;
ShellExecuteExW(&info);

WaitForSingleObject(info.hProcess, INFINITE);
CloseHandle(info.hProcess);

cd::ExecInMainThread([this]{
Config newConfig;
if (newConfig.m_homePage != g_config.m_homePage && m_browser != nullptr)
m_browser->Navigate(newConfig.m_homePage.c_str());
g_config = newConfig;
});
}).detach();
return false;
}
5 changes: 5 additions & 0 deletions Plugin/DesktopBrowser/DesktopBrowser.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,12 @@ class DesktopBrowser final
bool m_runThreadFlag = true;
bool m_pauseFlag = false;

const UINT m_menuID;


bool OnFileListWndProc(UINT message, WPARAM wParam, LPARAM lParam, LRESULT& res);
bool OnPostDrawBackground(HDC& hdc);

bool OnAppendTrayMenu(HMENU menu);
bool OnChooseMenuItem(UINT menuID);
};
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
#include "stdafx.h"
#include "MDConfig.h"
#include "Config.h"
#include <CDAPI.h>


MDConfig g_config;
Config g_config;


MDConfig::MDConfig()
Config::Config()
{
LoadConfig((cd::GetPluginDir() + L"\\Data\\MaskDesktop.ini").c_str());
}

void MDConfig::LoadConfig(LPCWSTR path)
void Config::LoadConfig(LPCWSTR path)
{
m_imagePath = cd::GetPluginDir() + L"\\Data\\Mask.png";
m_size = GetPrivateProfileIntW(APPNAME, L"Size", m_size, path);
Expand Down
6 changes: 3 additions & 3 deletions Plugin/MaskDesktop/MDConfig.h → Plugin/MaskDesktop/Config.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@

static const TCHAR APPNAME[] = _T("MaskDesktop");

class MDConfig final
class Config final
{
public:
std::wstring m_imagePath;
int m_size = 100;


MDConfig();
Config();
void LoadConfig(LPCWSTR path);
};

extern MDConfig g_config;
extern Config g_config;
65 changes: 57 additions & 8 deletions Plugin/MaskDesktop/MaskDesktop.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,27 +2,39 @@
#include "MaskDesktop.h"
#include <CDEvents.h>
#include <CDAPI.h>
#include "MDConfig.h"
#include "Config.h"
#include <thread>
#include <shellapi.h>


MaskDesktop::MaskDesktop(HMODULE hModule) :
m_module(hModule)
m_module(hModule),
m_menuID(cd::GetMenuID())
{
// 载入图片
CImage img;
img.Load(g_config.m_imagePath.c_str());
m_img.Create(g_config.m_size, g_config.m_size, 32, CImage::createAlphaChannel);
img.Draw(m_img.GetDC(), -5, -5, g_config.m_size + 10, g_config.m_size + 10);
m_img.ReleaseDC();
InitImg();

// 监听事件
cd::g_fileListWndProcEvent.AddListener(std::bind(&MaskDesktop::OnFileListWndProc, this, std::placeholders::_1,
std::placeholders::_2, std::placeholders::_3, std::placeholders::_4), m_module);
cd::g_postDrawIconEvent.AddListener(std::bind(&MaskDesktop::OnPostDrawIcon, this, std::placeholders::_1), m_module);
cd::g_appendTrayMenuEvent.AddListener(std::bind(&MaskDesktop::OnAppendTrayMenu, this, std::placeholders::_1), m_module);
cd::g_chooseMenuItemEvent.AddListener(std::bind(&MaskDesktop::OnChooseMenuItem, this, std::placeholders::_1), m_module);

cd::RedrawDesktop();
}

void MaskDesktop::InitImg()
{
CImage img;
img.Load(g_config.m_imagePath.c_str());
if (!m_img.IsNull())
m_img.Destroy();
m_img.Create(g_config.m_size, g_config.m_size, 32, CImage::createAlphaChannel);
img.Draw(m_img.GetDC(), -5, -5, g_config.m_size + 10, g_config.m_size + 10);
m_img.ReleaseDC();
}


bool MaskDesktop::OnFileListWndProc(UINT message, WPARAM wParam, LPARAM lParam, LRESULT& res)
{
Expand Down Expand Up @@ -79,4 +91,41 @@ bool MaskDesktop::OnPostDrawIcon(HDC& hdc)
FillRect(hdc, &rect, brush);

return true;
}
}


bool MaskDesktop::OnAppendTrayMenu(HMENU menu)
{
AppendMenu(menu, MF_STRING, m_menuID, APPNAME);
return true;
}

bool MaskDesktop::OnChooseMenuItem(UINT menuID)
{
if (menuID != m_menuID)
return true;

std::thread([this]{
SHELLEXECUTEINFOW info = {};
info.cbSize = sizeof(info);
info.fMask = SEE_MASK_NOCLOSEPROCESS | SEE_MASK_NOASYNC;
info.lpVerb = L"open";
info.lpFile = L"notepad.exe";
std::wstring param = cd::GetPluginDir() + L"\\Data\\MaskDesktop.ini";
info.lpParameters = param.c_str();
info.nShow = SW_SHOWNORMAL;
ShellExecuteExW(&info);

WaitForSingleObject(info.hProcess, INFINITE);
CloseHandle(info.hProcess);

cd::ExecInMainThread([this]{
Config newConfig;
int oldSize = g_config.m_size;
g_config = newConfig;
if (newConfig.m_size != oldSize)
InitImg();
});
}).detach();
return false;
}
7 changes: 7 additions & 0 deletions Plugin/MaskDesktop/MaskDesktop.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,14 @@ class MaskDesktop final
CImage m_img;
POINTS m_curPos;

const UINT m_menuID;


void InitImg();

bool OnFileListWndProc(UINT message, WPARAM wParam, LPARAM lParam, LRESULT& res);
bool OnPostDrawIcon(HDC& hdc);

bool OnAppendTrayMenu(HMENU menu);
bool OnChooseMenuItem(UINT menuID);
};
4 changes: 2 additions & 2 deletions Plugin/MaskDesktop/MaskDesktop.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@
</Bscmake>
</ItemDefinitionGroup>
<ItemGroup>
<ClInclude Include="MDConfig.h" />
<ClInclude Include="Config.h" />
<ClInclude Include="stdafx.h" />
<ClInclude Include="targetver.h" />
<ClInclude Include="MaskDesktop.h" />
Expand All @@ -167,7 +167,7 @@
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
</PrecompiledHeader>
</ClCompile>
<ClCompile Include="MDConfig.cpp" />
<ClCompile Include="Config.cpp" />
<ClCompile Include="stdafx.cpp">
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Create</PrecompiledHeader>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">Create</PrecompiledHeader>
Expand Down
4 changes: 2 additions & 2 deletions Plugin/MaskDesktop/MaskDesktop.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
<ClInclude Include="MaskDesktop.h">
<Filter>头文件</Filter>
</ClInclude>
<ClInclude Include="MDConfig.h">
<ClInclude Include="Config.h">
<Filter>头文件</Filter>
</ClInclude>
</ItemGroup>
Expand All @@ -38,7 +38,7 @@
<ClCompile Include="dllmain.cpp">
<Filter>源文件</Filter>
</ClCompile>
<ClCompile Include="MDConfig.cpp">
<ClCompile Include="Config.cpp">
<Filter>源文件</Filter>
</ClCompile>
</ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
#include "stdafx.h"
#include "VDConfig.h"
#include "Config.h"
#include <CDAPI.h>


VDConfig g_config;
Config g_config;


VDConfig::VDConfig()
Config::Config()
{
LoadConfig((cd::GetPluginDir() + L"\\Data\\VideoDesktop.ini").c_str());
}

void VDConfig::LoadConfig(LPCWSTR path)
void Config::LoadConfig(LPCWSTR path)
{
m_videoPath.resize(MAX_PATH);
GetPrivateProfileStringW(APPNAME, L"VideoPath", L"", &m_videoPath.front(), static_cast<DWORD>(m_videoPath.size()), path);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@

static const TCHAR APPNAME[] = _T("VideoDesktop");

class VDConfig final
class Config final
{
public:
std::wstring m_videoPath;
int m_volume = 100;


VDConfig();
Config();
void LoadConfig(LPCWSTR path);
};

extern VDConfig g_config;
extern Config g_config;
Loading

0 comments on commit ba18750

Please sign in to comment.