This function from the forums looked promising, but does not draw its text where you would expect! Or possibly I should have stopped coding a couple of hours (or maybe decades) ago!
Questions - what is wrong with this code? Is there a better way to do this?
Questions - what is wrong with this code? Is there a better way to do this?
Code:
#compile exe #dim all #include "win32api.inc" '--------------------------------------------- ' Borje Hagsten, Dean Schrage et al sub drawrotatedtext( byval hdc as long , _ s_textlabel as string , _ s_fontname as string , _ byval pointsize as long , _ byval q_rotationangle as double , _ byval x as long , _ byval y as long ) ' derives from http://www.powerbasic.com/support/pb...ad.php?t=10519 dim lf as logfont dim fnt as long dim fntold as long dim hfnt_old as long lf.lfcharset = %default_charset lf.lfclipprecision = %clip_default_precis lf.lfescapement = 10 * q_rotationangle lf.lforientation = lf.lfescapement lf.lfheight = - muldiv(pointsize, getdevicecaps(hdc&, %logpixelsy), 72) lf.lfweight = 400 ' normal is 400 bold is 700 lf.lfitalic = 0 lf.lfoutprecision = %out_tt_only_precis lf.lfpitchandfamily = %variable_pitch lf.lfquality = %proof_quality lf.lfunderline = 0 lf.lfstrikeout = 0 lf.lffacename = s_fontname fnt& = createfontindirect(lf) fntold& = selectobject(hdc&,fnt&) textout hdc&, x, y, byval strptr(s_textlabel), len(s_textlabel) hfnt_old = selectobject(hdc&, fntold&) deleteobject fnt& end sub '------------------------------------------ function pbmain () as long local hDC, hGR as dword local d as double graphic window "TEST", 300, 300, 300, 100 to hGR graphic attach hGR, 0 graphic get dc to hDC d = 30 drawrotatedtext( hdc, "TEST", "ARIAL", 10, d, 100, 100) drawrotatedtext( hdc, "XXXX", "ARIAL", 10, d, 50, 50) drawrotatedtext( hdc, "ZZZZ", "ARIAL", 10, d, 150, 100) graphic redraw graphic waitkey$ end function
Comment