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

Add option to disable min/max windows buttons

This commit introduces the functionality to disable the minimise and maximise buttons on windows. These options have been added to the `application.WebviewWindowOptions` and integrated in the Windows application logic. Effectively, developers can now control the availability of these buttons in their windows applications.
This commit is contained in:
Lea Anthony 2024-02-07 08:45:14 +11:00
parent 0584a3929d
commit 0b82968c0f
No known key found for this signature in database
GPG Key ID: 33DAF7BB90A58405
3 changed files with 39 additions and 0 deletions

View File

@ -60,6 +60,35 @@ func main() {
Show()
windowCounter++
})
if runtime.GOOS != "linux" {
myMenu.Add("New WebviewWindow (Disable Minimise)").
OnClick(func(ctx *application.Context) {
app.NewWebviewWindowWithOptions(application.WebviewWindowOptions{
Windows: application.WindowsWindow{
DisableMinimiseButton: true,
},
}).
SetTitle("WebviewWindow "+strconv.Itoa(windowCounter)).
SetRelativePosition(rand.Intn(1000), rand.Intn(800)).
SetURL("https://wails.io").
Show()
windowCounter++
})
myMenu.Add("New WebviewWindow (Disable Maximise)").
OnClick(func(ctx *application.Context) {
app.NewWebviewWindowWithOptions(application.WebviewWindowOptions{
Windows: application.WindowsWindow{
DisableMaximiseButton: true,
},
}).
SetTitle("WebviewWindow "+strconv.Itoa(windowCounter)).
SetRelativePosition(rand.Intn(1000), rand.Intn(800)).
SetURL("https://wails.io").
Show()
windowCounter++
})
}
myMenu.Add("New WebviewWindow (Hides on Close one time)").
SetAccelerator("CmdOrCtrl+H").
OnClick(func(ctx *application.Context) {

View File

@ -117,6 +117,12 @@ type WindowsWindow struct {
// Permissions map for WebView2. If empty, default permissions will be granted.
Permissions map[CoreWebView2PermissionKind]CoreWebView2PermissionState
// Disables the minimise button
DisableMinimiseButton bool
// Disables the maximise button
DisableMaximiseButton bool
}
type Theme int

View File

@ -237,6 +237,10 @@ func (w *windowsWebviewWindow) run() {
w.setSize(options.Width, options.Height)
// Min/max buttons
w.setStyle(!options.Windows.DisableMinimiseButton, w32.WS_MINIMIZEBOX)
w.setStyle(!options.Windows.DisableMaximiseButton, w32.WS_MAXIMIZEBOX)
// Register the window with the application
getNativeApplication().registerWindow(w)