🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.cppbuilder.nativeapi
Article #1603

Re: how to resolve conflicts in gdi+ ?

#1603
From: Remy Lebeau (TeamB)
Date: Thu, 05 Jul 2007 19:10
44 lines
2619 bytes
"4N" <xxxx@yyyy.zzz> wrote in message
news:468d3c18@newsgroups.borland.com...

> How?

I don't use STRICT in my code and it works fine.  I don't do anything
special for it.

> If I don't define STRICT the code stops in the last line
> of the following code (inside the file GDIPLUSGRAPHICS.H):

Then the compiler is wrong.  There is no ambiquity in that code.  The
Graphics class has only two constructors which accept an HDC as a
parameter.  The first constructor accepts only an HDC by itself,
whereas the second constructor accepts an additional HANDLE parameter.
That parameter does not have a default value defined, however, so
there is no way that passing an HDC by itself to a Graphics
constructor like FromHDC(HDC) does can be ambiquious with the second
constructor.  It doesn't matter if STRICT is defined or not.  The
number of parameters dictates which constructor to call before the
parameter types are then validated.

> If I define STRICT there are functions that need cast, eg. an
> error I get is:
>
> const HANDLE handle=...;
>  GetWindowLong(handle, GWL_STYLE);
>
>   [C++ Error] Unit_Main.cpp(3297): E2034 Cannot convert 'void *
const'
> to 'HWND__ *'

The error is correct in this case.  Your code is simply wrong to begin
with.  GetWindowLong() expects an HWND, not a HANDLE.  The two are not
the same thing, especially more so when STRICT is defined.  This is
exactly the type of thing that STRICT was designed for - it forces you
to use proper coding so that you can catch such errors.  When STRICT
is not defined, HANDLE and HWND are both void* and thus are
interchangable in code, but that is not necessarily the right thing to
do logically.


Gambit
Technical Details
Message-ID: <468d4237$1@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!news.glorb.com!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mail
References: <468d2ea0@newsgroups.borland.com> <468d312f$1@newsgroups.borland.com> <468d3c18@newsgroups.borland.com>

Show Full Headers
Complete Article Headers
X-Google-Thread: 10cc67,42fc4c19e42cbb45
X-Google-Attributes: gid10cc67,public,usenet
X-Google-Language: ENGLISH,ASCII-7-bit
From: "Remy Lebeau \(TeamB\)" <no.spam@no.spam.com>
Newsgroups: borland.public.cppbuilder.nativeapi
References: <468d2ea0@newsgroups.borland.com> <468d312f$1@newsgroups.borland.com> <468d3c18@newsgroups.borland.com>
Subject: Re: how to resolve conflicts in gdi+ ?
Date: Thu, 5 Jul 2007 12:10:50 -0700
Lines: 46
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2800.1409
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1409
NNTP-Posting-Host: 75.82.252.126
Message-ID: <468d4237$1@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1183662647 75.82.252.126 (5 Jul 2007 12:10:47 -0700)
Path: arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!news.glorb.com!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mail