Solved

I'm not getting back what I stored with CB_SETITEMDATA

Posted on 2006-11-16
2
510 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
[X]
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
  • 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

Want Experts Exchange at your fingertips?

With Experts Exchange’s latest app release, you can now experience our most recent features, updates, and the same community interface while on-the-go. Download our latest app release at the Android or Apple stores today!

Question has a verified solution.

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

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…
C++ Properties One feature missing from standard C++ that you will find in many other Object Oriented Programming languages is something called a Property (http://www.experts-exchange.com/Programming/Languages/CPP/A_3912-Object-Properties-in-C.ht…
The goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…
The viewer will be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.

623 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