Your solution is a good one.
If you want to write text with any angle use this function that I wrote for my use:
/*-@@+@@--------------------------------[Do not edit manually]------------
Procedure: DrawRotatedText
Created : Thu May 10 19:26:35 2007
Modified : Thu May 10 19:48:22 2007
Synopsys : Draws rotated text
Input : hDC : pointer to your device-context
str : the text
x : x start position
y : y start position
Opts : see documentation of ExtTextOut for more details
sFont: Font name or NULL to use default
Output : TRUE if success.
Errors : None
------------------------------------------------------------------@@-@@-*/
BOOL DrawRotatedText(HDC hDC, const wchar_t *str, UINT x, UINT y, float angle, UINT Opts, LPCTSTR sFont)
{
// convert angle to radian
HFONT hFont, hOldFont;
hFont = CreateFont( 0, 0, angle * 10.0, angle * 10.0, FW_DONTCARE, FALSE, FALSE, FALSE,
DEFAULT_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY, DEFAULT_PITCH, sFont);
if (!hFont)
return FALSE;
hOldFont = SelectObject(hDC, hFont);
ExtTextOutW(hDC, x, y, Opts, NULL, str, wcslen(str), NULL);
hOldFont = SelectObject(hDC, hOldFont);
DeleteObject(hFont);
return TRUE;
}
You can call the functios as:
if (!DrawRotatedText(ps.hdc,L"Dose", 50, 100, 45, 0, NULL))
//Error code