Never mind, I should have been setting the nGlyphs element of the GCP_RESULTS record to the number of characters I was sending, but had it set to 0.
 
Just to confirm though, in case anyone else wants to use this routine, that the correct import of this set of functions is as follows:
 
interface
....
{$EXTERNALSYM GetCharacterPlacementA}
function GetCharacterPlacementA(DC: HDC; p2: PAnsiChar; p3, p4: Integer;
  var p5: TGCPResults; p6: DWORD): DWORD; stdcall;
{$EXTERNALSYM GetCharacterPlacementW}
function GetCharacterPlacementW(DC: HDC; p2: PWideChar; p3, p4: Integer;
  var p5: TGCPResults; p6: DWORD): DWORD; stdcall;
{$EXTERNALSYM GetCharacterPlacement}
function GetCharacterPlacement(DC: HDC; p2: PChar; p3, p4: Integer;
  var p5: TGCPResults; p6: DWORD): DWORD; stdcall;
implementation
const
  gdi32     = 'gdi32.dll';
....
 
function GetCharacterPlacementA; external gdi32 name 'GetCharacterPlacementA';
function GetCharacterPlacementW; external gdi32 name 'GetCharacterPlacementW';
function GetCharacterPlacement; external gdi32 name 'GetCharacterPlacementA';
 
Phil.
 
----- Original Message -----
Sent: Wednesday, March 24, 2004 11:37 AM
Subject: [DUG] GetCharacterPlacement

Hi all,
 
I am trying to use the WinAPI function GetCharacterPlacement which is defined as:
DWORD GetCharacterPlacement(
    HDC hdc,                                  // handle to device context
    LPCTSTR lpString,                     // pointer to string
    int nCount,                                // number of characters in string
    int nMaxExtent,                         // maximum extent for displayed string
    LPGCP_RESULTS *lpResults,    // pointer to buffer for placement result
    DWORD dwFlags                       // placement flags
   ); 
I noticed that it seems to be incorrectly imported in the Windows.pas unit so I have redeclared it as follows:
{$EXTERNALSYM GetCharacterPlacement}
function GetCharacterPlacement(DC: HDC; p2: PChar; p3, p4: Integer;
  p5: PGCPResults; p6: DWORD): DWORD; stdcall;
I am calling this but it is failing and the getlasterror method returns 87 (invalid parameter).
I am setting the PGCPResults parameter to basically an empty structure (apart from the lStructSize element). I'm after the lpCaretPos information and have tried calling the routine with this element of the record set to point to an array of integer but still the same result.
 
Can anyone offer any insights? Have you used this before?
 
Cheers,
Phil.


_______________________________________________
Delphi mailing list
[EMAIL PROTECTED]
http://ns3.123.co.nz/mailman/listinfo/delphi
_______________________________________________
Delphi mailing list
[EMAIL PROTECTED]
http://ns3.123.co.nz/mailman/listinfo/delphi

Reply via email to