SetSelection(wxNOT_FOUND) not working under windows? Topic is solved

Do you have a typical platform dependent issue you're battling with ? Ask it here. Make sure you mention your platform, compiler, and wxWidgets version.
Post Reply
AUser
Knows some wx things
Knows some wx things
Posts: 38
Joined: Mon Jun 26, 2006 12:18 am

SetSelection(wxNOT_FOUND) not working under windows?

Post by AUser »

Hi,

I have recently found that I cannot get wxListBox-es to clear their selection. I have attached an example program demonstrating this problem (bug?).


The code is being compiled by wx2.8.11 using tdm-gcc32, windows 7

$ wx-config --cflags
-I/usr/local/lib/wx/include/msw-unicode-release-2.8 -I/usr/local/include/wx-2.8 -DWXUSINGDLL -D__WXMSW__ -mthreads
$ wx-config --version
2.8.11

To reproduce bug:

Compile:
$ g++ *cpp `wx-config --cflags --libs`
Run:
$./a.exe

then click File->About.

Then note that the item is selected, where I have set the selection to wxNOT_FOUND. According to the docs, this is supposed to

"Sets the selection to the given item n or removes the selection entirely if n == wxNOT_FOUND."

Does anyone have any work-arounds? Appending items seems to always append them in the selected state.

The code works fine under GTK and mac OSX..

Thanks,
Attachments
hworld.cpp
(1.73 KiB) Downloaded 120 times
AUser
Knows some wx things
Knows some wx things
Posts: 38
Joined: Mon Jun 26, 2006 12:18 am

Post by AUser »

I had a thought... Its a 32 bit binary on a 64 bit system. I looked through the wx code, and it is using SendMessage(...) for CB_SETCURSEL : does this need to be a 64 bit -1, or a 32 bit -1?

http://msdn.microsoft.com/en-us/library ... S.85).aspx
AUser
Knows some wx things
Knows some wx things
Posts: 38
Joined: Mon Jun 26, 2006 12:18 am

Post by AUser »

Nope.. my bad... That doesnt fix it
User avatar
doublemax
Moderator
Moderator
Posts: 19158
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Post by doublemax »

I think that's a bug. I tested it with the "listbox" sample that comes with wxWidgets. If you create a multiple-selection listbox, select some items and click "Deselect all", it selects all items instead of deselecting them.

As a workaround, use SetSelection(-1, false)
Use the source, Luke!
AUser
Knows some wx things
Knows some wx things
Posts: 38
Joined: Mon Jun 26, 2006 12:18 am

Post by AUser »

Great, your workaround does indeed work around the problem. Have you reported this, or should i?

Thanks. This was really frustating!
User avatar
doublemax
Moderator
Moderator
Posts: 19158
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Post by doublemax »

I haven't reported it. Please do so if you have time.
Use the source, Luke!
Post Reply