Click here to Skip to main content
15,889,595 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I have consumed a method "DrawText()" from the user32.dll to DrawText with wordBreak.Do we have any other way to replace this method with some Functionality.

DrawText(picImage.CreateGraphics().GetHdc().ToInt32(), New String(" "c, Strings.Len(Gd1.get_TextMatrix(ind, gdHeading)) * 2) & MSFlexGrid1.get_TextMatrix(wRow, mfgValue), -1, rct, DT_WORDBREAK)

Any alternative way to do this functionality.I have tried using spliting the Text based on the Spaces.The output differs with the old application.
Posted
Comments
Sergey Alexandrovich Kryukov 30-Oct-12 10:53am    
It depends what are you using. WPF? Forms? Metro? You need to tag it.
--SA

1 solution

The Graphics object has a bunch of DrawString methods that, under the covers, uses DrawText.

BTW: The code you posted leaks resources and will eventually crash the machine. If you call CreateGraphics you MUST call Dispose on the object you get back. Your code doesn't do that and will eventually cause Windows to do some very weird things before it just dies.
 
Share this answer
 
Comments
hemantwithu 31-Oct-12 0:40am    
Thanks Dave Kreskowiak.But i would like to know in this method what they are trying to do? I am unable to understand that.
Dave Kreskowiak 31-Oct-12 8:06am    
That's not what your question asked. There's insufficient information to explain everything.

DrawText takes 5 parameters:
1. A handle to a device context. This points to the surface to draw on.
2. The string of text to be drawn.
3. The length in characters of the string (can be -1 if the string is null terminated.)
4. The RECT structure that defines the rectangle to draw the string in.
5. The formatting options for the string.

You can read more about it at http://msdn.microsoft.com/en-us/library/windows/desktop/dd162498(v=vs.85).aspx.

Your code says its creating a new string with some number of spaces and the text retrieved from soemthing in the MSFlexGrid.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900