What with types? lazarus / 8-Other ---------------------------------------------------------------------- Girla · 2005-12-02 15:17 I tryed to port some code from Delphi: ... uses   Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,   Variants,  StdCtrls, Db, DBCtrls, Buttons, ExtCtrls, Menus, ComCtrls, CommCtrl,  Imglist, calendar, lmessages, lcltype; .... implementation uses Math, Types; .... procedure Some; var   DC: HDC;   SysMetrics: TTextMetric; begin ....   GetTextMetrics(DC, SysMetrics); .... end; When compiled, I receive error: call by var parameters have to match exactly: Got "tagTextMetricA" expected "TEXTMETRIC" OK, When I tryed to examine problem, I found that function GetTextMetrics in redef.inc: function GetTextMetrics(DC: HDC; var TM: TTextMetric): BOOL;external 'gdi32' name 'GetTextMetricsA'; has var TM type of TTextMetric that refer to definition in struct.inc:   TTEXTMETRIC = TEXTMETRIC;   TEXTMETRIC = record   ...   end; But! In my Procedure I has var SysMetrics type of TTextMetric; too, of course. In this case it refer to definition in LCLType.pp:   TTextMetric = TTextMetricA;   TTextMetricA = tagTEXTMETRICA;   tagTextMetricA = record   ...   end; And TEXTMETRIC record and tagTextMetricA has same structure. What wrong? Thanks. ---------------------------------------------------------------------- Phil · 2005-12-02 21:28 I believe this is because TTextMetric is defined in both the Windows and LclType units, but defined differently. A quick fix should be to declare LclType before Windows in the uses clause. A longer term fix is to decide whether to use the Windows and Messages units or the LCL cross-platform equivalents, LclIntf, LclType and LMessages. If you continue to use the Windows unit, you'll probably end up hitting other differences like this. In my cross-platform apps, I don't use the Windows or Messages units at all. ---------------------------------------------------------------------- Girla · 2005-12-25 09:33 Thank you, Phil. This application is not cross-platform. TTextMetric is absolutely equal in both cases. Problem is that 1) the ways to it definition is different, through some units 2) One part of this code Windows unit required only, another LclType. Only solution that I see is rewrite code because it can't directly port from Delphi in this case. ---------------------------------------------------------------------- marquessbr · 2009-05-05 12:15 Very Thank you, Phil! solve my problem. good look! ---------------------------------------------------------------------- Rave · 2009-05-05 17:24 I have another type-related question. My friend sent me a code which contains TLibHandle type. Somebody knows where is this type declared? ---------------------------------------------------------------------- Vincent Snijders · 2009-05-06 12:10 It is declared in unit dynlibs;