mirror of
https://github.com/wailsapp/wails.git
synced 2026-03-14 14:45:49 +01:00
[v3] Make Windows window class configurable (#3682)
This commit is contained in:
parent
b756bce67f
commit
46dbbb3b84
7 changed files with 14 additions and 8 deletions
|
|
@ -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)
|
||||
|
||||
|
|
|
|||
|
|
@ -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 (
|
||||
|
|
|
|||
|
|
@ -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.
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue