Solved

I'm not getting back what I stored with CB_SETITEMDATA

Posted on 2006-11-16
2
474 Views
Last Modified: 2008-01-09
I'm storing SID in the combox Item Data area for each of the item.  It's showing correctly when I debug this and check the content of the test,
groupSid = {"S-1-5-21-1993962763-879983540-725345543-1630" (1)}
groupSid = {"S-1-5-21-1993962763-879983540-725345543-1635" (1)}
But when I use  CB_GETITEMDATA to get data I get someting like: lResult = 38448552

Can someone tell me how to resolve this problem?  Thanks.


const char* test = groupSid.operator const char *();
lResult = SendMessage(hwndPrimGroup, CB_SETITEMDATA,(WPARAM)(comboSize-1), (LPARAM)(test));


lResult = SendMessage(hwndPrimGroup, CB_GETITEMDATA ,(WPARAM)index, (LPARAM)0);
0
Comment
Question by:lapucca
  • 2
2 Comments
 
LVL 86

Accepted Solution

by:
jkr earned 500 total points
ID: 17962233
The lResult value is a pointer to the item data, so you'd use

char* pszData = (char*) SendMessage(hwndPrimGroup, CB_GETITEMDATA ,(WPARAM)index, (LPARAM)0);

MessageBox(NULL,pszData,"Test",MB_OK);

to get the result.
0
 
LVL 86

Expert Comment

by:jkr
ID: 17966624
Oh, and don't forget to test for a NULL pointer before using it.
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

Errors will happen. It is a fact of life for the programmer. How and when errors are detected have a great impact on quality and cost of a product. It is better to detect errors at compile time, when possible and practical. Errors that make their wa…
What is C++ STL?: STL stands for Standard Template Library and is a part of standard C++ libraries. It contains many useful data structures (containers) and algorithms, which can spare you a lot of the time. Today we will look at the STL Vector. …
The goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.

746 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

13 Experts available now in Live!

Get 1:1 Help Now