diff --git a/v2/init.go b/v2/init.go new file mode 100644 index 000000000..50dc23fdb --- /dev/null +++ b/v2/init.go @@ -0,0 +1,7 @@ +// +build !windows + +package wails + +func Init() error { + return nil +} diff --git a/v2/init_windows.go b/v2/init_windows.go new file mode 100644 index 000000000..ac200328b --- /dev/null +++ b/v2/init_windows.go @@ -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 +} diff --git a/v2/wails.go b/v2/wails.go index 7c77753a0..d7c680bfd 100644 --- a/v2/wails.go +++ b/v2/wails.go @@ -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() }