Cheat Engine Forum Index Cheat Engine
The Official Site of Cheat Engine
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 


[C++] gets the text from specific index at listbox

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming
View previous topic :: View next topic  
Author Message
Stylo
Grandmaster Cheater Supreme
Reputation: 3

Joined: 16 May 2007
Posts: 1073
Location: Israel

PostPosted: Wed Jul 29, 2009 9:55 am    Post subject: [C++] gets the text from specific index at listbox Reply with quote

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
View user's profile Send private message
Anden100
Grandmaster Cheater
Reputation: 0

Joined: 20 Apr 2007
Posts: 668

PostPosted: Wed Jul 29, 2009 10:06 am    Post subject: Reply with quote

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
View user's profile Send private message
smartz993
I post too much
Reputation: 2

Joined: 20 Jun 2006
Posts: 2013
Location: USA

PostPosted: Wed Jul 29, 2009 10:06 am    Post subject: Reply with quote

lpwName is a NULL pointer, no?

Allocate some memory for it.
Back to top
View user's profile Send private message
Anden100
Grandmaster Cheater
Reputation: 0

Joined: 20 Apr 2007
Posts: 668

PostPosted: Wed Jul 29, 2009 10:09 am    Post subject: Reply with quote

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
View user's profile Send private message
Stylo
Grandmaster Cheater Supreme
Reputation: 3

Joined: 16 May 2007
Posts: 1073
Location: Israel

PostPosted: Wed Jul 29, 2009 10:23 am    Post subject: Reply with quote

yeah it works perfectly
i guess i should have allocate some memory for it thx guys :]
Back to top
View user's profile Send private message
TraxMate
Master Cheater
Reputation: 0

Joined: 01 Mar 2008
Posts: 363

PostPosted: Wed Jul 29, 2009 10:26 am    Post subject: Reply with quote

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
View user's profile Send private message
Stylo
Grandmaster Cheater Supreme
Reputation: 3

Joined: 16 May 2007
Posts: 1073
Location: Israel

PostPosted: Wed Jul 29, 2009 10:29 am    Post subject: Reply with quote

sounds nice i like it :]
works great thanks
Back to top
View user's profile Send private message
&Vage
Grandmaster Cheater Supreme
Reputation: 0

Joined: 25 Jul 2008
Posts: 1053

PostPosted: Wed Jul 29, 2009 5:28 pm    Post subject: Reply with quote

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
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group

CE Wiki   IRC (#CEF)   Twitter
Third party websites