mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-15 20:59:06 +02:00
Dialogs: conditional debug output for TCommonDialog events
git-svn-id: trunk@52789 -
This commit is contained in:
parent
8a444a31ef
commit
6b0c4428ec
@ -119,20 +119,28 @@ begin
|
|||||||
if Assigned(FOnShow) then
|
if Assigned(FOnShow) then
|
||||||
FOnShow(Self);
|
FOnShow(Self);
|
||||||
TWSCommonDialogClass(WidgetSetClass).ShowModal(Self);
|
TWSCommonDialogClass(WidgetSetClass).ShowModal(Self);
|
||||||
//if (Self is TFileDialog) debugln(['TCommonDialog.DoExecute, FCanCloseCalled=',FCanCloseCalled,' FUserChoice=',ModalResultStr[FUserChoice]]);
|
{$ifdef DebugCommonDialogEvents}
|
||||||
|
if (Self is TFileDialog) then debugln(['TCommonDialog.DoExecute, FCanCloseCalled=',FCanCloseCalled,' FUserChoice=',ModalResultStr[FUserChoice]]);
|
||||||
|
{$endif}
|
||||||
// can close was called from widgetset loop
|
// can close was called from widgetset loop
|
||||||
if not FCanCloseCalled then
|
if not FCanCloseCalled then
|
||||||
begin
|
begin
|
||||||
repeat
|
repeat
|
||||||
//if (Self is TFileDialog) then debugln(['TCommonDialog.DoExecute, FUserChoice=',ModalResultStr[FUserChoice],' Handle=',Handle]);
|
{$ifdef DebugCommonDialogEvents}
|
||||||
|
if (Self is TFileDialog) then debugln(['TCommonDialog.DoExecute, FUserChoice=',ModalResultStr[FUserChoice],' Handle=',Handle]);
|
||||||
|
{$endif}
|
||||||
if (FUserChoice <> mrNone) and (Handle<>0) then
|
if (FUserChoice <> mrNone) and (Handle<>0) then
|
||||||
begin
|
begin
|
||||||
CanClose := True;
|
CanClose := True;
|
||||||
//if (Self is TFileDialog) debugln(['TCommonDialog.DoExecute calling DoCanClose']);
|
{$ifdef DebugCommonDialogEvents}
|
||||||
|
if (Self is TFileDialog) then debugln(['TCommonDialog.DoExecute calling DoCanClose']);
|
||||||
|
{$endif}
|
||||||
DoCanClose(CanClose);
|
DoCanClose(CanClose);
|
||||||
if not CanClose then
|
if not CanClose then
|
||||||
FUserChoice:=mrNone;
|
FUserChoice:=mrNone;
|
||||||
//if (Self is TFileDialog) then debugln(['TCommonDialog.DoExecute after calling DoCanClose: CanClose=',CanClose,' FUserChoice=',ModalResultStr[FUserChoice]]);
|
{$ifdef DebugCommonDialogEvents}
|
||||||
|
if (Self is TFileDialog) then debugln(['TCommonDialog.DoExecute after calling DoCanClose: CanClose=',CanClose,' FUserChoice=',ModalResultStr[FUserChoice]]);
|
||||||
|
{$endif}
|
||||||
end;
|
end;
|
||||||
if FUserChoice <> mrNone then
|
if FUserChoice <> mrNone then
|
||||||
break;
|
break;
|
||||||
|
@ -37,7 +37,9 @@ end;
|
|||||||
|
|
||||||
procedure TFileDialog.DoCanClose(var CanClose: Boolean);
|
procedure TFileDialog.DoCanClose(var CanClose: Boolean);
|
||||||
begin
|
begin
|
||||||
//debugln(['TFileDialog.DoCanClose: FUserChoice = ',ModalResultStr[FUserChoice],' HandleAllocated=',HandleAllocated]);
|
{$ifdef DebugCommonDialogEvents}
|
||||||
|
debugln(['TFileDialog.DoCanClose: FUserChoice = ',ModalResultStr[FUserChoice],' HandleAllocated=',HandleAllocated]);
|
||||||
|
{$endif}
|
||||||
//Only call OnCanClose if user did not cancel the dialog, see:
|
//Only call OnCanClose if user did not cancel the dialog, see:
|
||||||
//http://docwiki.embarcadero.com/Libraries/Berlin/en/Vcl.Dialogs.TOpenDialog_Events
|
//http://docwiki.embarcadero.com/Libraries/Berlin/en/Vcl.Dialogs.TOpenDialog_Events
|
||||||
if (FUserChoice = mrOK) then
|
if (FUserChoice = mrOK) then
|
||||||
|
@ -328,6 +328,7 @@ begin
|
|||||||
Result := (WindowsVersion >= wvVista) and not (ofOldStyleDialog in AOpenDialog.Options);
|
Result := (WindowsVersion >= wvVista) and not (ofOldStyleDialog in AOpenDialog.Options);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
{ TWin32WSColorDialog }
|
{ TWin32WSColorDialog }
|
||||||
|
|
||||||
class function TWin32WSColorDialog.CreateHandle(const ACommonDialog: TCommonDialog): THandle;
|
class function TWin32WSColorDialog.CreateHandle(const ACommonDialog: TCommonDialog): THandle;
|
||||||
@ -532,9 +533,13 @@ begin
|
|||||||
ExtractDataFromNotify;
|
ExtractDataFromNotify;
|
||||||
CanClose := True;
|
CanClose := True;
|
||||||
TOpenDialog(DlgRec^.Dialog).UserChoice := mrOK;
|
TOpenDialog(DlgRec^.Dialog).UserChoice := mrOK;
|
||||||
//debugln(['OpenFileDialogCallBack calling DoCanClose']);
|
{$ifdef DebugCommonDialogEvents}
|
||||||
|
debugln(['OpenFileDialogCallBack calling DoCanClose']);
|
||||||
|
{$endif}
|
||||||
TOpenDialog(DlgRec^.Dialog).DoCanClose(CanClose);
|
TOpenDialog(DlgRec^.Dialog).DoCanClose(CanClose);
|
||||||
//debugln(['OpenFileDialogCallBack CanClose=',CanClose]);
|
{$ifdef DebugCommonDialogEvents}
|
||||||
|
debugln(['OpenFileDialogCallBack CanClose=',CanClose]);
|
||||||
|
{$endif}
|
||||||
if not CanClose then
|
if not CanClose then
|
||||||
begin
|
begin
|
||||||
//the dialog window will not process the click on OK button
|
//the dialog window will not process the click on OK button
|
||||||
@ -605,7 +610,9 @@ var
|
|||||||
FileNameWideBuffer: PWideChar;
|
FileNameWideBuffer: PWideChar;
|
||||||
FileNameBufferSize: Integer;
|
FileNameBufferSize: Integer;
|
||||||
begin
|
begin
|
||||||
//debugln(['CreateFileDialogHandle A']);
|
{$ifdef DebugCommonDialogEvents}
|
||||||
|
debugln(['CreateFileDialogHandle A']);
|
||||||
|
{$endif}
|
||||||
FileName := AOpenDialog.FileName;
|
FileName := AOpenDialog.FileName;
|
||||||
InitialDir := AOpenDialog.InitialDir;
|
InitialDir := AOpenDialog.InitialDir;
|
||||||
if (FileName <> '') and (FileName[length(FileName)] = PathDelim) then
|
if (FileName <> '') and (FileName[length(FileName)] = PathDelim) then
|
||||||
@ -661,7 +668,9 @@ begin
|
|||||||
lCustData := LParam(DialogRec);
|
lCustData := LParam(DialogRec);
|
||||||
end;
|
end;
|
||||||
Result := THandle(OpenFile);
|
Result := THandle(OpenFile);
|
||||||
//debugln(['CreateFileDialogHandle End']);
|
{$ifdef DebugCommonDialogEvents}
|
||||||
|
debugln(['CreateFileDialogHandle End']);
|
||||||
|
{$endif}
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure DestroyFileDialogHandle(AHandle: THandle);
|
procedure DestroyFileDialogHandle(AHandle: THandle);
|
||||||
@ -867,13 +876,17 @@ var
|
|||||||
Cookie: DWord;
|
Cookie: DWord;
|
||||||
//CanClose: Boolean;
|
//CanClose: Boolean;
|
||||||
begin
|
begin
|
||||||
|
{$ifdef DebugCommonDialogEvents}
|
||||||
debugln('TWin32WSOpenDialog.VistaDialogShowModal A');
|
debugln('TWin32WSOpenDialog.VistaDialogShowModal A');
|
||||||
|
{$endif}
|
||||||
FileDialogEvents := TFileDialogEvents.Create(AOpenDialog);
|
FileDialogEvents := TFileDialogEvents.Create(AOpenDialog);
|
||||||
ADialog.Advise(FileDialogEvents, @Cookie);
|
ADialog.Advise(FileDialogEvents, @Cookie);
|
||||||
try
|
try
|
||||||
AOpenDialog.DoShow;
|
AOpenDialog.DoShow;
|
||||||
ADialog.Show(GetParentWnd);
|
ADialog.Show(GetParentWnd);
|
||||||
|
{$ifdef DebugCommonDialogEvents}
|
||||||
debugln(['TWin32WSOpenDialog.VistaDialogShowModal: AOpenDialog.UserChoice = ',ModalResultStr[AOpenDialog.UserChoice]]);
|
debugln(['TWin32WSOpenDialog.VistaDialogShowModal: AOpenDialog.UserChoice = ',ModalResultStr[AOpenDialog.UserChoice]]);
|
||||||
|
{$endif}
|
||||||
//DoOnClose is called from TFileDialogEvents.OnFileOk if user pressed OK
|
//DoOnClose is called from TFileDialogEvents.OnFileOk if user pressed OK
|
||||||
//Do NOT call DoCanClose if user cancels the dialog
|
//Do NOT call DoCanClose if user cancels the dialog
|
||||||
//see http://docwiki.embarcadero.com/Libraries/Berlin/en/Vcl.Dialogs.TOpenDialog_Events
|
//see http://docwiki.embarcadero.com/Libraries/Berlin/en/Vcl.Dialogs.TOpenDialog_Events
|
||||||
@ -886,7 +899,9 @@ begin
|
|||||||
ADialog.unadvise(Cookie);
|
ADialog.unadvise(Cookie);
|
||||||
FileDialogEvents := nil;
|
FileDialogEvents := nil;
|
||||||
end;
|
end;
|
||||||
//debugln('TWin32WSOpenDialog.VistaDialogShowModal End');
|
{$ifdef DebugCommonDialogEvents}
|
||||||
|
debugln('TWin32WSOpenDialog.VistaDialogShowModal End');
|
||||||
|
{$endif}
|
||||||
end;
|
end;
|
||||||
|
|
||||||
class function TWin32WSOpenDialog.GetParentWnd: HWND;
|
class function TWin32WSOpenDialog.GetParentWnd: HWND;
|
||||||
@ -955,10 +970,14 @@ begin
|
|||||||
end
|
end
|
||||||
else
|
else
|
||||||
begin
|
begin
|
||||||
//debugln(['TWin32WSOpenDialog.ShowModal before ProcessFileDialogResults']);
|
{$ifdef DebugCommonDialogEvents}
|
||||||
|
debugln(['TWin32WSOpenDialog.ShowModal before ProcessFileDialogResults']);
|
||||||
|
{$endif}
|
||||||
ProcessFileDialogResult(TOpenDialog(ACommonDialog),
|
ProcessFileDialogResult(TOpenDialog(ACommonDialog),
|
||||||
GetOpenFileNameW(LPOPENFILENAME(ACommonDialog.Handle)));
|
GetOpenFileNameW(LPOPENFILENAME(ACommonDialog.Handle)));
|
||||||
//debugln(['TWin32WSOpenDialog.ShowModal after ProcessFileDialogResults, UserChoice=',ModalResultStr[TOpenDialog(ACommonDialog).UserChoice]]);
|
{$ifdef DebugCommonDialogEvents}
|
||||||
|
debugln(['TWin32WSOpenDialog.ShowModal after ProcessFileDialogResults, UserChoice=',ModalResultStr[TOpenDialog(ACommonDialog).UserChoice]]);
|
||||||
|
{$endif}
|
||||||
end;
|
end;
|
||||||
finally
|
finally
|
||||||
SetCurrentDirUTF8(lOldWorkingDir);
|
SetCurrentDirUTF8(lOldWorkingDir);
|
||||||
@ -1246,13 +1265,17 @@ function TFileDialogEvents.OnFileOk(pfd: IFileDialog): HResult; stdcall;
|
|||||||
var
|
var
|
||||||
CanClose: Boolean;
|
CanClose: Boolean;
|
||||||
begin
|
begin
|
||||||
//debugln('TFileDialogEvents.OnFileOk A');
|
{$ifdef DebugCommonDialogEvents}
|
||||||
|
debugln('TFileDialogEvents.OnFileOk A');
|
||||||
|
{$endif}
|
||||||
Result := TWin32WSOpenDialog.ProcessVistaDialogResult(pfd, FDialog);
|
Result := TWin32WSOpenDialog.ProcessVistaDialogResult(pfd, FDialog);
|
||||||
if Succeeded(Result) then
|
if Succeeded(Result) then
|
||||||
begin
|
begin
|
||||||
FDialog.UserChoice := mrOK; //DoCanClose needs this
|
FDialog.UserChoice := mrOK; //DoCanClose needs this
|
||||||
CanClose := True;
|
CanClose := True;
|
||||||
//debugln('TFileDialogEvents.OnFileOk: calling DoCanClose');
|
{$ifdef DebugCommonDialogEvents}
|
||||||
|
debugln('TFileDialogEvents.OnFileOk: calling DoCanClose');
|
||||||
|
{$endif}
|
||||||
FDialog.DoCanClose(CanClose);
|
FDialog.DoCanClose(CanClose);
|
||||||
if CanClose then
|
if CanClose then
|
||||||
begin
|
begin
|
||||||
@ -1261,7 +1284,9 @@ begin
|
|||||||
else
|
else
|
||||||
Result := S_FALSE;
|
Result := S_FALSE;
|
||||||
end;
|
end;
|
||||||
//debugln('TFileDialogEvents.OnFileOk End');
|
{$ifdef DebugCommonDialogEvents}
|
||||||
|
debugln('TFileDialogEvents.OnFileOk End');
|
||||||
|
{$endif}
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function TFileDialogEvents.OnFolderChanging(pfd: IFileDialog; psifolder: IShellItem): HResult; stdcall;
|
function TFileDialogEvents.OnFolderChanging(pfd: IFileDialog; psifolder: IShellItem): HResult; stdcall;
|
||||||
|
Loading…
Reference in New Issue
Block a user