tagSOMETHING and API calls.

Hello Experts.
I need you again :)

A begginer in C++
As I told before... talking about Visual C++.

Well, I'm working on a personal project, the goal of this is to learn
to program in this language. Thats why I'm working without MFC at this
time.
I just created a "Typical Hello World" aplication... And I'm adding
things on it.

I try to call some Api funtions that receive struct parameters.
For example. CreateBrushIndirect(CONST LOGBRUSH *lplb).

LOGBRUSH is defined like this:
typedef struct tagLOGBRUSH { // lb
   UINT     lbStyle;
   COLORREF lbColor;
   LONG     lbHatch;
} LOGBRUSH;

Well... Here is the problem.
I try this code.

LOGBRUSH mBrush; (Tried also LOGBRUSH *Brush = new LOGBRUSH;)

First
Into the class, When I write "Brush." (I There was a member they should be shown at this moment
but they don't appear).

Well The point is this.
When I call the Api Funtion:

CreateBrushIndirect(Brush);
The compiler rejects the code telling:
error C2664: 'CreateBrushIndirect' : cannot convert parameter 1 from 'struct tagLOGBRUSH' to 'const struct tagLOGBRUSH *'

Would you tell me what do I have to do?... Is not the first Api That receive "tagSOMETHING" as
parameter, Ind I have the same problem with them.
Thanks

I'm sorry for not being more generous, but I really need to do more questions.
Thanks again.
LVL 1
MarscAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

MarscAuthor Commented:
I Forgor to tell...
I included the file <wingdi.h>
0
ZoppoCommented:
Hi Marsc,

function is defined like this:

CreateBrushIndirect(
  CONST LOGBRUSH *lplb   // brush information
);

the parameter is a constant pointer to a struct LOGBRUSH instance, so you have to pass a pointer, i.e.:

------------------------------------------------
LOGBRUSH mBrush;
....
CreateBrushIndirect( &mBrush );
------------------------------------------------
or
------------------------------------------------
LOGBRUSH *pBrush;
....
CreateBrushIndirect( pBrush );
------------------------------------------------

hope that helps,

ZOPPO
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
ZoppoCommented:
ehh, forgot to mention that in the second example you'll have to release the allocated memory for the LOGBRUSH object after creating the brush, i.e.:

------------------------------------------------
LOGBRUSH *pBrush;
.....
CreateBrushIndirect( pBrush );
delete pBrush; // free memory
------------------------------------------------

ZOPPO
0
MarscAuthor Commented:

0
MarscAuthor Commented:

0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
C++

From novice to tech pro — start learning today.