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++ help] Getting selected item in a list box

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

Joined: 24 Jul 2008
Posts: 560
Location: California

PostPosted: Sun Feb 15, 2009 6:06 pm    Post subject: [C++ help] Getting selected item in a list box Reply with quote

I hate to admit it, but I have no idea how to do this. Does anyone know how to get the text of the selected item in a listbox?

Edit: I made my own window, not using MFC, etc.
Back to top
View user's profile Send private message Visit poster's website
manc
Grandmaster Cheater
Reputation: 1

Joined: 16 Jun 2006
Posts: 551

PostPosted: Sun Feb 15, 2009 6:17 pm    Post subject: Reply with quote

I dont know myself but it sounds like while creating the listbox there should be a parameter or value somewhere that you can call to retrieve it.

Otherwise i'd try google and wait for the pro's to enter Laughing

_________________
Back to top
View user's profile Send private message
AlbanainRetard
Master Cheater
Reputation: 0

Joined: 02 Nov 2008
Posts: 494
Location: Canada eh?

PostPosted: Sun Feb 15, 2009 6:20 pm    Post subject: Reply with quote

Dialog = GetDlgItemText();

Try : SendMessage();

_________________
Back to top
View user's profile Send private message Send e-mail
talkerzero
Grandmaster Cheater
Reputation: 1

Joined: 24 Jul 2008
Posts: 560
Location: California

PostPosted: Sun Feb 15, 2009 6:24 pm    Post subject: Reply with quote

Tried GetDlgItemText and SendMessage already. I have already tried LB_GETTEXT, LB_GETSELTEXT, etc. Can't get it working, the buffer I store it in always returns a bizarre string, the same one no matter which item I select. Weird.
Back to top
View user's profile Send private message Visit poster's website
TraxMate
Master Cheater
Reputation: 0

Joined: 01 Mar 2008
Posts: 363

PostPosted: Sun Feb 15, 2009 6:44 pm    Post subject: Reply with quote

Search for the text string using LB_FINDSTRING, it will return the position of the item.

EDIT: Didn't see you wanted to get the the text from it.. Thought you wanted to get position of the item :p. Anyways to get the text you can use LB_GETTEXT
Quote:

wchar_t Buf[256];
SendDlgItemMessage(hWnd, IDC_LISTBOX, LB_GETTEXT, Position, (LPARAM)Buf);


Last edited by TraxMate on Sun Feb 15, 2009 6:53 pm; edited 1 time in total
Back to top
View user's profile Send private message
slippppppppp
Grandmaster Cheater
Reputation: 0

Joined: 08 Aug 2006
Posts: 929

PostPosted: Sun Feb 15, 2009 6:48 pm    Post subject: Reply with quote

Use a listview, it's easier Sad
Back to top
View user's profile Send private message AIM Address MSN Messenger
talkerzero
Grandmaster Cheater
Reputation: 1

Joined: 24 Jul 2008
Posts: 560
Location: California

PostPosted: Sun Feb 15, 2009 6:59 pm    Post subject: Reply with quote

No no no, you're getting me wrong Trax. What I want is to get the text of the selected item. In my list, suppose I have "A", "B", and "C". I want to check to see which one has been selected by the user.
Back to top
View user's profile Send private message Visit poster's website
TraxMate
Master Cheater
Reputation: 0

Joined: 01 Mar 2008
Posts: 363

PostPosted: Sun Feb 15, 2009 7:15 pm    Post subject: Reply with quote

To get the selected item in the list you use LB_GETCURSEL and to get the text of the item you use LB_GETTEXT.
Back to top
View user's profile Send private message
AlbanainRetard
Master Cheater
Reputation: 0

Joined: 02 Nov 2008
Posts: 494
Location: Canada eh?

PostPosted: Sun Feb 15, 2009 7:41 pm    Post subject: Reply with quote

Oh i had same error with my dll, make the string you select smaller like with send message like test.
_________________
Back to top
View user's profile Send private message Send e-mail
talkerzero
Grandmaster Cheater
Reputation: 1

Joined: 24 Jul 2008
Posts: 560
Location: California

PostPosted: Sun Feb 15, 2009 10:09 pm    Post subject: Reply with quote

Figured it out. Here's how I did it, as a reference for the rest of the community:

Code:
char buf[33];
int selPos = SendMessage(GetDlgItem(hWnd, IDC_LIST1), LB_GETCURSEL, 0, 0);
SendMessage(GetDlgItem(hWnd, IDC_LIST1), LB_GETTEXT, selPos, buf);


The text of the selected item should now be stored in buf.
Back to top
View user's profile Send private message Visit poster's website
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