»ñµÃVB listbox Ñ¡ÖÐÏîÄ¿(¶àÏî)µÄÒ»¸öºÃ·½·¨
´«Í³·½·¨ÊDZéÀúÒ»±é
Èç¹ûlistbox ÏîÄ¿¹ý¶à
Ã÷ÏÔËٶȲ»ÐÐ
ºÃ·½·¨ÊÇͨ¹ýsendmessge·¢ÏûÏ¢¸ølistboxÈÃËû°ÑÑ¡ÖÐÏîÄ¿Ö±½Ó´«µ½²ÎÊýÊý×éÖÐ
You can use the SendMessage() API function instead.
As
you probably know, this function lets you send a message to one or more
windows. The declaration statement conforms to the following syntax:
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
Since
we want to gather the listbox: selected items, we'll send the
LB_GETSELITEMS constant in the wMsg argument, which you declare like so:
Private Const LB_GETSELITEMS = &H191
The LB_GETSELITEMS message fills an array with the index numbers of all the selected items.
Dim ItemIndexes() As Long, x As Integer, iNumItems As Integer
iNumItems = ThisBox.SelCount
If iNumItems Then
ReDim ItemIndexes(iNumItems - 1)
SendMessage ListBox1.hwnd, LB_GETSELITEMS, iNumItems, ItemIndexes(0)
End If
For x = 0 To iNumItems - 1
MsgBox ListBox1.List(ItemIndexes(x)) 'µ¯³ö¶Ô»°¿ò
Next x
After
being passed to the SendMessage function, iNumItems holds the total
number of selected items, and the ItemIndexes array holds the selected
item index values. Notice, that you must pass a pointer to the
ItemIndexes array, and not the array itself. Thus, we passed
ItemIndexes(0) into the SendMessage function, not ItemIndexes().
Ïà¹ØÎĵµ£º
VB Treeview¿Ø¼þÏêϸʹÓ÷½·¨
1¡¢ÊôÐÔ
ÕâÀïÖ»¸ø´ó¼Ò½éÉÜTreeview¿ ......
ºÜ¶àÄêÇ°¾ÍÏë×öÒ»¸öÔ¶³Ì¿ØÖƵÄÈí¼þ£¬Ö»ÊÇÒ»Ö±ÒÔÀ´Í¼Æ¬µÄѹËõËÙ¶È×ÜÊÇÌáÉý²»ÉÏÈ¥£¬¶øÎÒÒ²²Î¿¼¹ýºÜ¶àÍøÉϵĹØÓÚͼƬѹËõµÄÀý×Ó£¬±ÈÈçzyl910µÄGIF_LZWѹËõ·½·¨£¬HuffmanѹËõ·½·¨£¬ÒÔÖÁµ½GDI+µÄÖ±½ÓÉú³ÉJPG¡¢PNGµÄ·½·¨£¨ÕâÖÖ·½·¨ÎÞÂÛ´ÓѹËõÂʺÍËÙ¶ÈÉ϶¼ÊÇ×î¼ÑµÄ£¬¿ÉϧÕâÖÖ·½·¨ÍøÉÏһֱûÕÒµ½Ö±½Ó±£´æΪByte()µÄÀý×Ó£¬¼ûµÃ×î¶àµÄ ......
ËäÈ»WindowsXPµÄ½çÃæ·Ç³£»ªÀö¡£µ«ÊÇÁîÈËÒź¶µÄÊÇ£¬ÎÒÃÇÓÃVBдµÄ³ÌÐò³ýÁ˲˵¥ºÍ´°¿ÚµÄÍâ¹ÛÊÇXP·ç¸ñÍ⣬ÆäËû¿Ø¼þ»¹ÊÇÒ»Èç¼ÈÍùµÄÊÇÆÕͨ·ç¸ñ¡£ÎÒÏ룬ÓеijÌÐòÔÚXPÏÂÓÐXPµÄ·ç¸ñ£¬VBÒ²Ò»¶¨Óа취ʵÏÖXPµÄ·ç¸ñ¡£ºóÀ´±ÊÕßÔÚÍøÉÏ¿´µ½Ò»Æª½éÉÜXMLµÄÎÄÕ£¬ÓÖÔÚÍøÉÏÕÒµ½ÁËһƪʵÏÖXP·ç¸ñµÄÎÄÕ£¬¾¹ý×Ô¼ºµÄʵ¼ù£¬ÖÕÓÚÕÒµ½ÁËVB³ÌÐò ......