Board index » delphi » Error in the Windows Run Time Library

Error in the Windows Run Time Library

Hi

I am trying to get information about the size of the scrollbars from
within my program. This should not be difficult I should be able to
use

SystemParametersInfo(SPI_GETNONCLIENTMETRICS, 0, @NonClientMetrics,
0);

where NonClientMetrics has been set up as a TNonClientMetrics.

However there seems to be a bug in the definition of
TNonClientMetrics. In the Win32 help file it is defined as

typedef struct tagNONCLIENTMETRICS {
    UINT    cbSize;
    int     iBorderWidth;
    int     iScrollWidth;
    int     iScrollHeight;
    int     iCaptionWidth;
    int     iCaptionHeight;
    LOGFONT lfCaptionFont;
    int     iSmCaptionWidth;
    int     iSmCaptionHeight;
    LOGFONT lfSmCaptionFont;
    int     iMenuWidth;
    int     iMenuHeight;
    LOGFONT lfMenuFont;
    LOGFONT lfStatusFont;
    LOGFONT lfMessageFont;

Quote
} NONCLIENTMETRICS, FAR* LPNONCLIENTMETRICS;

but in the Windows.pas source code it is defined as:
type
  PNonClientMetrics = ^TNonClientMetrics;
  TNonClientMetrics = packed record
        cbSize: UINT;
        iBorderWidth: BOOL;
        iScrollWidth: BOOL;
        iScrollHeight: BOOL;
        iCaptionWidth: BOOL;
        iCaptionHeight: BOOL;
        lfCaptionFont: TLogFont;
        iSmCaptionWidth: BOOL;
        iSmCaptionHeight: BOOL;
        lfSmCaptionFont: TLogFont;
        iMenuWidth: BOOL;
        iMenuHeight: BOOL;
        lfMenuFont: TLogFont;
        lfStatusFont: TLogFont;
        lfMessageFont: TLogFont;
  end;          

iScrollHeight is an Integer in one and a Boolean in the other!!!

I have changed the definition of TNonClientMetrics in Windows.pas but
now I need to know how to recompile it, I think it has something to do
with MakeFile and might require an Assembler. Please Help

Cheers Mike

*********************************************************************
**           ** Tel:   +44 (0)1672 511670 ** Wagon  Yard ** Strive **
**   SHiFT   ** Fax:   +44 (0)1672 511428 ** Marlborough **   to   **
**    F 7    ** Email: m...@shift-f7.com  **  Wilts, UK  **   be   **
**           ** WWW:   www.shift-f7.com   **   SN8 1LH   ** happy! **
*********************************************************************

 

Re:Error in the Windows Run Time Library


Quote
Mike Dymond wrote:

> Hi

> I am trying to get information about the size of the scrollbars from
> within my program. This should not be difficult I should be able to
> use

> SystemParametersInfo(SPI_GETNONCLIENTMETRICS, 0, @NonClientMetrics,
> 0);

> where NonClientMetrics has been set up as a TNonClientMetrics.

> However there seems to be a bug in the definition of
> TNonClientMetrics. In the Win32 help file it is defined as

> typedef struct tagNONCLIENTMETRICS {
>     UINT    cbSize;
>     int     iBorderWidth;
>     int     iScrollWidth;
>     int     iScrollHeight;
>     int     iCaptionWidth;
>     int     iCaptionHeight;
>     LOGFONT lfCaptionFont;
>     int     iSmCaptionWidth;
>     int     iSmCaptionHeight;
>     LOGFONT lfSmCaptionFont;
>     int     iMenuWidth;
>     int     iMenuHeight;
>     LOGFONT lfMenuFont;
>     LOGFONT lfStatusFont;
>     LOGFONT lfMessageFont;
> } NONCLIENTMETRICS, FAR* LPNONCLIENTMETRICS;

> but in the Windows.pas source code it is defined as:
> type
>   PNonClientMetrics = ^TNonClientMetrics;
>   TNonClientMetrics = packed record
>         cbSize: UINT;
>         iBorderWidth: BOOL;
>         iScrollWidth: BOOL;
>         iScrollHeight: BOOL;
>         iCaptionWidth: BOOL;
>         iCaptionHeight: BOOL;
>         lfCaptionFont: TLogFont;
>         iSmCaptionWidth: BOOL;
>         iSmCaptionHeight: BOOL;
>         lfSmCaptionFont: TLogFont;
>         iMenuWidth: BOOL;
>         iMenuHeight: BOOL;
>         lfMenuFont: TLogFont;
>         lfStatusFont: TLogFont;
>         lfMessageFont: TLogFont;
>   end;

> iScrollHeight is an Integer in one and a Boolean in the other!!!

        Do you know that this doesn't work - have you tried it?
(It _could_ be that the default size of a Boolean in the Windows
API is the same as SizeOf(integer); actually this would make a
certain amount of sense. If so then there should be no problem with
the above.)

        If it doesn't work the first time there's another possobility:
This could be one of those things where you need to initialize the
cbSize field. Try using the Windows.pas stuff, but say

YourTNonClientMetrics.cbSize:= SizeOf(TNonClientMetrics);

before the function call and see what happens.
--
David Ullrich

?his ?s ?avid ?llrich's ?ig ?ile
(Someone undeleted it for me...)

Other Threads