1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

using textout api function

Discussion in 'Visual Basic ( VB )' started by drnda, Sep 22, 2010.

  1. drnda

    drnda New Member

    Joined:
    Sep 12, 2010
    Messages:
    5
    Likes Received:
    0
    Trophy Points:
    0
    did anyone know how set fontsize with textout api thanks
    :undecided
     
  2. virxen

    virxen New Member

    Joined:
    Nov 24, 2009
    Messages:
    387
    Likes Received:
    90
    Trophy Points:
    0
    drnda likes this.
  3. drnda

    drnda New Member

    Joined:
    Sep 12, 2010
    Messages:
    5
    Likes Received:
    0
    Trophy Points:
    0
    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:confused:
     
  4. virxen

    virxen New Member

    Joined:
    Nov 24, 2009
    Messages:
    387
    Likes Received:
    90
    Trophy Points:
    0
    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: Sep 27, 2010
    drnda likes this.
  5. drnda

    drnda New Member

    Joined:
    Sep 12, 2010
    Messages:
    5
    Likes Received:
    0
    Trophy Points:
    0
    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
    
    
    
     
  6. virxen

    virxen New Member

    Joined:
    Nov 24, 2009
    Messages:
    387
    Likes Received:
    90
    Trophy Points:
    0
    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 likes this.
  7. drnda

    drnda New Member

    Joined:
    Sep 12, 2010
    Messages:
    5
    Likes Received:
    0
    Trophy Points:
    0
    I forgot to tell you, I using OVTOOLLibrary.
    Maybe is problem with this lib.
     

Share This Page