-
April 11th, 2006, 11:05 AM
#1
DrawText() does not draw
If i do pDC->Rectangle(rc); it draws the rectangle correctly where I want to draw the text.
I want to draw text inside this rectangle, it does not draw text (with or without caling Rectangle() function)
Code:
pDC->DrawText("Hello", rc, DT_SINGLELINE | DT_LEFT);
This is not working in the first place and my goal is draw the text right aligned.
Good Answers, Good Points.
-
April 11th, 2006, 11:17 AM
#2
Re: DrawText() does not draw
What is the text color? Perhaps you are drawing white on white ( or black on black etc).
Har Har
-
April 11th, 2006, 11:20 AM
#3
Re: DrawText() does not draw
Are you drawing the text or the rect first ?
Jim
ATP BE400 CE500 (C550B-SPW) CE560XL MU300 CFI CFII
"The speed of non working code is irrelevant"... Of course that is just my opinion, I could be wrong.
"Nothing in the world can take the place of persistence. Talent will not; nothing is more common than unsuccessful men with talent. Genius will not; unrewarded genius is almost a proverb. Education will not; the world is full of educated derelicts. Persistence and determination are omnipotent. The slogan 'press on' has solved and always will solve the problems of the human race."...Calvin Coolidge 30th President of the USA.
-
April 11th, 2006, 11:23 AM
#4
Re: DrawText() does not draw
Perhaps you should try this
Code:
CRect rect(50,60,0,0); //in this case is not a normal rect :)
rect.NormalizeRect();
pDC.DrawText("Hello",rect, DT_SINGLELINE | DT_LEFT);
-
April 11th, 2006, 11:48 AM
#5
Re: DrawText() does not draw
Originally Posted by retry
Code:
pDC->DrawText("Hello", rc, DT_SINGLELINE | DT_LEFT);
This is not working in the first place and my goal is draw the text right aligned.
You must use "DT_RIGHT" if you want to right align the text...not "DT_LEFT". At what X-Y position are you trying to draw the text...do you have a MoveTo function call before calling DrawText ?? Can you use TextOut and supply the location of the Text to be printed within the TextOut function call.
Jim
ATP BE400 CE500 (C550B-SPW) CE560XL MU300 CFI CFII
"The speed of non working code is irrelevant"... Of course that is just my opinion, I could be wrong.
"Nothing in the world can take the place of persistence. Talent will not; nothing is more common than unsuccessful men with talent. Genius will not; unrewarded genius is almost a proverb. Education will not; the world is full of educated derelicts. Persistence and determination are omnipotent. The slogan 'press on' has solved and always will solve the problems of the human race."...Calvin Coolidge 30th President of the USA.
-
April 11th, 2006, 12:34 PM
#6
Re: DrawText() does not draw
The points go to g_gili, NormalizeRect() rect fixes the problem.
Sometimes these things are now documented in MSDN that the rect should be normalized before calling DrawText()...can anybody shine light why we need to NormalizeRect()?
Good Answers, Good Points.
-
April 11th, 2006, 12:58 PM
#7
Re: DrawText() does not draw
At the NormalizeRect
The following CRect methods require normalized rectangles in order to work properly
....
Width
So I think when you use DrawText() then you have to normalize first the rectangle if you have to that means if (x1>x2 or y1>y2)
Code:
CRect rect(50,60,0,0);//in this case the Width() = - 50 at the default maping mode
So I think you can't draw the text when your rectangle width is a negative number .
Last edited by g_gili; April 11th, 2006 at 01:29 PM.
Please use code tags [code] [/code]
We would change the world, but God won't give us the sourcecode..
Undocumented futures are fun and useful....
_________
Gili
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|