feat: --cm hide task bar

This commit is contained in:
Kingtous
2022-10-26 16:57:56 +08:00
parent 2301d09303
commit 6f2ef398bf
3 changed files with 30 additions and 9 deletions

View File

@@ -1,6 +1,7 @@
#include "win32_window.h"
#include <flutter_windows.h>
#include <shobjidl_core.h>
#include "resource.h"
@@ -104,7 +105,7 @@ Win32Window::~Win32Window() {
bool Win32Window::CreateAndShow(const std::wstring& title,
const Point& origin,
const Size& size) {
const Size& size, bool showOnTaskBar) {
Destroy();
const wchar_t* window_class =
@@ -115,7 +116,7 @@ bool Win32Window::CreateAndShow(const std::wstring& title,
HMONITOR monitor = MonitorFromPoint(target_point, MONITOR_DEFAULTTONEAREST);
UINT dpi = FlutterDesktopGetDpiForMonitor(monitor);
double scale_factor = dpi / 96.0;
HWND window = CreateWindow(
window_class, title.c_str(), WS_OVERLAPPEDWINDOW,
Scale(origin.x, scale_factor), Scale(origin.y, scale_factor),
@@ -126,6 +127,19 @@ bool Win32Window::CreateAndShow(const std::wstring& title,
return false;
}
if (!showOnTaskBar) {
// hide from taskbar
HRESULT hr;
ITaskbarList* pTaskbarList;
hr = CoCreateInstance(CLSID_TaskbarList, NULL, CLSCTX_INPROC_SERVER,IID_ITaskbarList,(void**)&pTaskbarList);
if (FAILED(hr)) {
return false;
}
hr = pTaskbarList->HrInit();
hr = pTaskbarList->DeleteTab(window);
hr = pTaskbarList->Release();
}
return OnCreate();
}