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 » Mon Nov 22, 2010 10:27 pm

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 79 times

AUser
Knows some wx things
Knows some wx things
Posts: 38
Joined: Mon Jun 26, 2006 12:18 am

Post by AUser » Mon Nov 22, 2010 10:49 pm

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 » Mon Nov 22, 2010 10:57 pm

Nope.. my bad... That doesnt fix it

User avatar
doublemax
Moderator
Moderator
Posts: 15655
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Post by doublemax » Mon Nov 22, 2010 11:19 pm

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 » Mon Nov 22, 2010 11:23 pm

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: 15655
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Post by doublemax » Mon Nov 22, 2010 11:34 pm

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

Post Reply