Recent

Author Topic: [SOLVED] TPicture.Create keep failing with exception  (Read 357 times)

Gizmo

  • Hero Member
  • *****
  • Posts: 831
[SOLVED] TPicture.Create keep failing with exception
« on: October 25, 2022, 01:10:36 pm »
Hi

A friend and I are 'simply' trying to use TPicture.Create but the creation keep failing with an exception. We are using it as part of a DLL project. Not a standard application. I tried changing the widgetset to fpNoGui instead of the standard "Win32" in case that was the reason for rsNoWidgetSet being passed. But then it wouldn't compile saying fpg_main fpguicrosshelpers couldn't be found and I couldn't find fpg_main in the package list. I tried adding "LCL" package to the project dependancy. LCLBase was already in it.   

Code: Pascal  [Select][+][-]
  1. var
  2.   MyPic : TPicture;
  3. begin
  4. ...
  5.   MyPic := TPicture.Create;  // *** FAILS
  6. ...
  7. end;
  8.  
Going through the debugger, the problem arises on line 185 of LCLIntf in PredefinedClipboardFormat, after the call to TPicClipboardFormats.Create by TPicture.Create

Code: Pascal  [Select][+][-]
  1. function PredefinedClipboardFormat(AFormat: TPredefinedClipboardFormat): TClipboardFormat;
  2. begin
  3.   if FPredefinedClipboardFormats[AFormat]=0 then begin
  4.     if WidgetSet=nil then
  5.       raise Exception.Create(rsNoWidgetSet);  // *** EXCEPTION RAISED HERE *** WidgetSet does equal 0
  6.     FPredefinedClipboardFormats[AFormat]:=
  7.       ClipboardRegisterFormat(PredefinedClipboardMimeTypes[AFormat]);
  8.   end;
  9.   Result:=FPredefinedClipboardFormats[AFormat];
  10. end;      
  11.  

If I create a new, blank project, and call it, it works fine.

Can anyone help me work out where to go next here? I can't for the life of me see what it is failing.
« Last Edit: October 25, 2022, 07:02:42 pm by Gizmo »

Gizmo

  • Hero Member
  • *****
  • Posts: 831
Re: [SOLVED] TPicture.Create keep failing with exception
« Reply #1 on: October 25, 2022, 07:03:21 pm »
Thanks to this older thread (https://forum.lazarus.freepascal.org/index.php?topic=30463.0) I realised that the correct, case sensitive, uses clause I needed to add to my projects was "Interfaces". Did that and it worked fine!

 

TinyPortal © 2005-2018