dcsimg
Results 1 to 9 of 9
  1. #1

    Thread Starter
    PowerPoster
    Join Date
    Jun 2013
    Posts
    3,665

    VB6 Simple Virtual ComboBox (OwnerDrawn)

    As the title says, a simple approach to accomplish ownerdrawing from Data in external Data-Containers
    in a "DropDown-scenario".

    As usual with virtual (bound) Controls, they are internally lightweight, since the Drawing happens on the outside.

    Nevertheless (depending on what the OwnerDraw-Event offers), a typical scenario
    can usually be implemented in only a few lines of OwnerDraw-Handler-Code -
    right on the Data of your exernal DataSource-Container (be that an Array, a Collection or a Recordset).

    The implementation below is based on only about 140 Lines of UserControl-Code.
    Feel free to swap the SubClasser (Tricks clsSubClass currently) to your own implementation, if you like...

    And since "Multi-Select-DropDown-scenarios" are apparently "en vouge" these days,
    the Control supports this as well - as the ScreenShot below shows:


    Ok, here's the Demo-Code: VirtualCombo.zip

    Have fun with it...

    Edit: enhancement of the MinVisibleItems-Prop, to work also in non-manifested environments.
    Edit2: MouseWheel-based Scrolling now updates the currently selected Item-under the Mouse + additional Event (MouseMoveOnItem, to address Hover-Areas within a given Item)

    Olaf
    Last edited by Schmidt; Today at 11:41 AM.

  2. #2
    Frenzied Member gibra's Avatar
    Join Date
    Oct 2009
    Location
    ITALY
    Posts
    1,543

    Re: VB6 Simple Virtual ComboBox (OwnerDrawn)

    Why, regardless of the setting of MinVisibleItems, always and only 4 items are displayed?

    Both on IDE and compiled EXE.

  3. #3

    Thread Starter
    PowerPoster
    Join Date
    Jun 2013
    Posts
    3,665

    Re: VB6 Simple Virtual ComboBox (OwnerDrawn)

    Quote Originally Posted by gibra View Post
    Why, regardless of the setting of MinVisibleItems, always and only 4 items are displayed?

    Both on IDE and compiled EXE.
    It's a feature of the (newer) CommonControls...

    Meaning, as soon as you run your IDE with appropriate "manifest-support",
    or (for the compiled Binary) include a CommonControls-covering *.res file into your Project,
    everything should look as in the ScreenShot...

    Edit: I've now included two lines, which should ensure the feature in roughly the same way also in non-manifested environments.
    ... have uploaded a new Zip...


    HTH

    Olaf
    Last edited by Schmidt; Jul 2nd, 2018 at 04:08 AM.

  4. #4
    Frenzied Member gibra's Avatar
    Join Date
    Oct 2009
    Location
    ITALY
    Posts
    1,543

    Re: VB6 Simple Virtual ComboBox (OwnerDrawn)

    Quote Originally Posted by Schmidt View Post
    Edit: I've now included two lines, which should ensure the feature in roughly the same way also in non-manifested environments.
    ... have uploaded a new Zip...
    Thank, now work good.

  5. #5
    PowerPoster Elroy's Avatar
    Join Date
    Jun 2014
    Location
    Near Nashville TN
    Posts
    4,386

    Re: VB6 Simple Virtual ComboBox (OwnerDrawn)

    Very nice Olaf. Not quite as full-featured as PGBSoft's, but far less code to get it done. Definitely two thumbs up from me.

    Take Care,
    Elroy
    Any software I post in these forums written by me is provided “AS IS” without warranty of any kind, expressed or implied, and permission is hereby granted, free of charge and without restriction, to any person obtaining a copy. Please understand that I’ve been programming since the mid-1970s and still have some of that code. My contemporary VB6 project is approaching 1,000 modules. In addition, I have a “VB6 random code folder” that is overflowing. I’ve been at this long enough to truly not know with absolute certainty from whence every single line of my code has come, with much of it coming from programmers under my employ who signed intellectual property transfers. I have not deliberately attempted to remove any licenses and/or attributions from any software. If someone finds that I have inadvertently done so, I sincerely apologize, and, upon notice and reasonable proof, will re-attach those licenses and/or attributions. To all, peace and happiness.

  6. #6
    Frenzied Member
    Join Date
    Jan 2010
    Posts
    1,102

    Re: VB6 Simple Virtual ComboBox (OwnerDrawn)

    fast scrolling cause weird behavior (mouse on an item and click, but highlight and select anothet item).

    Edited: look like it is Listbox standard behavior. We need a mouse move after fast scrolling.
    Attached Images Attached Images  
    Last edited by Jonney; Jul 16th, 2018 at 10:08 PM.

  7. #7

    Thread Starter
    PowerPoster
    Join Date
    Jun 2013
    Posts
    3,665

    Re: VB6 Simple Virtual ComboBox (OwnerDrawn)

    Quote Originally Posted by Jonney View Post
    fast scrolling cause weird behavior (mouse on an item and click, but highlight and select anothet item).

    Edited: look like it is Listbox standard behavior. We need a mouse move after fast scrolling.
    This behaviour is now addressed (the hovered-Item is now reflected, also in MouseWheel-scrollings, where the Mouse is not moved otherwise).

    Olaf

  8. #8

    Thread Starter
    PowerPoster
    Join Date
    Jun 2013
    Posts
    3,665

    Re: VB6 Simple Virtual ComboBox (OwnerDrawn)

    Quote Originally Posted by Elroy View Post
    Very nice Olaf. Not quite as full-featured as PGBSoft's, but far less code to get it done. Definitely two thumbs up from me.
    Well, at the moment I cannot think of a scenario which won't be possible with that virtual Control
    (and a whole lot of scenarios, which are impossible with non-virtual Controls, that do not support OwnerDrawing).

    Not many VB6-Users are familiar with the concept of an external DataContainer - perhaps that's the reason, why so much stuff gets "crammed" into the Controls itself.

    To give a few examples...:
    - Sorting (if you choose e.g. an ADO-Rs as your external DataContainer, you have multiple-column-sorts easily available - stuff like that does not belong into a Control IMO)
    - Searching (same thing as with Sorting - just use your own Find- or Filter-routines on your external DataContainer - e.g. an ADO-Rs already comes with appropriate methods)
    - Grid-like, or even TreeView-like real Multi-Colum-rendering is easily possible - and only depends on your external DataSource and how you manage the States there...

    Virtual Controls are far underused by the community IMO.
    They not only offer advantages implementation-wise (smaller, easier maintainable codebase) - but usage- (or UserCode-)wise as well.

    Olaf

  9. #9
    Lively Member
    Join Date
    May 2016
    Location
    China
    Posts
    79

    Re: VB6 Simple Virtual ComboBox (OwnerDrawn)

    I added a button support, let's see if it is needed: while supporting F4, you can press the down arrow to open the list.

    Private Sub oCB_KeyDown(KeyCode As Integer, Shift As Integer)
    If KeyCode = vbKeyDown And Not DroppedDownState Then
    KeyCode = vbKeyF4
    End If
    End Sub
    QQ: 289778005

Posting Permissions

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



Featured


Click Here to Expand Forum to Full Width