Jump to content
jesu

access violation changing font

Recommended Posts

Hello. Using 12.3 + patch 1. I'm seeing this error: 

Quote

Access violation at address 6F75232A in module 'COMCTL32.dll' (offset 2232A). Read of address 0000000C.

changing font at runtime. This is my code:

 

procedure TFprincipal.FontNameRClick(Sender: TObject);
begin
  ga_TipoLetra := FontNameR.Text;
  Font.Name := ga_TipoLetra;
  gn_FontSize := StrToInt(ComboSize.Text);
  Font.Size := gn_FontSize;
  Screen.MessageFont := Self.Font;
  ToolBar.Font.Size := Min(gn_FontSize, 14);
end;

The error happens at the end of that code in procedure TWinControl.DefaultHandler(var Message); inside VCL.Controls.
Is it a bug or should I do something different?

Thanks

Share this post


Link to post

From the posted code it is not clear what values are passed, for example what is assigned to "Font.name"? You need to find out which value is not right, start disabling some lines to see if the problem disappears.

Share this post


Link to post

I use this procedure to get installed fonts and allow to choose one:


 

procedure TFprincipal.GetFontNames;
var
  DC: HDC;
begin
  DC := GetDC(0);
  EnumFonts(DC, nil, @EnumFontsProc, Pointer(FontNameR.Items));
  ReleaseDC(0, DC);
  FontNameR.Sorted := True;
end;

but the problem seems to happen not when I change font name, but when I increase font size, and it doesn't happen always. If I choose a second time the same font size, the second time it seems to work.

 

Edited by jesu

Share this post


Link to post

try to monitor the values that are given to "font.size", or attach a simple project where we can check

Share this post


Link to post

My guess is that something you are doing elsewhere is corrupting memory and what you are seeing are just secondary errors.

You can probably use madExcept, with memory overrun check enabled, to find the origin of the problem.

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×