Go4Expert (http://www.go4expert.com/)
-   Visual Basic ( VB ) (http://www.go4expert.com/forums/visual-basic/)
-   -   using textout api function (http://www.go4expert.com/forums/using-textout-api-function-t23391/)

drnda 22Sep2010 21:34

using textout api function
did anyone know how set fontsize with textout api thanks

virxen 23Sep2010 02:33

Re: using textout api function


The text will be displayed using the device's currently selected font and text drawing color
from here

drnda 27Sep2010 13:57

Re: using textout api function
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

dim txt as integer,vt as integer
textout hz,vt,text,txt

sorry for my bad english

virxen 28Sep2010 02:00

Re: using textout api function
picturebox has font property.Did you try setting it's font size before using


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

drnda 28Sep2010 13:52

Re: using textout api function
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.



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
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"
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 29Sep2010 03:56

Re: using textout api function

Ekran.FontSize = 50
TextOutA dc, hz, vrt, SubTitl, Len(SubTitl)
try to change it into


Ekran.FontSize = 50   
TextOut(Ekran.hdc, hz, vrt, SubTitl, Len(SubTitl)

or send your project in a zip file to check it.

drnda 29Sep2010 22:57

Re: using textout api function
I forgot to tell you, I using OVTOOLLibrary.
Maybe is problem with this lib.

All times are GMT +5.5. The time now is 00:30.