Problem with GetTextExtentPoint

G

Gianco

Hello

I have a problem using the GetTextExtentPoint (the OS is Windows CE 4)

Probably I made a mistake but I don't understand which is. I have no
problems with the other GDI functions, I can draw the text but not
measure it

This is the declaration:

[DllImport("coredll.dll")]
private static extern int GetTextExtentPoint(IntPtr DC, string Str,
int Len, out SIZE size);

And when I use the function:

.....
SIZE Size;
String sValue;
.....

.....
sValue = dXScales.ToString();
GetTextExtentPoint(m_MemoryDC, sValue, sValue.Length, out Size);
......

I obtain the error message:
An unhandled exception of type 'System.MissingMethodException'
occurred in Test.exe

Which is the my error? Any help will be appreciated
Gianco
 
A

Alex Feinman [MVP]

In Windows CE GetTextExtentPoint is a define:
#define GetTextExtentPointW(hdc, lpString, cbString, lpSize) \
GetTextExtentExPointW(hdc, lpString, cbString, 0, NULL, NULL,
lpSize)
Correspondingly it is not available as an exported function from coredll.
You need to use GetTextExtentExPoint instead

[DllImport("coredll.dll")]
private static extern int GetTextExtentExPoint(IntPtr DC, string Str,
int Len,
int nMaxExtent,
int[] lpnFit,
int[] alpDx,
out SIZE size);
 
G

Gianco

It works perfectly

Many thanks for your help
Gianco

Alex Feinman said:
In Windows CE GetTextExtentPoint is a define:
#define GetTextExtentPointW(hdc, lpString, cbString, lpSize) \
GetTextExtentExPointW(hdc, lpString, cbString, 0, NULL, NULL,
lpSize)
Correspondingly it is not available as an exported function from coredll.
You need to use GetTextExtentExPoint instead

[DllImport("coredll.dll")]
private static extern int GetTextExtentExPoint(IntPtr DC, string Str,
int Len,
int nMaxExtent,
int[] lpnFit,
int[] alpDx,
out SIZE size);


Gianco said:
Hello

I have a problem using the GetTextExtentPoint (the OS is Windows CE 4)

Probably I made a mistake but I don't understand which is. I have no
problems with the other GDI functions, I can draw the text but not
measure it

This is the declaration:

[DllImport("coredll.dll")]
private static extern int GetTextExtentPoint(IntPtr DC, string Str,
int Len, out SIZE size);

And when I use the function:

....
SIZE Size;
String sValue;
....

....
sValue = dXScales.ToString();
GetTextExtentPoint(m_MemoryDC, sValue, sValue.Length, out Size);
.....

I obtain the error message:
An unhandled exception of type 'System.MissingMethodException'
occurred in Test.exe

Which is the my error? Any help will be appreciated
Gianco
 

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