mirror of
https://github.com/Maplespe/DWMBlurGlass.git
synced 2026-12-01 15:55:39 -05:00
92 lines
2.6 KiB
C++
92 lines
2.6 KiB
C++
/**
|
|
* FileName: MainWindow.cpp
|
|
*
|
|
* Copyright (C) 2024 Maplespe
|
|
*
|
|
* This file is part of MToolBox and DWMBlurGlass.
|
|
* DWMBlurGlass is free software: you can redistribute it and/or modify it under the terms of the
|
|
* GNU Lesser General Public License as published by the Free Software Foundation, either version 3
|
|
* of the License, or any later version.
|
|
*
|
|
* DWMBlurGlass is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
|
|
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
* See the GNU Lesser General Public License for more details.
|
|
*
|
|
* You should have received a copy of the GNU Lesser General Public License along with Foobar.
|
|
* If not, see <https://www.gnu.org/licenses/lgpl-3.0.html>.
|
|
*/
|
|
#include "MainWindow.h"
|
|
#include "UIManager.h"
|
|
#include "Helper/Helper.h"
|
|
#include "VersionHelper.h"
|
|
#include "Extend/ColorPickerDlg.h"
|
|
#include "Page/MainPage.h"
|
|
#include <User/Mui_Engine.h>
|
|
#include <dwmapi.h>
|
|
#include "resource.h"
|
|
#pragma comment(lib, "dwmapi.lib")
|
|
|
|
namespace MDWMBlurGlass
|
|
{
|
|
using namespace Mui;
|
|
|
|
ColorPickerDlg* g_colorDialog = nullptr;
|
|
MainWindowPage* g_mainPage = nullptr;
|
|
|
|
bool MainWindow_InitWindow(const MWindowCtx* ctx, UIControl* root, XML::MuiXML* ui)
|
|
{
|
|
if (!LoadDefualtUIStyle(ui))
|
|
return false;
|
|
|
|
if(!LoadLanguageString(ui, GetSystemLocalName(), true))
|
|
{
|
|
if (!LoadLanguageString(ui, L"en-US", true))
|
|
return false;
|
|
}
|
|
|
|
const HWND hWnd = (HWND)ctx->Base()->GetWindowHandle();
|
|
SetWindowLongW(hWnd, GWL_STYLE, GetWindowLongW(hWnd, GWL_STYLE) & ~(WS_MAXIMIZEBOX | WS_SIZEBOX));
|
|
HICON hIcon = LoadIconW(GetModuleHandleW(nullptr), MAKEINTRESOURCE(IDI_ICON1));
|
|
SendMessageW(hWnd, WM_SETICON, ICON_BIG, (LPARAM)hIcon);
|
|
SendMessageW(hWnd, WM_SETICON, ICON_SMALL, (LPARAM)hIcon);
|
|
|
|
EnableHostBackdropBrush(hWnd);
|
|
|
|
UIBkgndStyle bgStyle;
|
|
bgStyle.bkgndColor = Color::M_RGBA(255, 255, 255, 200);
|
|
root->SetBackground(bgStyle);
|
|
|
|
try
|
|
{
|
|
g_mainPage = new MainWindowPage(root, ui);
|
|
g_colorDialog = new ColorPickerDlg(root, ui);
|
|
}
|
|
catch(...)
|
|
{
|
|
return false;
|
|
}
|
|
return true;
|
|
}
|
|
|
|
void MainWindow_Destroy()
|
|
{
|
|
delete g_colorDialog;
|
|
delete g_mainPage;
|
|
}
|
|
|
|
void ShowColorPicker(_m_color showColor, bool alpha, std::function<void(bool, _m_color)> callback)
|
|
{
|
|
if (g_colorDialog)
|
|
g_colorDialog->ShowColorPicker(showColor, alpha, std::move(callback));
|
|
}
|
|
|
|
bool MainWindow_EventProc(MWindowCtx*, UINotifyEvent event, UIControl* control, _m_param param)
|
|
{
|
|
if (g_colorDialog && g_colorDialog->EventProc(event, control, param))
|
|
return true;
|
|
if (g_mainPage && g_mainPage->EventProc(event, control, param))
|
|
return true;
|
|
return false;
|
|
}
|
|
|
|
} |