[fpc-pascal]About order of units...

L D Blake ldblake at sympatico.ca
Sat Aug 30 20:23:56 CEST 2003


In reply to your message of August 30, 2003

> Yes. Identifiers in Windows unit will be hidden by same identifiers in
> WinFix unit.

Ok... I was pretty sure that would work.  And as you point out so well I'm
aware that it's stopgap at best.

The real problem here is types declared in the windows unit where, as I
pointed out previously, LongInt has been confused with BYTE, WORD and LONGWORD
types...  In continuing to fuss with this I checked the definitions of several
structures in struct.inc and found the MSG declaration corrupted...

     MSG = record
          hwnd : HWND;
          message : UINT;
          wParam : WPARAM;
          lParam : LPARAM;
          time : DWORD;
          pt : POINT;
       end;

In Base.inc ... HWND is defined as a longint, wparam is cardinal, lparam is
longint and dword is cardinal.  Not only could this result in negative message
numbers being passed to windproc or defwndproc, it could result in message
packets of varying sizes... disastrous when you realize windows is accessing
variables as an offset from a pointer.

Redeclaring MSG in my own code as

    MSG = record
          hwnd    : LongWord;
          message : LongInt;
          wParam  : LongWord;
          lParam  : LongWord;
          time    : LongWord;
          pt      : POINT;
       end;

Got me an almost 3 hour run before my software messed up again.

Looking furter for the message declarations (wm_command etc.), message.inc
reveals several blocks like this:

     NM_CLICK = -(2);
     NM_DBLCLK = -(3);
     NM_KILLFOCUS = -(8);
     NM_OUTOFMEMORY = -(1);
     NM_RCLICK = -(5);
     NM_RDBLCLK = -(6);
     NM_RETURN = -(4);
     NM_SETFOCUS = -(7);

Now, not only do we have the possibility of negative handles, we have negative
values for messages?  Are these values correct or are these the result of
futzing about trying to get around the incorrect declarations?

-----
 L D Blake





More information about the fpc-pascal mailing list