T
tavi
Hi all,
I am learning C# now, I write an application and I am playing with the
menus for now. I need to call GetTextMetrics at a point, I need to
know what is the system font, size and so on.
I've been successfully calling other API functions but with this
particular one I've got problems. I wrote something like this:
class PInvoke1App
{
[DllImport("user32.dll")]
static extern BOOL GetTextMetrics(HDC hdc, LPTEXTMETRIC lptm);
}
but it won't compile, it's complaining about HDC. It says unknown type
or something similar. Sorry, I don't remember the exact error message,
I am at work now ;-)
And it seems that if I declare the TEXTMETRIC structure on my cs file,
it will still not complain anymore.
That was easy, but how to declare the HDC type?
I read on MSDN about passing structures to the function, I believe I
could handle this, but I couldn't find any reference to handles and
HDC and I've got no ideeea what is the solution.
Also,if I need to use some constants from windows.h or other header,
how can I add a reference to these headers without declaring each
constant in my cs file?
Thank you!
Tavi
I am learning C# now, I write an application and I am playing with the
menus for now. I need to call GetTextMetrics at a point, I need to
know what is the system font, size and so on.
I've been successfully calling other API functions but with this
particular one I've got problems. I wrote something like this:
class PInvoke1App
{
[DllImport("user32.dll")]
static extern BOOL GetTextMetrics(HDC hdc, LPTEXTMETRIC lptm);
}
but it won't compile, it's complaining about HDC. It says unknown type
or something similar. Sorry, I don't remember the exact error message,
I am at work now ;-)
And it seems that if I declare the TEXTMETRIC structure on my cs file,
it will still not complain anymore.
That was easy, but how to declare the HDC type?
I read on MSDN about passing structures to the function, I believe I
could handle this, but I couldn't find any reference to handles and
HDC and I've got no ideeea what is the solution.
Also,if I need to use some constants from windows.h or other header,
how can I add a reference to these headers without declaring each
constant in my cs file?
Thank you!
Tavi