Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Wrong parameter type for EnumDisplaySettings?

297 views
Skip to first unread message

Steve Wyatt

unread,
Jul 31, 2008, 6:46:44 PM7/31/08
to
I am using Delphi 2006 VCL.NET, and am trying to use the EnumDisplaySettings
function. First of all, there is no ENUM_CURRENT_SETTINGS value defined for
Delphi, but I think the larger problem is that the type for the "iModeNum"
parameter of EnumDisplaySettings is defined as "Cardinal" (DWORD in
Windows.pas), when it should actually be "Integer".

According to the MS documentation ENUM_CURRENT_SETTINGS should have an
integer value of -1 (which doesn't work in a Cardinal or DWORD type).

Does anyone know of an available fix for this problem?

Steve Wyatt


Remy Lebeau (TeamB)

unread,
Jul 31, 2008, 7:34:24 PM7/31/08
to

"Steve Wyatt" <st...@methods.com> wrote in message
news:489240d7$1...@newsgroups.borland.com...

> I am using Delphi 2006 VCL.NET

Then you should post to the .dotnet group instead.

> I think the larger problem is that the type for the "iModeNum"
> parameter of EnumDisplaySettings is defined as "Cardinal" (DWORD
> in Windows.pas), when it should actually be "Integer".

No, it is supposed to be a Cardinal. Look at the declaration of
EnumDisplaySettings() in winuser.h, or in the Win32 API documentation.
iModeNum really is a DWORD, not an integer.

> According to the MS documentation ENUM_CURRENT_SETTINGS
> should have an integer value of -1 (which doesn't work in a Cardinal
> or DWORD type).

In C++ (which the Win32 API is based on), it does work.

> Does anyone know of an available fix for this problem?

Use $FFFFFFFF instead of -1. Or to use -1, type-cast it to Cardinal
(Windows.pas does that for many values).


Gambit


Steve Wyatt

unread,
Jul 31, 2008, 8:26:26 PM7/31/08
to
I appreciate the response; sorry I posted to the wrong group. I'm never
very comfortable deciding on which one to use.

But I must be missing something.

This statement:
EnumDisplaySettings(nil, 0, DeviceMode);
compiles and runs, but does not give me what I need (current settings).

This statement:
EnumDisplaySettings(nil, (-1 as Cardinal), DeviceMode);
Results in this compile error:
[Pascal Error] Unit1.pas(70): E1012 Constant expression violates
subrange bounds

This statement:
EnumDisplaySettings(nil, $FFFFFFFF, DeviceMode);
Results in this compile error:
[Pascal Error] Unit1.pas(70): E1012 Constant expression violates
subrange bounds

Steve Wyatt

"Remy Lebeau (TeamB)" <no....@no.spam.com> wrote in message
news:48924c7a$1...@newsgroups.borland.com...

Remy Lebeau (TeamB)

unread,
Jul 31, 2008, 9:24:24 PM7/31/08
to

"Steve Wyatt" <st...@methods.com> wrote in message
news:48925837$1...@newsgroups.borland.com...

> I appreciate the response; sorry I posted to the wrong group.
> I'm never very comfortable deciding on which one to use.

When in doubt about where to post, ask in .non-technical first.

> This statement:
> EnumDisplaySettings(nil, 0, DeviceMode);
> compiles and runs, but does not give me what I need (current settings).

You are asking for settings from graphics mode index 0, not from "current
settings".

> This statement:
> EnumDisplaySettings(nil, (-1 as Cardinal), DeviceMode);
> Results in this compile error:
> [Pascal Error] Unit1.pas(70): E1012 Constant expression violates
> subrange bounds

Don't use 'as' for integer casting like that. Use this instead:

EnumDisplaySettings(nil, Cardinal(-1), DeviceMode);

Or better:

EnumDisplaySettings(nil, DWORD(-1), DeviceMode);


Gambit


Steve Wyatt

unread,
Jul 31, 2008, 9:49:43 PM7/31/08
to
Thank you very much for the responses. You have solved my problem.

I will make a point of posting to .non-technical first in the future.

SW


"Remy Lebeau (TeamB)" <no....@no.spam.com> wrote in message

news:4892662a$1...@newsgroups.borland.com...

Pieter Zijlstra

unread,
Jul 31, 2008, 9:59:36 PM7/31/08
to
Steve Wyatt wrote:

> I will make a point of posting to .non-technical first in the future.

Only when you in serious doubt, otherwise just post to the most
appropriate/significant group.

--
Pieter

0 new messages