Results 1 to 6 of 6

Thread: Need some help searchng through a font box efficently *resolved*

  1. #1

    Thread Starter
    Fanatic Member Graff's Avatar
    Join Date
    Jan 2002
    Location
    Calgary
    Posts
    668

    Need some help searchng through a font box efficently *resolved*

    I'm writing a lite text editor and I have a font box (a custom control I downloaded from http://www.connetica.co.uk) populated with font names. I have it all working now but the font list always says the last used font, which if I have moved to a different part of the text may not necessarly be the font I'm using.

    I've made a loop that goes through the font list to find the apropriate font but it slows down everything while it goes through the list.

    VB Code:
    1. For i = 0 To cboFont(Index).ListCount - 1
    2.            
    3.             If cboFont(Index).ItemFont(i).Name = rtxtDesc(Index).SelFontName Then
    4.                 cboFont(Index).ListIndex = i
    5.                 Exit For
    6.             End If
    7.         Next

    Any ideas on how to speed this up or possibly a better way?
    Last edited by Graff; Dec 31st, 2002 at 04:45 AM.
    If wishes were fishes we'd all cast nets.

  2. #2
    -= B u g S l a y e r =- peet's Avatar
    Join Date
    Aug 2000
    Posts
    9,629
    It might be quicker using the sendmessage api

    sample

    VB Code:
    1. Option Explicit
    2. Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Integer, ByVal lParam As Any) As Long
    3. Private Const CB_FINDSTRING = &H14C
    4.  
    5. Private Sub Text1_Change()
    6.     Combo1.ListIndex = SendMessage(Combo1.hwnd, CB_FINDSTRING, -1, ByVal CStr(Text1.Text))
    7. End Sub
    -= a peet post =-

  3. #3

    Thread Starter
    Fanatic Member Graff's Avatar
    Join Date
    Jan 2002
    Location
    Calgary
    Posts
    668
    I'll try that thanks
    If wishes were fishes we'd all cast nets.

  4. #4

    Thread Starter
    Fanatic Member Graff's Avatar
    Join Date
    Jan 2002
    Location
    Calgary
    Posts
    668
    Worked like a charm, thanks again.
    If wishes were fishes we'd all cast nets.

  5. #5
    -= B u g S l a y e r =- peet's Avatar
    Join Date
    Aug 2000
    Posts
    9,629
    Just want to know Graff, was it a lot quicker ?
    -= a peet post =-

  6. #6

    Thread Starter
    Fanatic Member Graff's Avatar
    Join Date
    Jan 2002
    Location
    Calgary
    Posts
    668
    With my method there was a noticable lag of about ~250 - 500 ms where as the api method is almost instantaneous.
    If wishes were fishes we'd all cast nets.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width