 |
|
 |
your code is great. but i am working in c#, i tried to convert the following code but unable to get any success.
// get the center of a not-rotated text
CSize TextSize = pDC->GetTextExtent(str);
would u please let me know how would I perform above step.
Graphics g = null;
g = Graphics.FromImage(this.pictureBoxSurface.Image);
Size TextSize = e.?
Thanx in advance
Rizwan Ahmed Butt
Software Engineer
Accoutacy Outsourcing Services (AOS)
Lahore,Pakistan.
|
|
|
|
 |
|
 |
I had problems with text not showing up in subsequent calls to DrawText and had to add the following:
// finally draw the text and move it to the center of the rectangle
UINT oldAlign = pDC->GetTextAlign(); // save the old alignment
pDC->SetTextAlign(TA_BASELINE);
pDC->SetBkMode(TRANSPARENT);
pDC->ExtTextOut(rect.left + rect.Width() / 2 - rcenter.x,
rect.top + rect.Height() / 2 + rcenter.y,
nOptions, rect, str, NULL);
pDC->SetTextAlign(oldAlign); // restore the old alignment
agi20dla
|
|
|
|
 |
|
 |
I want to write a project has some functions like WordArt of Microsoft Words.
Could you tell me what i must do?
thanks and regards
I love everybody
|
|
|
|
 |
|
 |
Hi,
Looks like a great function, but I can't get it to work. I always get horizontal text, no matter what angle I try:
DrawRotatedText(pDC, "text not rotated", rect, 45.0, ETO_CLIPPED|ETO_OPAQUE);
Am I doing something wrong?
Thanks!
Mike
|
|
|
|
 |
|
 |
I am trying to rotate all the text that is displayed on the desktop ie all the icon text etc. Basically we are trying to rotate the full screen and all the icons and text to 180 degree
I am trying to set the orientation of text through "fpOrientation" member variable of TEXTXFORM structure.
But still the text is not rotating.
Please give the suggestion on the same.
Thank You
|
|
|
|
 |
|
 |
Thanks for the code, it was great use in times of trouble.
Sansky
John 3:16
For God so loved the world,
that he gave his only begotten Son ( Jesus Christ ) ,
that whosoever believeth in him should not perish, but have everlasting life.
|
|
|
|
 |
|
 |
Hi Friends,
I want to rotate entire text control which uses CRichEditCtrl as base class. Do you have any idea or pointer.
Thanks
How to rotate Text control
|
|
|
|
 |
|
 |
This is a very useful bit of code, but it doesn't work on Windows 95/98.
From looking at the documentation it should work, but I have found that it only ever works (NT/XP/etc) if the device context's graphics mode is set to GM_ADVANCED, which is not supported on Win95/98.
(You haven't mentioned needing to do this - does it work for you without using GM_ADVANCED?)
Does anyone have any information on this, or any other way to get it working on Win95/98?
---
"The way of a fool seems right to him, but a wise man listens to advice" - Proverbs 12:15 (NIV)
|
|
|
|
 |
|
 |
OK - I've found the problem: I'm using the font MS Sans Serif, and trying to rotate it by 270 degress (ie 90 degrees clockwise).
I have found that although this doesn't work, if I rotate by an angle which is not a multiple of 90 (eg 271 degrees), or I use a true-type font, it works as per the documentation.
All I need to do now is find a standard true-type font which looks like MS Sans Serif, and is available on all platforms...
---
"The way of a fool seems right to him, but a wise man listens to advice" - Proverbs 12:15 (NIV)
|
|
|
|
 |
|
 |
the docs say you just need to set the escapement and orientation to the same value for older winvers.
|
|
|
|
 |
|
 |
I did everything as per the docs, but it didn't work. Does it work for you on Win98, with non-true-type fonts, and rotations divisible by 90 degrees? The code I ended up using is this: LOGFONT lf;
CFont font;
font.CreateStockObject(DEFAULT_GUI_FONT);
font.GetLogFont(&lf);
if (lstrcmpi(lf.lfFaceName, _T("MS Sans Serif")) == 0)
lstrcpy(lf.lfFaceName, _T("Tahoma"));
font.DeleteObject();
lf.lfEscapement = lf.lfOrientation = 2700; VERIFY(font.CreateFontIndirect(&lf));
"The way of a fool seems right to him, but a wise man listens to advice" - Proverbs 12:15 (NIV)
|
|
|
|
 |
|
 |
void DrawRotatedText(HDC hdc, char *str, LPRECT rect,
double angle, UINT nOptions = 0)
{
double pi = 3.141592654;
double radian = pi * 2 / 360 * angle;
SIZE TextSize;;
GetTextExtentPoint32(hdc, str, strlen(str), &TextSize);
POINT center;
center.x = TextSize.cx / 2;
center.y = TextSize.cy / 2;
POINT rcenter;
rcenter.x = long(cos(radian) * center.x - sin(radian) * center.y);
rcenter.y = long(sin(radian) * center.x + cos(radian) * center.y);
SetTextAlign(hdc, TA_BASELINE);
SetBkMode(hdc, TRANSPARENT);
ExtTextOut(hdc, rect->left + (rect->right - rect->left) / 2 - rcenter.x,
rect->top + (rect->bottom - rect->top) / 2 + rcenter.y,
nOptions, rect, str, strlen(str), NULL);
}
|
|
|
|
 |
|
 |
I think you should use alignment TA_BOTTOM instead of TA_BASELINE, because GetTextExtent returns height of text from bottom to top and not from baseline to top
|
|
|
|
 |