Recent

Author Topic: Actions and Reslts  (Read 660 times)

TRon

  • Hero Member
  • *****
  • Posts: 1841
Re: Actions and Reslts
« Reply #15 on: June 05, 2023, 10:52:22 am »
@wp: if I check your app on Linux with 2.2.4 then I get an operation was cancelled messagebox when selecting cancel or no and after canceling the savedialog. I take it that is the intended behaviour ?

edit: same results as above with trunk Lazarus.
« Last Edit: June 05, 2023, 10:58:36 am by TRon »

wp

  • Hero Member
  • *****
  • Posts: 11445
Re: Actions and Reslts
« Reply #16 on: June 05, 2023, 11:13:35 am »
@wp: if I check your app on Linux with 2.2.4 then I get an operation was cancelled messagebox when selecting cancel or no and after canceling the savedialog. I take it that is the intended behaviour ?
Yes. That's fine because it tells me that the bug is not in the general TFileDialog/TCommonDialog code, but in the win32 widgetset code. And in fact there is the win32-specific function TFileDialogEvents.OnFileOK which does not reset the FDialog.UserChoice in case of CanClose is false. With the following modification, the overall behaviour is correct, on Windows:
Code: Pascal  [Select][+][-]
  1. function TFileDialogEvents.OnFileOk(pfd: IFileDialog): HResult; stdcall;  // removed the {$ifdef...} instructions
  2. var
  3.   CanClose: Boolean;
  4. begin
  5.   Result := TWin32WSOpenDialog.ProcessVistaDialogResult(pfd, FDialog);
  6.   if Succeeded(Result) then
  7.   begin
  8.     FDialog.UserChoice := mrOK; //DoCanClose needs this
  9.     CanClose := True;
  10.     FDialog.DoCanClose(CanClose);
  11.     if CanClose then
  12.     begin
  13.       Result := S_OK;
  14.     end
  15.     else
  16.     begin
  17.       FDialog.UserChoice := mrNone;   // <---- ADDED
  18.       Result := S_FALSE;
  19.     end;
  20.   end;
  21. end;

[EDIT]
Filed a bug report for documentation (https://gitlab.com/freepascal.org/lazarus/lazarus/-/issues/40297), and committed above fix to Laz/main.
« Last Edit: June 05, 2023, 01:04:39 pm by wp »

 

TinyPortal © 2005-2018