Click here to Skip to main content
14,664,547 members
Home » Discussions » C / C++ / MFC
   

C / C++ / MFC

 
QuestionHow to get last window's hwnd Pin
josip cagalj3-Sep-07 1:45
Memberjosip cagalj3-Sep-07 1:45 
AnswerRe: How to get last window's hwnd Pin
Nishad S3-Sep-07 2:46
MemberNishad S3-Sep-07 2:46 
GeneralRe: How to get last window's hwnd [modified] Pin
josip cagalj3-Sep-07 21:52
Memberjosip cagalj3-Sep-07 21:52 
QuestionTDI Server Programme .... TdiBuildListen help Pin
barun_iit3-Sep-07 0:30
Memberbarun_iit3-Sep-07 0:30 
QuestionHow to use SetItem() and GetItem() for ListCtrl having JPEG images? Pin
Atul233-Sep-07 0:15
MemberAtul233-Sep-07 0:15 
AnswerRe: How to use SetItem() and GetItem() for ListCtrl having JPEG images? Pin
Nishad S3-Sep-07 1:41
MemberNishad S3-Sep-07 1:41 
GeneralRe: How to use SetItem() and GetItem() for ListCtrl having JPEG images? Pin
Atul233-Sep-07 1:55
MemberAtul233-Sep-07 1:55 
GeneralRe: How to use SetItem() and GetItem() for ListCtrl having JPEG images? Pin
Nishad S3-Sep-07 2:44
MemberNishad S3-Sep-07 2:44 
Atulmahajan wrote:
Yes It is Local.



So I think you are mistaken.

Actually you are trying to save the image name along with each list control item, right? SetItemData is holding only a 4 byte value. We are using this to hold a pointer. Here in your case, it is a pointer to the string. Since the string is local when you exit from the function, the pointer will not be valid. So the stored pointer has no use.

One solution is that you can dynamically allocate the string in heap (using new CString). But need to delete the memory when you close the window, or delete the list control item.

Another method is that you can use a CStringArray object as member variable. Then you can store each string in the array and can keep the index in the list control item data. Here also removal of the string item from the array is needed, if you delete a list control item (just for saving the memory).

Hope you got the idea.

- NS -

QuestionImport dll to vc++ Pin
shakumar_222-Sep-07 23:56
Membershakumar_222-Sep-07 23:56 
AnswerRe: Import dll to vc++ Pin
chandu0043-Sep-07 0:01
Memberchandu0043-Sep-07 0:01 
GeneralRe: Import dll to vc++ Pin
shakumar_223-Sep-07 0:56
Membershakumar_223-Sep-07 0:56 
AnswerRe: Import dll to vc++ Pin
Hamid_RT3-Sep-07 0:05
MemberHamid_RT3-Sep-07 0:05 
Questionhi Pin
Lakshmi_p2-Sep-07 23:47
MemberLakshmi_p2-Sep-07 23:47 
AnswerRe: hi Pin
baerten2-Sep-07 23:53
Memberbaerten2-Sep-07 23:53 
GeneralRe: hi Pin
Rajesh R Subramanian2-Sep-07 23:59
professionalRajesh R Subramanian2-Sep-07 23:59 
GeneralRe: hi Pin
Lakshmi_p3-Sep-07 0:37
MemberLakshmi_p3-Sep-07 0:37 
AnswerRe: hi Pin
Rajesh R Subramanian3-Sep-07 0:08
professionalRajesh R Subramanian3-Sep-07 0:08 
Questionabout HKEY_CLASSES_ROOT TypeLib Pin
George_George2-Sep-07 23:27
MemberGeorge_George2-Sep-07 23:27 
QuestionStack overflow while reading bamp image Pin
Maynka2-Sep-07 23:26
MemberMaynka2-Sep-07 23:26 
AnswerRe: Stack overflow while reading bamp image Pin
chandu0042-Sep-07 23:48
Memberchandu0042-Sep-07 23:48 
AnswerRe: Stack overflow while reading bamp image Pin
Russell'2-Sep-07 23:55
MemberRussell'2-Sep-07 23:55 
AnswerRe: Stack overflow while reading bamp image Pin
Mark Salsbery3-Sep-07 9:05
MemberMark Salsbery3-Sep-07 9:05 
GeneralRe: Stack overflow while reading bamp image Pin
Maynka3-Sep-07 18:45
MemberMaynka3-Sep-07 18:45 
GeneralRe: Stack overflow while reading bamp image Pin
Mark Salsbery3-Sep-07 20:31
MemberMark Salsbery3-Sep-07 20:31 
QuestionPicture Control / Client Rectangle Pin
TheShihan2-Sep-07 23:22
MemberTheShihan2-Sep-07 23:22 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.