Solved

I'm not getting back what I stored with CB_SETITEMDATA

Posted on 2006-11-16
2
503 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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
C++ Language error 28 314
Beginner to Unreal Engine 4 5 120
Outlook 13 100
boost::uuid crashes 17 63
When writing generic code, using template meta-programming techniques, it is sometimes useful to know if a type is convertible to another type. A good example of when this might be is if you are writing diagnostic instrumentation for code to generat…
Container Orchestration platforms empower organizations to scale their apps at an exceptional rate. This is the reason numerous innovation-driven companies are moving apps to an appropriated datacenter wide platform that empowers them to scale at a …
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
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…

739 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