Add AlwaysOnTop()

This commit is contained in:
Evan 2024-07-09 23:47:11 -04:00
parent c3f7e410c2
commit c0a5330968
2 changed files with 13 additions and 0 deletions

View File

@ -4,6 +4,7 @@ import (
"context" "context"
"github.com/ncruces/zenity/internal/win" "github.com/ncruces/zenity/internal/win"
"golang.org/x/sys/windows"
) )
func message(kind messageKind, text string, opts options) error { func message(kind messageKind, text string, opts options) error {
@ -52,6 +53,10 @@ func message(kind messageKind, text string, opts options) error {
} }
} }
if opts.alwaysOnTop {
flags |= windows.MB_SYSTEMMODAL
}
owner, _ := opts.attach.(win.HWND) owner, _ := opts.attach.(win.HWND)
defer setup(owner)() defer setup(owner)()
unhook, err := hookMessageDialog(opts) unhook, err := hookMessageDialog(opts)

View File

@ -39,6 +39,7 @@ func IsAvailable() bool {
type options struct { type options struct {
// General options // General options
title *string title *string
alwaysOnTop bool
width uint width uint
height uint height uint
okLabel *string okLabel *string
@ -115,6 +116,13 @@ func Title(title string) Option {
return funcOption(func(o *options) { o.title = &title }) return funcOption(func(o *options) { o.title = &title })
} }
// AlwaysOnTop returns an Option to set the dialog to be always on top (Windows only)..
func AlwaysOnTop(alwaysOnTop bool) Option {
return funcOption(func(o *options) {
o.alwaysOnTop = alwaysOnTop
})
}
// Width returns an Option to set the dialog width (Unix only). // Width returns an Option to set the dialog width (Unix only).
func Width(width uint) Option { func Width(width uint) Option {
return funcOption(func(o *options) { return funcOption(func(o *options) {