gpt4 book ai didi

c++ - 如何在 Windows 窗体/C++ 中将文本或数字旋转 90°?

转载 作者:行者123 更新时间:2023-11-28 07:27:46 24 4
gpt4 key购买 nike

我想在 Windows 窗体应用程序 Visual Studio 2010 (C++) 中将一段文本或一个数字旋转 90°。有没有简单的方法可以做到这一点?

最佳答案

您必须创建一个 LOGFONT并使用 lfEscapementlfOrientation 的值,如下所示:

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/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com