This is a multi-part message in MIME format.
--------------1F1E7F44612C
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
Quote:
> You could do worse than to use the ListView control (part of the Windows
> common controls OCX).
> > Hello,
> > Does anybody know how to create a listbox or combobox with a icoc/bitmap
> on
> > the first position ? I know that they are in the new common controls like
> > the coolbar/rebar. If anybody has a control or codeexample how to create
> > this i would be very interested. I appreaciate any suggestions and/or
> > examples.
> > Thanks in advance !
> > Greetings,
> > Emile
I made the following control myself, and it's not quite finished yet.
But it works. Hope you can figure out how it works
--------------1F1E7F44612C
Content-Type: text/plain; charset=us-ascii; name="Droplist.ctl"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline; filename="Droplist.ctl"
VERSION 5.00
Object = "{6B7E6392-850A-101B-AFC0-4210102A8DA7}#1.1#0"; "comctl32.ocx"
Begin VB.UserControl CCDropList
ClientHeight = 4725
ClientLeft = 0
ClientTop = 0
ClientWidth = 8295
LockControls = -1 'True
ScaleHeight = 4725
ScaleWidth = 8295
Begin ComctlLib.ListView lvwCombo
Height = 2445
Left = 0
TabIndex = 2
Top = 350
Width = 3645
_ExtentX = 6429
_ExtentY = 4313
View = 3
LabelEdit = 1
LabelWrap = -1 'True
HideSelection = 0 'False
HideColumnHeaders= -1 'True
ForeColor = -2147483640
BackColor = -2147483643
BorderStyle = 1
Appearance = 0
BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851}
Name = "MS Sans Serif"
Size = 8.25
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
MouseIcon = "Droplist.ctx":0000
NumItems = 1
BeginProperty ColumnHeader(1) {0713E8C7-850A-101B-AFC0-4210102A8DA7}
Key = "X"
Object.Tag = ""
Text = ""
Object.Width = 2540
EndProperty
End
Begin VB.PictureBox picCombo
BackColor = &H80000005&
Height = 330
Left = 0
ScaleHeight = 270
ScaleWidth = 3765
TabIndex = 0
Top = 0
Width = 3825
Begin VB.Image imgDropButton
Height = 270
Left = 3510
Picture = "Droplist.ctx":001C
Top = 0
Width = 240
End
Begin VB.Image imgItem
Height = 240
Left = 15
Stretch = -1 'True
Top = 15
Width = 270
End
Begin VB.Label labItemText
BackStyle = 0 'Transparent
Height = 225
Left = 360
TabIndex = 1
Top = 30
Width = 2715
End
End
End
Attribute VB_Name = "CCDropList"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = True
Attribute VB_PredeclaredId = False
Attribute VB_Exposed = True
Option Explicit
Private Dropped As Boolean
'Events
Event ItemClick(Item As ListItem)
Event MouseDown(Button As Integer, Shift As Integer, x As Single, y As Single) 'MappingInfo=UserControl,UserControl,-1,MouseDown
Event MouseMove(Button As Integer, Shift As Integer, x As Single, y As Single) 'MappingInfo=UserControl,UserControl,-1,MouseMove
Event MouseUp(Button As Integer, Shift As Integer, x As Single, y As Single) 'MappingInfo=UserControl,UserControl,-1,MouseUp
Public Sub Add(Optional Key As Variant, Optional Text As Variant, Optional IconKey As Variant)
Dim ItmX As ListItem
Set ItmX = lvwCombo.ListItems.Add(, Key, Text, IconKey, IconKey)
End Sub
Public Property Let Icons(ged As Object)
Set lvwCombo.Icons = ged
Set lvwCombo.SmallIcons = ged
End Property
Public Sub SelectItem(ByVal Key As String)
Set lvwCombo.SelectedItem = lvwCombo.ListItems(Key)
End Sub
Public Property Get SelectedItem() As ListItem
Set SelectedItem = lvwCombo.SelectedItem
End Property
Public Property Let Sorted(ByVal S As Boolean)
lvwCombo.Sorted = S
End Property
Private Sub imgDropButton_MouseDown(Button As Integer, Shift As Integer, x As Single, y As Single)
Dropped = Dropped Xor True
Call UserControl_Resize
RaiseEvent MouseDown(Button, Shift, x, y)
End Sub
Private Sub imgDropButton_MouseMove(Button As Integer, Shift As Integer, x As Single, y As Single)
RaiseEvent MouseMove(Button, Shift, x, y)
End Sub
Private Sub imgDropButton_MouseUp(Button As Integer, Shift As Integer, x As Single, y As Single)
RaiseEvent MouseUp(Button, Shift, x, y)
End Sub
Private Sub imgItem_MouseDown(Button As Integer, Shift As Integer, x As Single, y As Single)
RaiseEvent MouseDown(Button, Shift, x, y)
End Sub
Private Sub imgItem_MouseMove(Button As Integer, Shift As Integer, x As Single, y As Single)
RaiseEvent MouseMove(Button, Shift, x, y)
End Sub
Private Sub imgItem_MouseUp(Button As Integer, Shift As Integer, x As Single, y As Single)
RaiseEvent MouseUp(Button, Shift, x, y)
End Sub
Private Sub labItemText_MouseDown(Button As Integer, Shift As Integer, x As Single, y As Single)
Dropped = Dropped Xor True
Call UserControl_Resize
RaiseEvent MouseDown(Button, Shift, x, y)
End Sub
Private Sub labItemText_MouseMove(Button As Integer, Shift As Integer, x As Single, y As Single)
RaiseEvent MouseMove(Button, Shift, x, y)
End Sub
Private Sub labItemText_MouseUp(Button As Integer, Shift As Integer, x As Single, y As Single)
RaiseEvent MouseUp(Button, Shift, x, y)
End Sub
Private Sub lvwCombo_ItemClick(ByVal Item As ComctlLib.ListItem)
labItemText.Caption = Item.Text
If Item.Icon <> "" Then
imgItem.Picture = lvwCombo.Icons.ListImages(Item.Icon).Picture
labItemText.Left = 360
Else
imgItem.Picture = Nothing
labItemText.Left = imgItem.Left
End If
Dropped = False
Call UserControl_Resize
RaiseEvent ItemClick(lvwCombo.SelectedItem)
End Sub
Private Sub lvwCombo_MouseDown(Button As Integer, Shift As Integer, x As Single, y As Single)
RaiseEvent MouseDown(Button, Shift, x, y)
End Sub
Private Sub lvwCombo_MouseMove(Button As Integer, Shift As Integer, x As Single, y As Single)
RaiseEvent MouseMove(Button, Shift, x, y)
End Sub
Private Sub lvwCombo_MouseUp(Button As Integer, Shift As Integer, x As Single, y As Single)
RaiseEvent MouseUp(Button, Shift, x, y)
End Sub
Private Sub UserControl_ExitFocus()
Dropped = False
Call UserControl_Resize
End Sub
Private Sub UserControl_LostFocus()
Dropped = False
Call UserControl_Resize
End Sub
Private Sub UserControl_Resize()
If Width < 700 Then Width = 700
If Dropped = False Then
Height = picCombo.Height
Else
Height = lvwCombo.Top + lvwCombo.Height
End If
picCombo.Width = Width
lvwCombo.Width = Width
lvwCombo.ColumnHeaders("X").Width = Width * 0.8
imgDropButton.Left = Abs(picCombo.ScaleWidth - imgDropButton.Width)
labItemText.Width = Abs(imgDropButton.Left - labItemText.Left)
End Sub
--------------1F1E7F44612C
Content-Type: application/octet-stream; name="Droplist.ctx"
Content-Transfer-Encoding: base64
Content-Disposition: attachment; filename="Droplist.ctx"
<encoded_portion_removed>
BwA=
--------------1F1E7F44612C
Content-Type: text/plain; charset=us-ascii; name="Droptree.ctl"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline; filename="Droptree.ctl"
VERSION 5.00
Object = "{6B7E6392-850A-101B-AFC0-4210102A8DA7}#1.1#0"; "comctl32.ocx"
Begin VB.UserControl CCDropTree
ClientHeight = 4725
ClientLeft = 0
ClientTop = 0
ClientWidth = 8295
LockControls = -1 'True
ScaleHeight = 4725
ScaleWidth = 8295
Begin ComctlLib.TreeView tvwCombo
Height = 2535
Left = 0
TabIndex = 2
Top = 345
Width = 2895
_ExtentX = 5106
_ExtentY = 4471
Indentation = 265
LabelEdit = 1
Style = 5
BorderStyle = 1
Appearance = 0
BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851}
Name = "MS Sans Serif"
Size = 8.25
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
End
Begin VB.PictureBox picCombo
BackColor = &H80000005&
Height = 330
Left = 0
ScaleHeight = 270
ScaleWidth = 3765
TabIndex = 0
Top = 0
Width = 3825
Begin VB.Image imgDropButton
Height = 270
Left = 3510
Picture = "Droptree.ctx":0000
Top = 0
Width = 240
End
Begin VB.Image imgItem
Height = 240
Left = 15
Stretch = -1 'True
...
read more »