5
0
mirror of https://github.com/wailsapp/wails.git synced 2025-05-02 23:51:44 +08:00

[windows] Add DPI awareness

This commit is contained in:
Lea Anthony 2021-04-29 21:25:03 +10:00
parent 168cd96f56
commit 0224228c46
3 changed files with 30 additions and 2 deletions

7
v2/init.go Normal file
View File

@ -0,0 +1,7 @@
// +build !windows
package wails
func Init() error {
return nil
}

14
v2/init_windows.go Normal file
View File

@ -0,0 +1,14 @@
package wails
import (
"fmt"
"syscall"
)
func Init() error {
status, r, err := syscall.NewLazyDLL("user32.dll").NewProc("SetProcessDPIAware").Call()
if status == 0 {
return fmt.Errorf("exit status %d: %v %v", status, r, err)
}
return nil
}

View File

@ -16,10 +16,17 @@ type Store = runtime.Store
// Run creates an application based on the given config and executes it
func Run(options *options.App) error {
app, err := app.CreateApp(options)
// Call an Init method manually
err := Init()
if err != nil {
return err
}
return app.Run()
mainapp, err := app.CreateApp(options)
if err != nil {
return err
}
return mainapp.Run()
}