1605b5b7ae
- win32/autostart: SetAutoStart/IsAutoStartEnabled 操作 HKCU Run 键 - win32/window_size: GetWindowSize 通过 GetWindowRect 获取窗口尺寸 - config: 新增 AutoStart、WindowWidth、WindowHeight 字段 - store: Preferences/SetPreferences 扩展支持 autoStart + windowSize - dialog_preferences: 新增"开机自启动"复选框 - app.go: 启动时恢复窗口大小,关闭时通过 SetWindowSize 保存 - i18n: label_auto_start / hint_auto_start 三语翻译
26 lines
498 B
Go
26 lines
498 B
Go
//go:build windows
|
|
|
|
package win32
|
|
|
|
import (
|
|
"unsafe"
|
|
)
|
|
|
|
var (
|
|
procGetWindowRect = user32.NewProc("GetWindowRect")
|
|
)
|
|
|
|
type rect struct {
|
|
Left, Top, Right, Bottom int32
|
|
}
|
|
|
|
// GetWindowSize returns the width and height of the given window in pixels.
|
|
func GetWindowSize(hwnd uintptr) (width, height int, ok bool) {
|
|
var r rect
|
|
ret, _, _ := procGetWindowRect.Call(hwnd, uintptr(unsafe.Pointer(&r)))
|
|
if ret == 0 {
|
|
return 0, 0, false
|
|
}
|
|
return int(r.Right - r.Left), int(r.Bottom - r.Top), true
|
|
}
|