[Lazarus] Inconsistent result from MessageDlg

Bart bartjunk64 at gmail.com
Fri Aug 19 12:25:44 CEST 2011


Hi all,

While investigating issue #19863 in the bugtracker
(http://bugs.freepascal.org/view.php?id=19863) I stumbled upon this.

If you have a MessageDlg (without a mrCancel button) and you click the
"Close" border-icon of the dialog then the result now depends on your
OS (on Windows that is)

On Windows Vista (and up) the result will be "EscapeResult" (user
presses Escape key: the result depends on the actual buttons in the
dialog: it will be mrNo if you have [mbYes,mbNo] as buttons).
On lower Windows versions it will be mrCancel always.

The cause lies in the WidgetSet.PromptUser() function:

In WidgetSet.PromptUser we do not correct for CancelValue

...
  if PromptDialogFunction <> nil then
    Result := PromptDialogFunction(DialogCaption, DialogMessage, DialogType,
       Buttons, ButtonCount, DefaultIndex, EscapeResult, True, 0, 0)


in TWin32WidgetSet.PromptUser we do correct for it:
...
      Result := IDCANCEL;
      TaskDialogIndirect(@TaskConfig, @Result, nil, nil);
      if Result = IDCANCEL then
        Result := EscapeResult;

To me it makes more sense that pressing Escape key and clicking the
"Close" border-icon will give the same result.


At least we should make it behave consistently.

Any opinions on how we want it to behave (or how it "must" behave)?

Bart




More information about the Lazarus mailing list