Disable only the "Up" button of a spin button ... Topic is solved

If you are using the main C++ distribution of wxWidgets, Feel free to ask any question related to wxWidgets development here. This means questions regarding to C++ and wxWidgets, not compile problems.
Post Reply
Marco
Experienced Solver
Experienced Solver
Posts: 65
Joined: Wed Aug 17, 2005 2:25 pm
Location: Rennes, France

Disable only the "Up" button of a spin button ...

Post by Marco » Fri Aug 19, 2005 12:20 pm

Hi everybody,

How can I disable only the "Up" or the "Down" button of a Spin Button ??? I try to use the Enable(false) or Disable functions but they disable the entire Spin Button ...

Thank you in advance,

Marco

ssigala
Earned some good credits
Earned some good credits
Posts: 109
Joined: Fri Sep 03, 2004 9:30 am
Location: Brescia, Italy

Post by ssigala » Fri Aug 19, 2005 12:27 pm

Why would you like to do it? Perhaps you should instead change the spin button range with the wxSpinButton::SetRange() method.
Sandro Sigala - Kynosoft, Brescia

Marco
Experienced Solver
Experienced Solver
Posts: 65
Joined: Wed Aug 17, 2005 2:25 pm
Location: Rennes, France

Post by Marco » Fri Aug 19, 2005 12:35 pm

Hi ssigala,

Thank you to your prompt answer !!!

I use the Spin Button to move up or to move down items in a ListCtrl ... When the first item is selected, I want the "Up" button to be disable and even for the last item with the "Down" button of the Spin Button. But when others are selected the "Up" and "Down" buttons are both enable. That's why I want to disable the "Up" button or the "Down" button sometimes ...

Can you please help me ???

Thank you,

Marco

upCASE
Site Admin
Site Admin
Posts: 3176
Joined: Mon Aug 30, 2004 6:55 am
Location: Germany, Cologne

Post by upCASE » Fri Aug 19, 2005 12:41 pm

There is no possible way of doing so (at least not on windows).
You can, however, enable or disable only the buttons by overriding wxSpinCtrl::Enable() and make it only disable the buttons (just calling wxControl::Enable()).
On Windows, the up/down arrows are a control itself and I didn't find a way to send a message to only one of the buttons yet.
OS: OpenSuSE, Ubuntu, Win XP Pro
wx: svn
Compiler: gcc 4.5.1, VC 2008, eVC 4

"If it was hard to write it should be hard to read..." - the unknown coder
"Try not! Do. Or do not. There is no try." - Yoda

ssigala
Earned some good credits
Earned some good credits
Posts: 109
Joined: Fri Sep 03, 2004 9:30 am
Location: Brescia, Italy

Post by ssigala » Fri Aug 19, 2005 12:43 pm

This is a rough solution:

Suppose you have 15 items in your listbox.

First of all, set the range of the spinbox with SetRange(0,14).

Catch the "item changed" event of the listbox, and in the event code call
spinbox->SetValue(listbox->GetSelection());

Catch the "value changed" event of the spinbox, and in the event code call
listbox->SetSelection(spinbox->GetValue());

When the spinbox value gets changed into 0 or 14, the up down buttons are automatically disabled.
Sandro Sigala - Kynosoft, Brescia

Marco
Experienced Solver
Experienced Solver
Posts: 65
Joined: Wed Aug 17, 2005 2:25 pm
Location: Rennes, France

Post by Marco » Fri Aug 19, 2005 12:50 pm

OK, thank you for your answers ...

I will let the Spin Button "as is" ...

Marco

lowjoel
Moderator
Moderator
Posts: 1511
Joined: Sun Jun 19, 2005 11:37 am
Location: Singapore
Contact:

Post by lowjoel » Fri Aug 19, 2005 12:55 pm

if you like spin button, go ahead and use it.

I decided to use wxBitmapButton for it instead. See it in action in my education suite which is HEAVILY in devlopment still http://classtools.joelsplace.sg/downloadbeta.php at the moment its just a buch of maths functions and some student academic performance tracker thing.

im implementing the SQLite interface to it first before i go on anywherer else... my data storage way currently stinks.... very crash prone etc...

Muskelkatermann
Earned some good credits
Earned some good credits
Posts: 135
Joined: Thu Apr 28, 2005 11:36 am
Location: Gie

Post by Muskelkatermann » Fri Aug 19, 2005 1:12 pm

Hi Marco,

i think I have a nice solution for you!

What about Drag and Drop control in your ListCtrl, like Winamp has or the Windows Media Player has.

I've written the Methods for this about 6 Months ago.

Write me an E-Mail if you want them, i'll search out source for you,

greetins

Post Reply