Problem with highlight property

Discussion in 'AutoCAD' started by Tom Roberts, Oct 4, 2004.

  1. Tom Roberts

    Tom Roberts Guest

    I am displaying a modaless userform from which the User can select from a
    list of entity handles displayed in a ListBox.
    I would like to hightlight entities in the drawing window as their
    corrosponding entry in the listbox is clicked.

    My problem is that the hightlight method does not take effect until the
    drawing window receives the focus again.
    ie the User clicks in the graphics window.
    Calling the Update method of an entity after its hightlight property is set
    to TRUE has no effect.
    The code I am using is below. Any suggestion would be most welcome
    Please note that my form does have the acFocus control on it, however
    removing it does not seem to help

    --
    Regards
    Tom Roberts
    __________________________
    MechWest Design & Drafting
    Perth, Western Australia



    '---------code---------
    Dim i As Integer
    Dim objEnt As AcadEntity

    For i = 0 To lstItems.ListCount - 1
    Set objEnt = ThisDrawing.HandleToObject(lstItems.List(i))
    If lstItems.Selected(i) = True Then
    objEnt.Highlight True
    Else
    objEnt.Highlight False
    End If
    'objEnt.Update
    Next i
    '---------end of code------------
     
    Tom Roberts, Oct 4, 2004
    #1
  2. Here, paste this onto a form that has a listbox and the focus control:

    Option Explicit

    Private oEnt As AcadEntity

    Private Sub ListBox1_Click()
    If Not oEnt Is Nothing Then oEnt.Highlight False
    Set oEnt = ThisDrawing.HandleToObject(ListBox1.Text)
    oEnt.Highlight True
    Me.Move Me.Left + 1
    Me.Move Me.Left - 1
    End Sub

    Private Sub UserForm_Initialize()
    For Each oEnt In ThisDrawing.ModelSpace
    ListBox1.AddItem oEnt.Handle
    Next
    End Sub

    -- Mike
    ___________________________
    Mike Tuersley
    CADalyst's CAD Clinic
    Rand IMAGINiT Technologies
    ___________________________
    the trick is to realize that there is no spoon...
     
    Mike Tuersley, Oct 4, 2004
    #2
  3. Tom Roberts

    Tom Roberts Guest

    Thanks Mike, works great

    My listbox is set to MultiSelect = 2 (extended) which is why I looped thru
    all the list items checking the Selected property
    I found that a listbox does not respond to the click event when MultiSelect
    = 1 or 2.
    Therefore I run my code from the MouseUp event. Is this good practice...it
    works!

    --
    Regards
    Tom Roberts
    __________________________
    MechWest Design & Drafting
    Perth, Western Australia
     
    Tom Roberts, Oct 5, 2004
    #3
Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.