How to use [out] parameters in C++ .NET

J

jgctr4

I'm trying to use the Graphics::MeasureString method,
which gives two out parameters. Apparently these out
parameters are an invention of C#, but the docs still
show a syntax for C++ (below). However, when I try to
compile, I get "error C2059: syntax error: '['".

Can someone enlighten me on using the out parameter in
C++ .net 2003 (such as an example)? I couldn't find any
more info on this. The MIDL also says the same syntax.

My code:

gfx->MeasureString(labHx, printFont, rectText.Size, new
StringFormat(), [out] int * charsPerLine, [out] int *
linesFilled);

Documentation:

public: SizeF MeasureString(
String* text,
Font* font,
SizeF layoutArea,
StringFormat* stringFormat,
[
Out
] int* charactersFitted,
[
Out
] int* linesFilled
);
 
?

=?iso-8859-1?Q?Jakub_W=F3jciak?=

Can someone enlighten me on using the out parameter in
C++ .net 2003 (such as an example)? I couldn't find any
more info on this. The MIDL also says the same syntax.

My code:

gfx->MeasureString(labHx, printFont, rectText.Size, new
StringFormat(), [out] int * charsPerLine, [out] int *
linesFilled);

Get rid of the '[out]' fragments - they are only for informational purposes
in documentation (they are relevant in MIDL, but illegal in C++).
So it should look like this:
gfx->MeasureString(labHx, printFont, rectText.Size, new
StringFormat(), &charsPerLine, &linesFilled);

--
pozdrawia
(e-mail address removed)
Anything was possible last night. That was the trouble
with last nights. They were always followed by this mornings.
- Terry Pratchett, "Small Gods"
 
J

jgctr4

Great. That worked. Thanks very much for your quick
reply.
-----Original Message-----
Can someone enlighten me on using the out parameter in
C++ .net 2003 (such as an example)? I couldn't find any
more info on this. The MIDL also says the same syntax.

My code:

gfx->MeasureString(labHx, printFont, rectText.Size, new
StringFormat(), [out] int * charsPerLine, [out] int *
linesFilled);

Get rid of the '[out]' fragments - they are only for informational purposes
in documentation (they are relevant in MIDL, but illegal in C++).
So it should look like this:
gfx->MeasureString(labHx, printFont, rectText.Size, new
StringFormat(), &charsPerLine, &linesFilled);

--
pozdrawia
(e-mail address removed)
Anything was possible last night. That was the trouble
with last nights. They were always followed by this mornings.
- Terry Pratchett, "Small Gods"

.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top