April 30, 2024, 04:57:20 PM

News:

IonicWind Snippit Manager 2.xx Released!  Install it on a memory stick and take it with you!  With or without IWBasic!


Help drawing vertical text

Started by Haim, November 10, 2006, 03:39:48 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Haim

Hi,
Can anyone show me how to draw vertical text to a device context?

any help would be appreciated

Haim

sapero

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;
}

Haim

Wow!
That is great!
Exactly what i was looking for.

Thank you very much Sapero.

Haim