Solved

Sendmessage, listbox & itemdata

Posted on 1998-02-23
6
1,025 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
6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

 
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

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
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…

760 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

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now