我想在 Windows 窗体应用程序 Visual Studio 2010 (C++) 中将一段文本或一个数字旋转 90°。有没有简单的方法可以做到这一点?
最佳答案
您必须创建一个 LOGFONT并使用 lfEscapement 和 lfOrientation 的值,如下所示:
SetGraphicsMode(hdc, GM_ADVANCED);
LOGFONT font = {0};
font.lfHeight = 0;
font.lfWidth = 0;
font.lfEscapement = 900; // here
font.lfOrientation = 900; // and here
font.lfWeight = 0;
font.lfItalic = false;
font.lfUnderline = false;
font.lfStrikeOut = false;
font.lfCharSet = DEFAULT_CHARSET;
font.lfOutPrecision = OUT_DEFAULT_PRECIS;
font.lfClipPrecision = CLIP_DEFAULT_PRECIS;
font.lfQuality = CLEARTYPE_QUALITY;
font.lfPitchAndFamily = DEFAULT_PITCH | FF_DONTCARE;
auto newfont = CreateFontIndirect(&font);
auto oldfont = SelectObject(hdc, newfont);
/* do actual drawing here */
SelectObject(hdc, oldfont);
SetGraphicsMode(hdc, GM_COMPATIBLE);
DeleteObject(newfont);
关于c++ - 如何在 Windows 窗体/C++ 中将文本或数字旋转 90°?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18395564/