func (dlg *Dialog) SetDefaultButton(button *PushButton) error { if button != nil && !win.IsChild(dlg.hWnd, button.hWnd) { return newError("not a descendant of the dialog") } succeeded := false if dlg.defaultButton != nil { if err := dlg.defaultButton.setAndClearStyleBits(win.BS_PUSHBUTTON, win.BS_DEFPUSHBUTTON); err != nil { return err } defer func() { if !succeeded { dlg.defaultButton.setAndClearStyleBits(win.BS_DEFPUSHBUTTON, win.BS_PUSHBUTTON) } }() } if button != nil { if err := button.setAndClearStyleBits(win.BS_DEFPUSHBUTTON, win.BS_PUSHBUTTON); err != nil { return err } } dlg.defaultButton = button succeeded = true return nil }
func (dlg *Dialog) SetCancelButton(button *PushButton) error { if button != nil && !win.IsChild(dlg.hWnd, button.hWnd) { return newError("not a descendant of the dialog") } dlg.cancelButton = button return nil }