using textout api function

drnda's Avatar, Join Date: Sep 2010
Light Poster
did anyone know how set fontsize with textout api thanks
virxen's Avatar, Join Date: Nov 2009
Pro contributor
Quote:
.......

The text will be displayed using the device's currently selected font and text drawing color
..........
from here
http://www.ex-designz.net/apidetail.asp?api_id=343
drnda like this
drnda's Avatar, Join Date: Sep 2010
Light Poster
yes i know that but it can`t aply with picturebox, and I need dinamicly set horizontal text means like this
dim text as string
text="something"

dim txt as integer,vt as integer
txt=len(text)
hz=picture1.hwight-txt
textout hz,vt,text,txt

sorry for my bad english
thanks
virxen's Avatar, Join Date: Nov 2009
Pro contributor
picturebox has font property.Did you try setting it's font size before using
textout?

Code:
..........
Private Sub Command1_Click()
Dim retval As Long ' return value
retval = SetTextAlign(mem_dc, TA_CENTER Or TA_TOP Or TA_NOUPDATECP)
Picture1.FontSize = 50
retval = TextOut(Picture1.hdc, 100, 50, "Hello, world!", 13)
End Sub
........

Last edited by virxen; 28Sep2010 at 02:24..
drnda like this
drnda's Avatar, Join Date: Sep 2010
Light Poster
Yes, I tried that, but doesn`t work. Did You have any other sugestion?
I `ll send you small code of my work.

please tell me if I do some wrong.

thank`s

Code:
Private Sub Slider1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
    Timer2.Enabled = False
End Sub
Private Sub Slider1_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
    Timer2.Enabled = True
    poz.CurrentPosition = Slider1.Value
            starts = Slider1.Value
    find_start (starts) 'search for time
    DoEvents
End Sub
Private Sub Timer1_Timer()

' searching for same time at the listview
' and when found then set text on picturebox (Ekran)


  On Error Resume Next

    Dim dc As Long
    Dim cr As Long
Dim SubTitl As String
    Dim start As String
    Dim sstop As String
    Dim p As Integer, p1 As Integer, scn As Long
        Dim hz As Integer, vrt As Integer, lst As Integer
hz = 0: vrt = 0: lst = 0
 Label3.Caption = TimSet(poz.Duration)
Label2.Caption = TimSet(poz.CurrentPosition)
            starts = poz.CurrentPosition
    find_start (starts) ' when slider is moving search the time
         sstop = Left$(ListView1.ListItems.Item(stnum).SubItems(2), 8) ' stop time
        start = Left$(ListView1.ListItems.Item(stnum).SubItems(1), 8) ' start time
    If TimSet(poz.CurrentPosition) = start Then
    SubTitl = ListView1.ListItems.Item(stnum).SubItems(3) ' set text to subtitle string
    lst = (Len(SubTitl) \ 2)
   hz = (Ekran.Height \ 2) - lst
        vrt = 250
    dc = TxtInsert.GetHDC()
    cr = TxtInsert.ColourKey
    SetBkColor dc, cr
    cr = 16777215   'bijela boja, white colour
    SetTextColor dc, cr
    Ekran.FontSize = 50
    TextOutA dc, hz, vrt, SubTitl, Len(SubTitl)
    TxtInsert.ReleaseDC dc
ElseIf TimSet(poz.CurrentPosition) = sstop Then
stnum = stnum + 1 ' set to next search stnum is up[/COLOR]
    End If
End Sub
Private Sub Timer2_Timer()
Slider1.Value = poz.CurrentPosition
End Sub
Private Function TimSet(SecAply As Double) As String
On Error Resume Next
Dim Sek, Mnt, Sat
SecAply = Int(SecAply)
If SecAply < 1 Then TimSet = "00:00:00": Exit Function
Sek = SecAply - Int(SecAply / 60) * 60
Mnt = Int((SecAply - Int(SecAply / 3600) * 3600) / 60)
Sat = Int(SecAply / 3600)
If Int(Sat) > 24 Then
TimSet = "24:59:59"
Else
TimSet = Format(str(Sat) & ":" & str(Mnt) & ":" & str(Sek), "hh:mm:ss")
End If
End Function
Private Function find_start(st As Double) As String
Dim i As Integer
Dim stext As String, ftext As String

ftext = TimSet(st)
For i = 1 To ListView1.ListItems.Count
stext = Left$(ListView1.ListItems.Item(i).SubItems(1), 8)
     If ftext = stext Then
  stnum = i
Exit For
End If
Next i
stext = ""
ftext = ""
End Function
virxen's Avatar, Join Date: Nov 2009
Pro contributor
Quote:
.........
Ekran.FontSize = 50
TextOutA dc, hz, vrt, SubTitl, Len(SubTitl)
.........
try to change it into

Code:
.............
Ekran.FontSize = 50     
TextOut(Ekran.hdc, hz, vrt, SubTitl, Len(SubTitl) 
.............
or send your project in a zip file to check it.
drnda like this
drnda's Avatar, Join Date: Sep 2010
Light Poster
I forgot to tell you, I using OVTOOLLibrary.
Maybe is problem with this lib.