Hi,
Can anyone show me how to draw vertical text to a device context?
any help would be appreciated
Haim
Using a trick, and mixing api functions :)
import int GetObject alias GetObjectA(int hgdiobj,int cbBuffer,void *lpvObject);
import int CreateFontIndirect alias CreateFontIndirectA(LOGFONT *lf);
import int DeleteObject(int obj);
struct LOGFONT
{
int lfHeight; int lfWidth;
int lfEscapement; int lfOrientation; int lfWeight;
BYTE lfItalic; BYTE lfUnderline; BYTE lfStrikeOut;
BYTE lfCharSet; BYTE lfOutPrecision;
BYTE lfClipPrecision; BYTE lfQuality;
BYTE lfPitchAndFamily; dstring lfFaceName[32];
}
class CWnd : CWindow
{
declare virtual OnClose() {Destroy();}
declare WriteVText(int x,int y,string txt,opt int grad=0);
}
sub main()
{
CWnd win;
win.Create(0,0,600,400,0x10CF0050,0,"",0);
// you need to set any font before
win.SetFont("Arial", 22, 400);
win.WriteVText(100,360,"Help drawing vertical text", 900); // +90 grad
win.WriteVText(200, 30,"Help drawing vertical text",-900); // -90 grad
win.WriteVText(280,330,"Help drawing vertical text", 450); // +45 grad
while(win.m_hwnd) {wait();}
return;
}
CWnd::WriteVText(int x,int y,string txt,int grad)
{
int hFont = m_hFont; // save font
LOGFONT lf;
// get the font data from window
GetObject(hFont, sizeof(LOGFONT), &lf);
// change some values
lf.lfEscapement = grad;
lf.lfOrientation = grad;
// and create new font
m_hFont = CreateFontIndirect(&lf);
WriteText(x,y,txt);
// free memory
DeleteObject(m_hFont);
// restore font
m_hFont = hFont;
}
Wow!
That is great!
Exactly what i was looking for.
Thank you very much Sapero.
Haim