Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » U++ Library support » U++ Widgets - General questions or Mixed problems » Help needed dealing with switch control
Help needed dealing with switch control [message #19879] Thu, 29 January 2009 16:58 Go to next message
kbyte is currently offline  kbyte
Messages: 87
Registered: July 2008
Member
Hi,
I need to put two switch controls (option boxes) in to a form and they must be grouped in order to select one and the other one must be automatically unselected. I need also how to set the true value on them and get value they have.
Is there any switch tutorial? Cant find information on that.

Many thanks

Alex
Re: Help needed dealing with switch control [message #19942 is a reply to message #19879] Wed, 04 February 2009 10:11 Go to previous messageGo to next message
mrjt is currently offline  mrjt
Messages: 705
Registered: March 2007
Location: London
Contributor
In case you still need help with this, I think this is the code you need:
CtrlLibTest::CtrlLibTest()
{
	CtrlLayout(*this, "Window title");

	switch1.Add(0, "One");
	switch1.Add(1, "Two");
	switch1.Add(2, "Three");
	switch1 <<= Null;

	switch2.Add(String("Letter A"), "A");
	switch2.Add(String("Letter B"), "B");
	switch2.Add(String("Letter C"), "C");
	switch2 <<= "Letter A";
	
	switch1 <<= THISBACK(OnSwitch1);
	switch2 <<= THISBACK(OnSwitch2);
}

void CtrlLibTest::OnSwitch1()
{
	switch2 <<= Null;
}

void CtrlLibTest::OnSwitch2()
{
	switch1 <<= Null;
}

If you were going to do this with more than two switches or quite often I'd create a SwitchGroup class that wasn't a Ctrl but handled the state of the switches for you.
Re: Help needed dealing with switch control [message #20017 is a reply to message #19879] Tue, 10 February 2009 10:23 Go to previous messageGo to next message
kbyte is currently offline  kbyte
Messages: 87
Registered: July 2008
Member
Sorry, but may be I didnt explain my problem:

I drawn a form in a lay file during design time. Please, see the jpeg attached.

During form initialization (run-time) I want to select the numerica switch button and clear (it is already) the alfanumerica switch button.

The second doublt is:
On visual basic and visual C we add (at design time) switch buttons and group them and they became mutual exclusive, this means when the user selects one all the others become unselected.

Does u++ has this automatic behaviour?

I am using this but it doesnt works:

void xxxdlg::OnSwitch1(void) //numerica
{
sw2<<NULL;
sw1<<1;
}

void xxxdlg::OnSwitch2(void) //alfanumerica
{
sw1<<NULL;
sw2<<1;
}



Many thanks

Alex
  • Attachment: option.JPG
    (Size: 8.25KB, Downloaded 209 times)

[Updated on: Tue, 10 February 2009 10:29]

Report message to a moderator

Re: Help needed dealing with switch control [message #20018 is a reply to message #20017] Tue, 10 February 2009 10:42 Go to previous messageGo to next message
cbpporter is currently offline  cbpporter
Messages: 1401
Registered: September 2007
Ultimate Contributor
I'm not sure I understand your problem, but it could be caused by the way U++ handles Switches.

The traditional way of doing things is that if you want 3 switches, you will place 3 widgets on you form, each corresponding to a single option. Of course, you need to deactivate options when users interacts with on of the switches that constitute a logical group, and since witting such code would be repetitive for this very common scenario, you would place all tree switches in a GroupControl which will handle selecting items and logical grouping for you.

In U++ on the other hand, If you need to have 3 options, you will only add one single Switch to your layout. Then you will call Add 3 times on that Switch. In U++ Switch is actually more like a GroupControl, an calling Add populates it with "traditional switch" widgets. Switch is a group control, and is not like Option, which constitutes a single check box, not a group.

This works well for single groups, but if you need multiple groups that act as a single logical group, you will have to use something like mrjt suggested.

Switch should be able to handle both horizontal and vertical layout (as seen in your screenshot).
Re: Help needed dealing with switch control [message #20019 is a reply to message #19879] Tue, 10 February 2009 11:02 Go to previous messageGo to next message
kbyte is currently offline  kbyte
Messages: 87
Registered: July 2008
Member
Great!

Switch behaves like a container of options boxes. Ok, understood now!

Thank you

Alex
Re: Help needed dealing with switch control [message #20101 is a reply to message #19879] Tue, 17 February 2009 16:18 Go to previous message
kbyte is currently offline  kbyte
Messages: 87
Registered: July 2008
Member
Cant find how to format horizontal and vertical layout on switch group.
Please,could you help me?

Sorry,i got it. It depends of the dimension


Alex

[Updated on: Tue, 17 February 2009 16:36]

Report message to a moderator

Previous Topic: EditString validation
Next Topic: Win32 / Linux layouts
Goto Forum:
  


Current Time: Tue Apr 16 13:47:04 CEST 2024

Total time taken to generate the page: 0.03764 seconds