5
0
mirror of https://github.com/wailsapp/wails.git synced 2025-05-02 04:09:46 +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
winc.RegClassOnlyOnce("wailsWindow")
handle := winc.CreateWindow("wailsWindow", parent, uint(exStyle), uint(dwStyle))
windowClassName := "wailsWindow"
if windowsOptions != nil && windowsOptions.WindowClassName != "" {
windowClassName = windowsOptions.WindowClassName
}
winc.RegClassOnlyOnce(windowClassName)
handle := winc.CreateWindow(windowClassName, parent, uint(exStyle), uint(dwStyle))
result.SetHandle(handle)
winc.RegMsgHandler(result)
result.SetParent(parent)

View File

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

View File

@ -99,7 +99,9 @@ func main() {
// OnResume is called when Windows resumes from low power mode
OnResume: func(),
// 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{
TitleBar: &mac.TitleBar{
@ -322,7 +324,7 @@ If not defined, the result is the following in cases where the Handler would hav
:::info
This does not work with vite v5.0.0+ and wails v2 due to changes in vite.
This does not work with vite v5.0.0+ and wails v2 due to changes in vite.
Changes are planned in v3 to support similar functionality under vite v5.0.0+.
If you need this feature, stay with vite v4.0.0+.
See [issue 3240](https://github.com/wailsapp/wails/issues/3240) for details
@ -804,6 +806,13 @@ Setting this to `true` will enable swipe gestures for the webview.
Name: EnableSwipeGestures<br/>
Type: `bool`
#### WindowClassName
Class name for the window. If empty, 'wailsWindow' will be used.
Name: WindowClassName<br/>
Type: `string`
### 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.
## [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 cross compilation failed with CGO [PR](https://github.com/wailsapp/wails/pull/3795) by [@fcying](https://github.com/fcying)