-
Q:
Could you please tell me how to know the status of each
Check Box of the list?
A:
You can check Value property array. Value
property returns and sets the state of the checkbox
displayed in the listbox. The Value property
is an integer array that each element is a list item.
The setting is an integer number specifying the state
of the checkbox. False (default) is unchecked,
True is checked. The syntax is as follows,
[form.]Chklist.Value(Index)
[= setting%]
Back
to top.
-
Q:
Is there a way to turn off the checkmark?
A:
You can set NoCheckmark property to True, and then the
control will not display a checkmark in the front of
each item.
Back
to top.
-
Q:
Is there a way to make it where you had to
double-click on an item to check the box instead of
a single click?
A:
Yes. You can set ToggleMode
property. There are some choices which let your program
work like other popular software.
Back
to top.
-
Q:
Is there a TAG property for each individual
ITEM in the CheckListBox Control, or for only the control
itself? What is the correct syntax?
A:
The Tag property is for only the control itself.
There is an ItemData (Long type) property array
which can be used for each individual item in the CheckListBox
control. ItemData is an array of long integer.
For example, you can use it to store the index of another
string array as followings,
CheckListBox1.ItemData(
0 ) = 2
CheckListBox1.ItemData( 1 ) = 3
......
MsgBox arrString(CheckListBox1.ItemData _ (CheckListBox1.ListIndex))
Where arrString is a string array.
Back
to top.
-
Q:
I want to use your control in a web page, but it can't
work in a client machine without using the installating
program from you?
A:
CheckListBox is a licensed control. To use licensed
controls in an HTML page on a non-licensed computer,
you must generate a license package file (LPK). The
LPK file contains the run-time licenses for licensed
controls in the HTML page. Lpk_tool.exe, which originally
comes with the Internet Client SDK, generates this file.
You can download the Internet Client SDK from the following
Microsoft Web site:
http://msdn.microsoft.com/downloads/tools/lpktool/lpktool.asp
To embed
CheckListBox control on an HTML page, follow these steps:
1) Run Lpk_tool.exe
on a computer that is licensed to use the control.
2) Highlight
CheckListBox ActiveX control(in some machines, it may
be shown as "Chklist control"), and then click
Add.
3) Click
Save & Exit, and then type a name for the LPK file.
4) In the
HTML page, insert an <OBJECT> tag for the License
Manager object before any other <OBJECT> tags.
The License Manager is an ActiveX control that is installed
with Internet Explorer.
NOTE: This
CLASSID, "5220cb21-c88d-11cf-b347-00aa00a28331",
is for the License Manager and not for CheckListBox
ActiveX controls. You must use the same CLASSID every
time you refer to the LPK file. In addition, you should
keep the Name property of the <PARAM> tag as "LPKPath",
and set the Value property for the <PARAM> tag
of the License Manager object to the LPK file name and
path. This path may be a relative path but must not
refer to a UNC share or a URL on another domain.
Because
you can only have one LPK file for each HTML page, make
sure that you include all of the licensed ActiveX Controls
for the page when you generate your LPK file. For example:
<OBJECT
CLASSID = "clsid:5220cb21-c88d-11cf-b347-00aa00a28331"
VIEWASTEXT>
<PARAM
NAME="LPKPath" VALUE="relative URL to
.LPK file">
</OBJECT>
5) Insert
the <OBJECT> tag for your licensed control afterward.
For example, an HTML page that displays the CheckListBox
ActiveX control looks like this:
<OBJECT
CLASSID="clsid:5220cb21-c88d-11cf-b347-00aa00a28331"
VIEWASTEXT>
<PARAM
NAME="LPKPath" VALUE="chklist2.lpk">
</OBJECT>
<OBJECT
CLASSID="classid="clsid:22A21987-4FA2-11D1-AF19-444553540000"
WIDTH=100
HEIGHT=25 VIEWASTEXT>
</OBJECT>
Please refer
to MS knowledge base article "HOWTO:
Use Licensed ActiveX Controls in Internet Explorer [Q159923]."
Back
to top.
-
Q:
I was wondering if there is a way to get a horizontal
scroll bar on the CheckListBox?
A:
In Version 2.5 Build 7 and above, this feature is added
to the control. Add following code to add a horizontal
scroll bar to CheckListBox control.
Private Declare Function SendMessage Lib "user32" _
Alias "SendMessageA" (ByVal hwnd As Long,
_
ByVal wMsg As Long, ByVal wParam As Long,
_
lParam As Any) As Long
Private Const LB_SETHORIZONTALEXTENT = &H194
Private Sub Form_Load()
ChkList1.AddItem "Line 1"
ChkList1.AddItem "a big Line 2 some
text some text"
ChkList1.AddItem "Line 3"
addHorScrlBarListBox ChkList1
End Sub
Public Sub
addHorScrlBarListBox(ByVal refControlListBox As Object)
Dim nRet As Long
Dim nNewWidth As Integer
nNewWidth = 400 '
new width in pixels
nRet = SendMessage(refControlListBox.hwnd,
_
LB_SETHORIZONTALEXTENT, nNewWidth,
ByVal 0&)
End Sub
Back
to top
-
Q:
I want to be able to add a right click on each item
and have a popup menu. One thing that I am having problems
with is that if the item is not selected and you right
click then the popup menu appears but since it is not
selected I do not know which item the popup menu is
for, I get the last item normally selected but not the
one that I right clicked on. Is there a way with the
x and y that I could know where the right click was
done? Is there a way that when the right click is performed
that the item would become selected?
A:
A right click can't select some items automatically.
But you can sends the LB_ITEMFROMPOINT message to retrieve
the zero-based index of the item nearest the specified
point in a list box.
Following
is an example:
Global Const
LB_ITEMFROMPOINT = &H1A9
Declare Function
SendMessage Lib "user32" Alias "SendMessageA"
_
(ByVal
hWnd As Long, _
ByVal
wMsg As Long, _
ByVal
wParam As Long, _
lParam
As Any) As Long
Dim lRet
As Long
Dim lXPos
As Long, lYPos As Long
' Convert the cursor position into pixels , because
that is what is needed
lXPos =
CLng(x / Screen.TwipsPerPixelX)
lYPos =
CLng(y / Screen.TwipsPerPixelY)
'
If the right mouse button is clicked...
If Button
= 2 Then
'
Get the listitem closest to the cursor
'
NOTE: Since the X and Y values have to be in the form
of high and low
'
order words, send the values as ((lYPos * 65536) +
lXPos)
lRet =
SendMessage(ChkFileList.hWnd, LB_ITEMFROMPOINT, 0,
_
ByVal ((lYPos
* 65536) + lXPos))
'
If the returned value is a valid index, then set that
item as the selected
' item
If lRet
< ChkFileList.ListCount Then
ChkFileList.ListIndex
= lRet
'
now Popup the menu over the selected item with Selection
bar
' Highlighting it
PopupMenu
MnuChkListInfo
Else:
'
If not possible to highlight the item then beep
and exit
Beep
End If
End If
Back
to top.