diff --git a/declarative/dialog.go b/declarative/dialog.go index ca6fee4b..915ba1fa 100644 --- a/declarative/dialog.go +++ b/declarative/dialog.go @@ -31,10 +31,19 @@ type Dialog struct { Children []Widget DefaultButton **walk.PushButton CancelButton **walk.PushButton + FixedSize bool } func (d Dialog) Create(owner walk.Form) error { - w, err := walk.NewDialog(owner) + var w *walk.Dialog + var err error + + if d.FixedSize { + w, err = walk.NewDialogWithFixedSize(owner) + } else { + w, err = walk.NewDialog(owner) + } + if err != nil { return err } @@ -86,7 +95,9 @@ func (d Dialog) Create(owner walk.Form) error { } if db := *d.DataBinder.AssignTo; db != nil { - (*d.DefaultButton).SetEnabled(db.CanSubmit()) + if db.DataSource() != nil { + (*d.DefaultButton).SetEnabled(db.CanSubmit()) + } db.CanSubmitChanged().Attach(func() { (*d.DefaultButton).SetEnabled(db.CanSubmit()) diff --git a/dialog.go b/dialog.go index e039bbe2..ef9a3025 100644 --- a/dialog.go +++ b/dialog.go @@ -49,6 +49,14 @@ type Dialog struct { } func NewDialog(owner Form) (*Dialog, error) { + return newDialogWithStyle(owner, win.WS_THICKFRAME) +} + +func NewDialogWithFixedSize(owner Form) (*Dialog, error) { + return newDialogWithStyle(owner, 0) +} + +func newDialogWithStyle(owner Form, style uint32) (*Dialog, error) { dlg := &Dialog{ FormBase: FormBase{ owner: owner, @@ -59,7 +67,7 @@ func NewDialog(owner Form) (*Dialog, error) { dlg, owner, dialogWindowClass, - win.WS_CAPTION|win.WS_SYSMENU|win.WS_THICKFRAME, + win.WS_CAPTION|win.WS_SYSMENU|style, win.WS_EX_DLGMODALFRAME); err != nil { return nil, err }