Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Rotate text in dialog
#1
What's wrong?

Member function __Font.Create2
Code:
Copy      Help
function# $font [size] [style] [rotate];;style: 1 bold, 2 italic, 4 underline, 8 strikeout

;Creates font.
;If font is "", uses "Tahoma".


LOGFONT lf
if(size)
,int hdc=GetDC(0)
,lf.lfHeight=-MulDiv(size GetDeviceCaps(hdc LOGPIXELSY) 72)
,ReleaseDC 0 hdc
else lf.lfHeight=0
lf.lfWeight=iif(style&1 FW_BOLD FW_NORMAL)
lf.lfItalic=style&2
lf.lfUnderline=style&4
lf.lfStrikeOut=style&8
lf.lfCharSet=1
lf.lfEscapement=rotate
lf.lfOrientation=rotate
if(empty(font)) font="Tahoma"
strncpy(&lf.lfFaceName font 31)

if(handle) DeleteObject handle
handle=CreateFontIndirect(&lf)


Function test_rotate_text
Code:
Copy      Help
\Dialog_Editor
function# hDlg message wParam lParam
if(hDlg) goto messages


if(!ShowDialog("test_rotate_text" &test_rotate_text)) ret

;BEGIN DIALOG
;0 "" 0x90C80AC8 0x0 0 0 223 135 "Dialog"
;1 Button 0x54030001 0x4 120 116 48 14 "OK"
;2 Button 0x54030000 0x4 170 116 48 14 "Cancel"
;3 Static 0x54000000 0x0 26 14 154 98 "This is a test"
;END DIALOG
;DIALOG EDITOR: "" 0x2030108 "" "" ""

ret
;messages
sel message
,case WM_INITDIALOG
,__Font-- f.Create2("Courier New" 20 1|2 450)
,f.SetDialogFont(hDlg "3")
,case WM_DESTROY
,case WM_COMMAND goto messages2
ret
;messages2
sel wParam
,case IDOK
,case IDCANCEL
ret 1
#2
I never tried it, maybe it only for making italic. If does not do what you want, draw text in a memory device context, rotate the bitmap..
#3
In http://bcbjournal.org/articles/vol2/980 ... 5aba2d519c

At this point, the LOGFONT structure has been filled in with information obtained from the form's Font property. The next step is to change the escapement and orientation. Both of these parameters are specified in tenths of degrees. For example, to rotate the font 45 degrees, you'd set lfEscapement and lfOrientation to 450:
lf.lfEscapement = 450;
lf.lfOrientation = 450;
#4
Works when you draw text with TextOut.

note: set ownerdraw style for the static control.

Function test_rotate_text
Code:
Copy      Help
\Dialog_Editor
function# hDlg message wParam lParam
if(hDlg) goto messages


if(!ShowDialog("test_rotate_text" &test_rotate_text)) ret

;BEGIN DIALOG
;0 "" 0x90C80AC8 0x0 0 0 223 135 "Dialog"
;1 Button 0x54030001 0x4 120 116 48 14 "OK"
;2 Button 0x54030000 0x4 170 116 48 14 "Cancel"
;3 Static 0x5400000D 0x0 26 14 98 84 ""
;END DIALOG
;DIALOG EDITOR: "" 0x2030109 "" "" ""

ret
;messages
sel message
,case WM_INITDIALOG
,__Font-- f.Create2("Courier New" 20 1|2 450)
,case WM_DESTROY
,case WM_COMMAND goto messages2
,case WM_DRAWITEM
,if(wParam=3) ;;control id
,,DRAWITEMSTRUCT& r=+lParam
,,int of=SelectObject(r.hDC f.handle)
,,BSTR b="This is a test"
,,TextOutW r.hDC 0 r.rcItem.bottom-30 b b.len
,,SelectObject r.hDC of

ret
;messages2
sel wParam
,case IDOK
,case IDCANCEL
ret 1
#5
Thanks.


Forum Jump:


Users browsing this thread: 1 Guest(s)