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:
parent
0584a3929d
commit
0b82968c0f
@ -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) {
|
||||
|
@ -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
|
||||
|
@ -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)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user