Exception in TOpenDialog when closing program

247 views Asked by At

When I use TOpenDialog, after closing the program, there is an exception in the Vcl.Forms module.

Program I'm using:

std::auto_ptr<TOpenDialog> OpenDialog (new TOpenDialog(this));
if ( OpenDialog->Execute() ){}

Exception: 'access violation at 0x008133a4: read of address 0x000000c4'

Highlighted is line: if not FHandleCreated then

function TApplication.GetDialogHandle: HWND;
begin
  if not FHandleCreated then
    Result := SendMessage(Handle, CM_DIALOGHANDLE, 1, 0)
  else
    Result := FDialogHandle;
end;
3

There are 3 answers

0
Grzegorz Majcher On

Another possible workaround is to set the option ofOldStyleDialog. The dialog looks old-style but has colors compatible with Widows Themes.

OpenDialog1->Options << ofOldStyleDialog;
0
vitaly On

I confirm this issue. I have project that uses TOpenDialog component. There was no problem with RAD C++ Builder 10.2 (Tokyo). But now I get same error after upgrading to RAD C++ Builder 10.4 Update 2 (Sydney). I don't use dynamic creation TOpenDialog with auto_ptr. Instead, I just dragged component on my form. So code is very simple:

if(!OpenDialog1->Execute())
     return;

It's enough to open this dialog, do nothing, press cancel and then close app. After that I got the same access violation like Jacek had. So problem is in C++ Builder 10.4

UPDATE: The problem is not in C++ Builder 10.4 itself. The error raises when application uses Custom Styles (Themes). I just disabled Custom Styles in my app and there is no error with OpenDialog.

0
Harri Luoma On

One possible workaround is to disable styling for common dialogs:

TStyleManager::SystemHooks = TStyleManager::SystemHooks >> TStyleManager::TSystemHook::shDialogs;