Failed to create win32 control lazarus / 31-LCL ---------------------------------------------------------------------- BeniBela · 2020-01-05 12:43 Several users have reported getting  "Failed to create win32 control, error: 0" messages from my app when opening a dialog. It is a very simple dialog opened with create and showmodal. What could cause that? It has never happened on my computer, neither with wine or in a vm I have a custom high dpi scaling, could that cause problems? Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i procedure TVideLibriForm.DoCreate; //overrides TCustomForm.DoCreateconst REFERENCE_FONT = 19; //19 on Linux, 15 on Windows for the same DPIvar  fontHeight: Integer;  bounds, oldbounds: TRect;begin  guiScaleFactor := 1;  fontHeight := Canvas.GetTextHeight('Hm,.|');   oldbounds := GetRealBounds;  bounds := oldbounds;  LockRealizeBounds;  if fontHeight > REFERENCE_FONT then begin    guiScaleFactor := fontHeight / REFERENCE_FONT;    bounds.Width := MulDiv(bounds.Width, fontHeight, REFERENCE_FONT);    bounds.Height := MulDiv(bounds.Height, fontHeight, REFERENCE_FONT);  end;   //these basically only call SetBoundsKeepBase();  MyAutoPlacement(bounds, oldBounds);  if fontHeight > REFERENCE_FONT then    videLibriScale(self);   inherited DoCreate;   UnlockRealizeBounds;end; ---------------------------------------------------------------------- MarkMLl · 2020-01-05 12:52 Can you give us any indication at all of what OSes these users are running (i.e. Windows versions)? When did the problem start? MarkMLl ---------------------------------------------------------------------- BeniBela · 2020-01-05 13:06 Quote from: MarkMLl on January 05, 2020, 01:52:00 pmCan you give us any indication at all of what OSes these users are running (i.e. Windows versions)? Windows 10, 64-bit, one said Quote from: MarkMLl on January 05, 2020, 01:52:00 pmWhen did the problem start? We do not know. That dialog form is only used to show an error message. If everything else works, the dialog is never opened. Now the problem started, because a server was changed, which causes it do show an error message saying what was changed. But the dialog might have been failing for years ---------------------------------------------------------------------- marcov · 2020-01-05 13:16 Seems you touch canvas before running inherited docreate? Not entirely logical. ---------------------------------------------------------------------- BeniBela · 2020-01-05 14:25 Not very logical, but when I tested it, it worked well to get the real font size ---------------------------------------------------------------------- MarkMLl · 2020-01-05 14:55 For some definition of "well" :-) Does it work /better/ if you heed marcov's advice? MarkMLl ---------------------------------------------------------------------- BeniBela · 2020-01-05 23:03 I need another way to get the font size. Font.GetTextWidth does not work. I could create a temporary bitmap? But I cannot test it. It might take days/weeks to get user feedback ---------------------------------------------------------------------- winni · 2020-01-05 23:56 Hi! If you changed the default values of the font already then you have to initialize then canvas of the font. As @marcov said: inheritate before reading from the font. If it is just the default font: the size is 10 pt. That results in a height of 13 px. Since years. Winni ---------------------------------------------------------------------- BeniBela · 2020-01-06 10:18 Quote from: winni on January 06, 2020, 12:56:01 am As @marcov said: inheritate before reading from the font. DoCreate calls OnCreate, it does not actually create anything Quote from: winni on January 06, 2020, 12:56:01 amIf it is just the default font: the size is 10 pt. That results in a height of 13 px. Since years. The default font is different on every system, because the user can change the system font. On a system with multiple screens with different dpi, perhaps even every monitor has a different font I have size 10, but the canvas height is 19. Linux fonts tend to be larger than Windows fonts And font.size and font.height is always 0