Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

Sendmessage, listbox & itemdata

Posted on 1998-02-23
6
1,030 Views
Last Modified: 2008-02-01
Hello
I can, with sendmessage, fill the text of a listbox.
But, how, with sendmessage, fill the itemdata of a listbox?
Code needed.
Regards
0
Comment
Question by:trodri
  • 3
  • 2
6 Comments
 
LVL 3

Expert Comment

by:rmichels
ID: 1457707
Not sure about this, but ItemData appears to be an extension of the standard Microsoft listbox.  The VB control provides this, above and beyond a listbox.  Also in C++, the object wrapper around the listbox appears to provide the itemdata property.

But...hang on for more comments..cause I could be wrong.
0
 
LVL 8

Expert Comment

by:mrmick
ID: 1457708
You can find examples that demonstrate using sendmessage and the listbox as well as many other great VB examples at the following URL:

http://home.sprynet.com/sprynet/rasanen/vbnet/default.htm

Click Code Library on the left, List & Combo on the center left.

0
 

Author Comment

by:trodri
ID: 1457709
Sorry, i need code here
0
Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
LVL 8

Accepted Solution

by:
mrmick earned 100 total points
ID: 1457710
Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
Const LB_SETITEMDATA = &H19A

Assuming a listbox named "List1" has data, Index contains the index of the item and longData contains the value to be assinged to ItemData.  RC = Return Code.

RC = SendMessage(List1.hwnd, LB_SETITEMDATA, Index, longData)
0
 

Author Comment

by:trodri
ID: 1457711
Thanks very much, but....
i try this code using a combobox and i can put values in text using: rc = SendMessage(Combo1.hwnd, CB_ADDSTRING, 0, ByVal ja)
but i can't put any values on itemdata!!! In the two cases, rc is 0.
Can you help me? I give you the points, of course!
Regards
0
 
LVL 8

Expert Comment

by:mrmick
ID: 1457712
Sorry, that's because to set itemdata values in a combobox you must use

Const CB_SETITEMDATA = &H151

instead of the LB_SETITEMDATA



0

Featured Post

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction I needed to skip over some file processing within a For...Next loop in some old production code and wished that VB (classic) had a statement that would drop down to the end of the current iteration, bypassing the statements that were c…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

839 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question