[v3] Make Windows window class configurable (#3682)

This commit is contained in:
Windom 2024-08-20 11:20:44 +03:00 committed by GitHub
commit 46dbbb3b84
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
7 changed files with 14 additions and 8 deletions

View file

@ -17,6 +17,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## [Unreleased]
### Added
- [windows] Window class name option by [windom](https://github.com/windom/) in [#3682](https://github.com/wailsapp/wails/pull/3682)
### Fixed
- [windows] Fixed syso icon file generation bug by [atterpac](https://github.com/atterpac) in [#3675](https://github.com/wailsapp/wails/pull/3675)

View file

@ -168,6 +168,9 @@ func mergeApplicationDefaults(o *Options) {
if o.Description == "" {
o.Description = "An application written using Wails"
}
if o.Windows.WndClass == "" {
o.Windows.WndClass = "WailsWebviewWindow"
}
}
type (

View file

@ -182,6 +182,10 @@ type MacOptions struct {
// WindowsOptions contains options for Windows applications.
type WindowsOptions struct {
// Window class name
// Default: WailsWebviewWindow
WndClass string
// WndProcInterceptor is a function that will be called for every message sent in the application.
// Use this to hook into the main message loop. This is useful for handling custom window messages.
// If `shouldReturn` is `true` then `returnCode` will be returned by the main message loop.

View file

@ -16,12 +16,8 @@ import (
"github.com/wailsapp/wails/v3/pkg/events"
"github.com/wailsapp/wails/v3/pkg/w32"
"github.com/samber/lo"
)
var windowClassName = lo.Must(syscall.UTF16PtrFromString("WailsWebviewWindow"))
type windowsApp struct {
parent *App
@ -212,7 +208,7 @@ func (m *windowsApp) init() {
m.windowClass.Background = w32.COLOR_BTNFACE + 1
m.windowClass.Icon = icon
m.windowClass.Cursor = w32.LoadCursorWithResourceID(0, w32.IDC_ARROW)
m.windowClass.ClassName = windowClassName
m.windowClass.ClassName = w32.MustStringToUTF16Ptr(m.parent.options.Windows.WndClass)
m.windowClass.MenuName = nil
m.windowClass.IconSm = icon

View file

@ -34,7 +34,7 @@ func (m *windowsApp) initMainLoop() {
// > Because the system directs messages to individual windows in an application, a thread must create at least one window before starting its message loop.
m.mainThreadWindowHWND = w32.CreateWindowEx(
0,
windowClassName,
w32.MustStringToUTF16Ptr(m.parent.options.Windows.WndClass),
w32.MustStringToUTF16Ptr("__wails_hidden_mainthread"),
w32.WS_DISABLED,
w32.CW_USEDEFAULT,

View file

@ -150,7 +150,7 @@ func (s *windowsSystemTray) setMenu(menu *Menu) {
func (s *windowsSystemTray) run() {
s.hwnd = w32.CreateWindowEx(
0,
windowClassName,
w32.MustStringToUTF16Ptr(globalApplication.options.Windows.WndClass),
nil,
0,
0,

View file

@ -249,7 +249,7 @@ func (w *windowsWebviewWindow) run() {
w.hwnd = w32.CreateWindowEx(
uint(exStyle),
windowClassName,
w32.MustStringToUTF16Ptr(globalApplication.options.Windows.WndClass),
w32.MustStringToUTF16Ptr(options.Title),
style,
startX,