Click here to Skip to main content
15,914,500 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
QuestionHow to get last window's hwnd Pin
josip cagalj3-Sep-07 1:45
josip cagalj3-Sep-07 1:45 
AnswerRe: How to get last window's hwnd Pin
Nishad S3-Sep-07 2:46
Nishad S3-Sep-07 2:46 
GeneralRe: How to get last window's hwnd [modified] Pin
josip cagalj3-Sep-07 21:52
josip cagalj3-Sep-07 21:52 
QuestionTDI Server Programme .... TdiBuildListen help Pin
barun_iit3-Sep-07 0:30
barun_iit3-Sep-07 0:30 
QuestionHow to use SetItem() and GetItem() for ListCtrl having JPEG images? Pin
Atul233-Sep-07 0:15
Atul233-Sep-07 0:15 
AnswerRe: How to use SetItem() and GetItem() for ListCtrl having JPEG images? Pin
Nishad S3-Sep-07 1:41
Nishad S3-Sep-07 1:41 
GeneralRe: How to use SetItem() and GetItem() for ListCtrl having JPEG images? Pin
Atul233-Sep-07 1:55
Atul233-Sep-07 1:55 
GeneralRe: How to use SetItem() and GetItem() for ListCtrl having JPEG images? Pin
Nishad S3-Sep-07 2:44
Nishad 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
shakumar_222-Sep-07 23:56 
AnswerRe: Import dll to vc++ Pin
chandu0043-Sep-07 0:01
chandu0043-Sep-07 0:01 
GeneralRe: Import dll to vc++ Pin
shakumar_223-Sep-07 0:56
shakumar_223-Sep-07 0:56 
AnswerRe: Import dll to vc++ Pin
Hamid_RT3-Sep-07 0:05
Hamid_RT3-Sep-07 0:05 
Questionhi Pin
Lakshmi_p2-Sep-07 23:47
Lakshmi_p2-Sep-07 23:47 
AnswerRe: hi Pin
baerten2-Sep-07 23:53
baerten2-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
Lakshmi_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
George_George2-Sep-07 23:27 
QuestionStack overflow while reading bamp image Pin
Maynka2-Sep-07 23:26
Maynka2-Sep-07 23:26 
AnswerRe: Stack overflow while reading bamp image Pin
chandu0042-Sep-07 23:48
chandu0042-Sep-07 23:48 
AnswerRe: Stack overflow while reading bamp image Pin
Russell'2-Sep-07 23:55
Russell'2-Sep-07 23:55 
AnswerRe: Stack overflow while reading bamp image Pin
Mark Salsbery3-Sep-07 9:05
Mark Salsbery3-Sep-07 9:05 
GeneralRe: Stack overflow while reading bamp image Pin
Maynka3-Sep-07 18:45
Maynka3-Sep-07 18:45 
GeneralRe: Stack overflow while reading bamp image Pin
Mark Salsbery3-Sep-07 20:31
Mark Salsbery3-Sep-07 20:31 
QuestionPicture Control / Client Rectangle Pin
TheShihan2-Sep-07 23:22
TheShihan2-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.