Please post code that will compile. ;)
GM_ADVANCED. So with your code, change the lfOrientation to 0 or
same.
need GM_ADVANCED.
AliR.
"Joseph M. Newcomer" <newcomer@flounder.com> wrote in message
Actually, no. If we could post images on the NG, I'd show an example of
a
rotated font
that does not use GM_ADVANCED. I rotated it both 90 and 270, to create
a
vertical label
for a pair of slider controls, and the code is as shown below.
The font I'm using is
"MS Shell Dlg 2"
but I get that from the font that is established when the dialog is
created.
The setup was in the OnInitDialog of the dialog containing the control:
CRotatedText x_Eye;
CFont * f = GetFont();
LOGFONT lf;
f->GetLogFont(&lf);
lf.lfEscapement = 900;
lf.lfOrientation = 900;
Vertical90.CreateFontIndirect(&lf);
x_Height.SetFont(&Vertical90);
lf.lfEscapement = 2700;
lf.lfOrientation = 2700;
Vertical270.CreateFontIndirect(&lf);
x_Eye.SetFont(&Vertical270);
and the class is derived from CStatic:
class CRotatedText : public CStatic
{
DECLARE_DYNAMIC(CRotatedText)
public:
CRotatedText();
virtual ~CRotatedText();
protected:
DECLARE_MESSAGE_MAP()
public:
afx_msg void OnPaint();
afx_msg void OnSize(UINT nType, int cx, int cy);
};
void CRotatedText::OnPaint()
{
CPaintDC dc(this); // device context for painting
CRect r;
GetClientRect(&r);
dc.FillSolidRect(&r, ::GetSysColor(COLOR_3DFACE));
dc.SetTextAlign(TA_CENTER);
CFont * f = GetFont();
LOGFONT lf;
f->GetLogFont(&lf);
int x = 0;
if(f.lfRotation == 2700)
x = r.Width();
dc.SelectObject(f);
CString s;
GetWindowText(s);
dc.TextOut(x, r.Height() / 2, s);
// Do not call CStatic::OnPaint() for painting messages
}
I discovered it wasn't properly updating when it was resized:
void CRotatedText::OnSize(UINT nType, int cx, int cy)
{
CStatic::OnSize(nType, cx, cy);
Invalidate();
}
joe
On Mon, 24 Mar 2008 09:45:29 -0500, "AliR \(VC++ MVP\)"
<AliR@online.nospam> wrote:
You have to set the drawing mode to GM_ADVANCED for the Orientation to
work.
Here is an example:
http://www.learnstar.com/alir/FontRotate.zip
Here is a thread from last week about the same question:
http://groups.google.com/group/microsoft.public.vc.mfc/browse_thread/thread/5de375afbed42526/d6e4f6c8eaf762e2?lnk=st&q=Font.CreateFont#d6e4f6c8eaf762e2
Search is your friend. ;)
AliR.
"hamishd" <Hamish.Dean@gmail.com> wrote in message
news:98fbf59e-a7df-4ee1-8ee8-6855ea3add2e@m44g2000hsc.googlegroups.com...
I cannot get my text to display vertically :-(
void CTestApp::OnDrawCDC* pDC)
{
CDC dcMem;
dcMem.CreateCompatibleDC(pDC);
pDC->SetBkColor(RGB(255,255,255));
CMemDC pDC(dc);
LOGFONT lfNew;
ZeroMemory (&lfNew, sizeof(LOGFONT));
lfNew.lfHeight = 100;
lfNew.lfWeight = FW_NORMAL;
lfNew.lfOrientation = lfNew.lfEscapement = 2700;
wcscpy(lfNew.lfFaceName, _T("MS Sans Serif"));
CFont Font;
Font.CreateFontIndirect(&lfNew);
pDC->SelectObject(&Font);
pMEMDC->TextOut(200, 200, _T("Hello World"));
....
}
Joseph M. Newcomer [MVP]
email: newcomer@flounder.com
Web: http://www.flounder.com
MVP Tips: http://www.flounder.com/mvp_tips.htm