| View previous topic :: View next topic |
| Author |
Message |
Stylo Grandmaster Cheater Supreme
Reputation: 3
Joined: 16 May 2007 Posts: 1073 Location: Israel
|
Posted: Wed Jul 29, 2009 9:55 am Post subject: [C++] gets the text from specific index at listbox |
|
|
i'm having troubles suddenly when i try to get the text from a specific index from listbox
i first get the index that the cursor set b4
| Code: |
int index;
index = SendMessage(hList,LB_GETCURSEL,0,0);
|
then i try to get the text from that specific index
| Code: |
wchar_t *lpwName;
SendMessage(hList,LB_GETTEXT,(WPARAM)Index,(LPARAM)lpwName);
|
but my program crushes for no reason
i try using GetLastError but it keeps returning me 0 which means there's non.
:S any1 ?!
|
|
| Back to top |
|
 |
Anden100 Grandmaster Cheater
Reputation: 0
Joined: 20 Apr 2007 Posts: 668
|
Posted: Wed Jul 29, 2009 10:06 am Post subject: |
|
|
Not sure if this will help, but try to allocate some space for the character, or by making an array of wchar_t's, ex:
| Code: | | wchar_t lpwName[500]; |
|
|
| Back to top |
|
 |
smartz993 I post too much
Reputation: 2
Joined: 20 Jun 2006 Posts: 2013 Location: USA
|
Posted: Wed Jul 29, 2009 10:06 am Post subject: |
|
|
lpwName is a NULL pointer, no?
Allocate some memory for it.
|
|
| Back to top |
|
 |
Anden100 Grandmaster Cheater
Reputation: 0
Joined: 20 Apr 2007 Posts: 668
|
Posted: Wed Jul 29, 2009 10:09 am Post subject: |
|
|
| smartz993 wrote: | lpwName is a NULL pointer, no?
Allocate some memory for it. |
| Code: | | wchar_t lpwName = malloc(500); |
Not sure, but will that work?
|
|
| Back to top |
|
 |
Stylo Grandmaster Cheater Supreme
Reputation: 3
Joined: 16 May 2007 Posts: 1073 Location: Israel
|
Posted: Wed Jul 29, 2009 10:23 am Post subject: |
|
|
yeah it works perfectly
i guess i should have allocate some memory for it thx guys :]
|
|
| Back to top |
|
 |
TraxMate Master Cheater
Reputation: 0
Joined: 01 Mar 2008 Posts: 363
|
Posted: Wed Jul 29, 2009 10:26 am Post subject: |
|
|
| You need to allocate some memory for the string. A smart way is to first get the length of the string from the listbox so you know how much memory you need to allocate.
|
|
| Back to top |
|
 |
Stylo Grandmaster Cheater Supreme
Reputation: 3
Joined: 16 May 2007 Posts: 1073 Location: Israel
|
Posted: Wed Jul 29, 2009 10:29 am Post subject: |
|
|
sounds nice i like it :]
works great thanks
|
|
| Back to top |
|
 |
&Vage Grandmaster Cheater Supreme
Reputation: 0
Joined: 25 Jul 2008 Posts: 1053
|
Posted: Wed Jul 29, 2009 5:28 pm Post subject: |
|
|
| 1qaz wrote: | sounds nice i like it :]
works great thanks |
Don't forget to free(); after your done when using malloc ;3
|
|
| Back to top |
|
 |
|