mirror of
https://github.com/Auties00/Reboot-Launcher.git
synced 2026-01-13 11:12:23 +01:00
8.2
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
#include <bitsdojo_window_windows/bitsdojo_window_plugin.h>
|
||||
auto bdw = bitsdojo_window_configure(BDW_CUSTOM_FRAME | BDW_HIDE_ON_STARTUP);
|
||||
auto bdw = bitsdojo_window_configure(BDW_CUSTOM_FRAME);
|
||||
|
||||
#include <cstdlib>
|
||||
|
||||
@@ -15,19 +15,20 @@ auto bdw = bitsdojo_window_configure(BDW_CUSTOM_FRAME | BDW_HIDE_ON_STARTUP);
|
||||
#include <stdio.h>
|
||||
#include <fcntl.h>
|
||||
|
||||
bool CheckOneInstance()
|
||||
{
|
||||
HANDLE m_hStartEvent = CreateEventW( NULL, FALSE, FALSE, L"reboot_launcher");
|
||||
if(m_hStartEvent == NULL)
|
||||
{
|
||||
CloseHandle( m_hStartEvent );
|
||||
bool CheckOneInstance(){
|
||||
HANDLE hMutex = CreateMutexW(NULL, TRUE, L"RebootLauncherMutex");
|
||||
if (hMutex == NULL) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (GetLastError() == ERROR_ALREADY_EXISTS)
|
||||
{
|
||||
CloseHandle( m_hStartEvent );
|
||||
m_hStartEvent = NULL;
|
||||
if (GetLastError() == ERROR_ALREADY_EXISTS) {
|
||||
HWND hwndExisting = FindWindowW(NULL, L"Reboot Launcher");
|
||||
if (hwndExisting != NULL) {
|
||||
ShowWindow(hwndExisting, SW_RESTORE);
|
||||
SetForegroundWindow(hwndExisting);
|
||||
}
|
||||
|
||||
CloseHandle(hMutex);
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -58,7 +59,7 @@ int APIENTRY wWinMain(_In_ HINSTANCE instance, _In_opt_ HINSTANCE prev,
|
||||
FlutterWindow window(project);
|
||||
Win32Window::Point origin(10, 10);
|
||||
Win32Window::Size size(1280, 720);
|
||||
if (!window.CreateAndShow(L"reboot_launcher", origin, size)) {
|
||||
if (!window.CreateAndShow(L"Reboot Launcher", origin, size)) {
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
|
||||
@@ -4,6 +4,8 @@
|
||||
|
||||
#include "resource.h"
|
||||
|
||||
#include <dwmapi.h>
|
||||
|
||||
namespace {
|
||||
|
||||
constexpr const wchar_t kWindowClassName[] = L"FLUTTER_RUNNER_WIN32_WINDOW";
|
||||
@@ -108,7 +110,7 @@ bool Win32Window::CreateAndShow(const std::wstring& title,
|
||||
Destroy();
|
||||
|
||||
const wchar_t* window_class =
|
||||
WindowClassRegistrar::GetInstance()->GetWindowClass();
|
||||
WindowClassRegistrar::GetInstance()->GetWindowClass();
|
||||
|
||||
const POINT target_point = {static_cast<LONG>(origin.x),
|
||||
static_cast<LONG>(origin.y)};
|
||||
@@ -117,10 +119,18 @@ bool Win32Window::CreateAndShow(const std::wstring& title,
|
||||
double scale_factor = dpi / 96.0;
|
||||
|
||||
HWND window = CreateWindow(
|
||||
window_class, title.c_str(), WS_OVERLAPPEDWINDOW | WS_VISIBLE,
|
||||
Scale(origin.x, scale_factor), Scale(origin.y, scale_factor),
|
||||
Scale(size.width, scale_factor), Scale(size.height, scale_factor),
|
||||
nullptr, nullptr, GetModuleHandle(nullptr), this);
|
||||
window_class,
|
||||
title.c_str(),
|
||||
WS_OVERLAPPED & ~WS_VISIBLE,
|
||||
Scale(origin.x, scale_factor),
|
||||
Scale(origin.y, scale_factor),
|
||||
Scale(size.width, scale_factor),
|
||||
Scale(size.height, scale_factor),
|
||||
nullptr,
|
||||
nullptr,
|
||||
GetModuleHandle(nullptr),
|
||||
this
|
||||
);
|
||||
|
||||
if (!window) {
|
||||
return false;
|
||||
|
||||
Reference in New Issue
Block a user