release ohos

This commit is contained in:
Developer
2026-04-21 10:14:37 +08:00
parent b1acdbdf05
commit 32f5aa53fa
229 changed files with 5690 additions and 28709 deletions

View File

@@ -89,13 +89,13 @@ BEGIN
BEGIN
BLOCK "040904e4"
BEGIN
VALUE "CompanyName", "com.example" "\0"
VALUE "FileDescription", "mom_kitchen" "\0"
VALUE "CompanyName", "MomKitchen" "\0"
VALUE "FileDescription", "小妈厨房" "\0"
VALUE "FileVersion", VERSION_AS_STRING "\0"
VALUE "InternalName", "mom_kitchen" "\0"
VALUE "LegalCopyright", "Copyright (C) 2026 com.example. All rights reserved." "\0"
VALUE "LegalCopyright", "Copyright (C) 2026 MomKitchen. All rights reserved." "\0"
VALUE "OriginalFilename", "mom_kitchen.exe" "\0"
VALUE "ProductName", "mom_kitchen" "\0"
VALUE "ProductName", "小妈厨房" "\0"
VALUE "ProductVersion", VERSION_AS_STRING "\0"
END
END

View File

@@ -65,6 +65,17 @@ FlutterWindow::MessageHandler(HWND hwnd, UINT const message,
case WM_FONTCHANGE:
flutter_controller_->engine()->ReloadSystemFonts();
break;
case WM_XBUTTONUP: {
int button = GET_XBUTTON_WPARAM(wparam);
if (button == XBUTTON1) {
PostMessage(hwnd, WM_KEYDOWN, VK_BROWSER_BACK, 0);
PostMessage(hwnd, WM_KEYUP, VK_BROWSER_BACK, 0);
} else if (button == XBUTTON2) {
PostMessage(hwnd, WM_KEYDOWN, VK_BROWSER_FORWARD, 0);
PostMessage(hwnd, WM_KEYUP, VK_BROWSER_FORWARD, 0);
}
return TRUE;
}
}
return Win32Window::MessageHandler(hwnd, message, wparam, lparam);

View File

@@ -26,8 +26,8 @@ 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.Create(L"mom_kitchen", origin, size)) {
Win32Window::Size size(520, 800);
if (!window.Create(L"小妈厨房", origin, size)) {
return EXIT_FAILURE;
}
window.SetQuitOnClose(true);

Binary file not shown.

Before

Width:  |  Height:  |  Size: 33 KiB

After

Width:  |  Height:  |  Size: 335 KiB

View File

@@ -88,19 +88,24 @@ WindowClassRegistrar* WindowClassRegistrar::instance_ = nullptr;
const wchar_t* WindowClassRegistrar::GetWindowClass() {
if (!class_registered_) {
WNDCLASS window_class{};
WNDCLASSEX window_class{};
window_class.cbSize = sizeof(WNDCLASSEX);
window_class.hCursor = LoadCursor(nullptr, IDC_ARROW);
window_class.lpszClassName = kWindowClassName;
window_class.style = CS_HREDRAW | CS_VREDRAW;
window_class.cbClsExtra = 0;
window_class.cbWndExtra = 0;
window_class.hInstance = GetModuleHandle(nullptr);
window_class.hIcon =
LoadIcon(window_class.hInstance, MAKEINTRESOURCE(IDI_APP_ICON));
window_class.hIcon = static_cast<HICON>(LoadImage(
window_class.hInstance, MAKEINTRESOURCE(IDI_APP_ICON), IMAGE_ICON,
256, 256, LR_DEFAULTCOLOR));
window_class.hIconSm = static_cast<HICON>(LoadImage(
window_class.hInstance, MAKEINTRESOURCE(IDI_APP_ICON), IMAGE_ICON,
48, 48, LR_DEFAULTCOLOR));
window_class.hbrBackground = 0;
window_class.lpszMenuName = nullptr;
window_class.lpfnWndProc = Win32Window::WndProc;
RegisterClass(&window_class);
RegisterClassEx(&window_class);
class_registered_ = true;
}
return kWindowClassName;
@@ -134,16 +139,43 @@ bool Win32Window::Create(const std::wstring& title,
UINT dpi = FlutterDesktopGetDpiForMonitor(monitor);
double scale_factor = dpi / 96.0;
int scaled_width = Scale(size.width, scale_factor);
int scaled_height = Scale(size.height, scale_factor);
// Center window on screen
MONITORINFO monitor_info;
monitor_info.cbSize = sizeof(monitor_info);
GetMonitorInfo(monitor, &monitor_info);
int screen_width = monitor_info.rcWork.right - monitor_info.rcWork.left;
int screen_height = monitor_info.rcWork.bottom - monitor_info.rcWork.top;
int pos_x = monitor_info.rcWork.left + (screen_width - scaled_width) / 2;
int pos_y = monitor_info.rcWork.top + (screen_height - scaled_height) / 2;
HWND window = CreateWindow(
window_class, title.c_str(), WS_OVERLAPPEDWINDOW,
Scale(origin.x, scale_factor), Scale(origin.y, scale_factor),
Scale(size.width, scale_factor), Scale(size.height, scale_factor),
pos_x, pos_y,
scaled_width, scaled_height,
nullptr, nullptr, GetModuleHandle(nullptr), this);
if (!window) {
return false;
}
// Set high-resolution icons for taskbar and title bar
HINSTANCE hInst = GetModuleHandle(nullptr);
HICON hIconLarge = static_cast<HICON>(LoadImage(
hInst, MAKEINTRESOURCE(IDI_APP_ICON), IMAGE_ICON,
256, 256, LR_DEFAULTCOLOR));
HICON hIconSmall = static_cast<HICON>(LoadImage(
hInst, MAKEINTRESOURCE(IDI_APP_ICON), IMAGE_ICON,
48, 48, LR_DEFAULTCOLOR));
if (hIconLarge) {
SendMessage(window, WM_SETICON, ICON_BIG, reinterpret_cast<LPARAM>(hIconLarge));
}
if (hIconSmall) {
SendMessage(window, WM_SETICON, ICON_SMALL, reinterpret_cast<LPARAM>(hIconSmall));
}
UpdateTheme(window);
return OnCreate();
@@ -195,6 +227,21 @@ Win32Window::MessageHandler(HWND hwnd,
SetWindowPos(hwnd, nullptr, newRectSize->left, newRectSize->top, newWidth,
newHeight, SWP_NOZORDER | SWP_NOACTIVATE);
// Reload icons at new DPI
HINSTANCE hInst = GetModuleHandle(nullptr);
HICON hIconLarge = static_cast<HICON>(LoadImage(
hInst, MAKEINTRESOURCE(IDI_APP_ICON), IMAGE_ICON,
256, 256, LR_DEFAULTCOLOR));
HICON hIconSmall = static_cast<HICON>(LoadImage(
hInst, MAKEINTRESOURCE(IDI_APP_ICON), IMAGE_ICON,
48, 48, LR_DEFAULTCOLOR));
if (hIconLarge) {
SendMessage(hwnd, WM_SETICON, ICON_BIG, reinterpret_cast<LPARAM>(hIconLarge));
}
if (hIconSmall) {
SendMessage(hwnd, WM_SETICON, ICON_SMALL, reinterpret_cast<LPARAM>(hIconSmall));
}
return 0;
}
case WM_SIZE: {
@@ -207,6 +254,17 @@ Win32Window::MessageHandler(HWND hwnd,
return 0;
}
case WM_GETMINMAXINFO: {
// Limit minimum window size (480x700 logical pixels)
auto info = reinterpret_cast<MINMAXINFO*>(lparam);
UINT dpi = FlutterDesktopGetDpiForMonitor(
MonitorFromWindow(window_handle_, MONITOR_DEFAULTTONEAREST));
double scale_factor = dpi / 96.0;
info->ptMinTrackSize.x = Scale(480, scale_factor);
info->ptMinTrackSize.y = Scale(600, scale_factor);
return 0;
}
case WM_ACTIVATE:
if (child_content_ != nullptr) {
SetFocus(child_content_);