2021年7月23日 星期五

[Flutter] 變更視窗的大小,並讓他啟動時出現在畫面的正中央 (windows)

Change the form size and make the starting position in the center of the screen

在 flutter 專案底下 windows/runner/main.cpp 檔案,找到底下兩行

Win32Window::Point origin(10, 10);
Win32Window::Size size(1280, 720);
並將其變更如下
int width = 800; // 設定 Form 寬度
int height = 600;  // 設定 Form 高度
int x = (GetSystemMetrics(SM_CXSCREEN) - width) / 2;
int y = (GetSystemMetrics(SM_CYSCREEN) - height) / 2;
Win32Window::Point origin(x, y);
Win32Window::Size size(width, height);

沒有留言:

張貼留言