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

Allow set window class name via options for Windows (#3828)

* Allow set window class name via options

* update changelog
This commit is contained in:
Andrey Pshenkin 2024-10-20 03:36:13 +01:00 committed by GitHub
parent 14cc9ec45b
commit 1b6ed1bc00
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 24 additions and 4 deletions

View File

@ -70,8 +70,13 @@ func NewWindow(parent winc.Controller, appoptions *options.App, versionInfo *ope
var dwStyle = w32.WS_OVERLAPPEDWINDOW var dwStyle = w32.WS_OVERLAPPEDWINDOW
winc.RegClassOnlyOnce("wailsWindow") windowClassName := "wailsWindow"
handle := winc.CreateWindow("wailsWindow", parent, uint(exStyle), uint(dwStyle)) if windowsOptions != nil && windowsOptions.WindowClassName != "" {
windowClassName = windowsOptions.WindowClassName
}
winc.RegClassOnlyOnce(windowClassName)
handle := winc.CreateWindow(windowClassName, parent, uint(exStyle), uint(dwStyle))
result.SetHandle(handle) result.SetHandle(handle)
winc.RegMsgHandler(result) winc.RegMsgHandler(result)
result.SetParent(parent) result.SetParent(parent)

View File

@ -118,6 +118,9 @@ type Options struct {
// Configure whether swipe gestures should be enabled // Configure whether swipe gestures should be enabled
EnableSwipeGestures bool EnableSwipeGestures bool
// Class name for the window. If empty, 'wailsWindow' will be used.
WindowClassName string
} }
func DefaultMessages() *Messages { func DefaultMessages() *Messages {

View File

@ -100,6 +100,8 @@ func main() {
OnResume: func(), OnResume: func(),
// Disable GPU hardware acceleration for the webview // Disable GPU hardware acceleration for the webview
WebviewGpuDisabled: false, WebviewGpuDisabled: false,
// Class name for the window. If empty, 'wailsWindow' will be used.
WindowClassName: "MyWindow",
}, },
Mac: &mac.Options{ Mac: &mac.Options{
TitleBar: &mac.TitleBar{ TitleBar: &mac.TitleBar{
@ -804,6 +806,13 @@ Setting this to `true` will enable swipe gestures for the webview.
Name: EnableSwipeGestures<br/> Name: EnableSwipeGestures<br/>
Type: `bool` Type: `bool`
#### WindowClassName
Class name for the window. If empty, 'wailsWindow' will be used.
Name: WindowClassName<br/>
Type: `string`
### Mac ### Mac
This defines [Mac specific options](#mac). This defines [Mac specific options](#mac).

View File

@ -13,6 +13,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- `Security` in case of vulnerabilities. - `Security` in case of vulnerabilities.
## [Unreleased] ## [Unreleased]
### Added
- Added option to set window class name on Windows. Added in [PR](https://github.com/wailsapp/wails/pull/3828) by @APshenkin
### Fixed ### Fixed
- Fixed cross compilation failed with CGO [PR](https://github.com/wailsapp/wails/pull/3795) by [@fcying](https://github.com/fcying) - Fixed cross compilation failed with CGO [PR](https://github.com/wailsapp/wails/pull/3795) by [@fcying](https://github.com/fcying)