Home » Community » Newbie corner » Problem using a switch control
Problem using a switch control [message #45589] |
Fri, 11 December 2015 09:04  |
Giorgio
Messages: 218 Registered: August 2015
|
Experienced Member |
|
|
Hi there,
I have a problem with a switch control. In an application, I have a window that helps user to select some data. User puts a code into a filed, hit a button, and the application shows - using a switch control - some lengths (just to give context: the code is a cable and the lengths are the ones available for that cable). After that the user can choose one of the lengths. The problem is that when user passes over the options of the switch control, they get highlighted as they were selected. I know this description may sound obscure, so I attach a video. In the video I click and select an option, then I pass over other options and finally I click randomly on some options.
Thanks for any help,
Gio
[Updated on: Sun, 13 December 2015 19:58] Report message to a moderator
|
|
|
|
Re: Problem using a switch control [message #45599 is a reply to message #45590] |
Mon, 14 December 2015 15:08   |
Giorgio
Messages: 218 Registered: August 2015
|
Experienced Member |
|
|
Hello Mirek,
thank you for your post. I have used the debugger and it seems switch cases have different values. In fact, the value is assigned during a loop with a variable that is incremented. Anyway, I created a very small test case, attached. Please note that the test case is very small, most of the space is the sqlite db. As my application uses a MySQL db, I have created a sqlite db: please note that I got rid of a lot of tables, so maybe the db and application look incoherent. To reproduce the problem, launch the application and click on the "Select job order" button. A dialog opens: put in the active field the following order id 15036120901 (maybe it works with other order ids, but I tested that one) and hit return. After that, click on a switch case and then pass the mouse over other cases (try different cases, sometimes it works with a particular case). The problem is in lines 51-85 (specifically, lines 62-77), but I cannot locate it.
Thank you for the support,
Gio
-
Attachment: SWPR.zip
(Size: 74.01KB, Downloaded 271 times)
|
|
|
Re: Problem using a switch control [message #45603 is a reply to message #45599] |
Mon, 14 December 2015 20:49   |
 |
mirek
Messages: 14255 Registered: November 2005
|
Ultimate Member |
|
|
Giorgio wrote on Mon, 14 December 2015 15:08Hello Mirek,
thank you for your post. I have used the debugger and it seems switch cases have different values. In fact, the value is assigned during a loop with a variable that is incremented. Anyway, I created a very small test case, attached. Please note that the test case is very small, most of the space is the sqlite db. As my application uses a MySQL db, I have created a sqlite db: please note that I got rid of a lot of tables, so maybe the db and application look incoherent. To reproduce the problem, launch the application and click on the "Select job order" button. A dialog opens: put in the active field the following order id 15036120901 (maybe it works with other order ids, but I tested that one) and hit return. After that, click on a switch case and then pass the mouse over other cases (try different cases, sometimes it works with a particular case). The problem is in lines 51-85 (specifically, lines 62-77), but I cannot locate it.
Thank you for the support,
Gio
for(int j = 0; j < n_of_drums; j++)
{
DDUMP(query[DRUM]);
dlgSelectDrums.lengthList.Set(i, AsString(query[DRUM]), ( AsString(query[METER]) + "m - N: " + AsString(k+1) + " of " + AsString(n_of_drums)));
query[DRUM] = 125
query[DRUM] = 125
query[DRUM] = 125
query[DRUM] = 140
query[DRUM] = 160
query[DRUM] = 160
...exactly what I have suspected...
|
|
|
|
|
Re: Problem using a switch control [message #45610 is a reply to message #45589] |
Tue, 15 December 2015 22:19   |
mr_ped
Messages: 826 Registered: November 2005 Location: Czech Republic - Praha
|
Experienced Contributor |
|
|
for(int j = 0; j < n_of_drums; j++)
{
DDUMP(query[DRUM]);
dlgSelectDrums.lengthList.Set(i, AsString(query[DRUM]), ( AsString(query[METER]) + "m - N: " + AsString(k+1) + " of " + AsString(n_of_drums)));
pardon my ignorance (and laziness to check the zip with full source), but is it ok the for has "j" and the Set takes "i" in first parameter?
Also when the key is "AsString(query[DRUM])", you may produce string like "i,query[DRUM]" for keys, and then extract the query[DRUM] by splitting the key with ',', if you insist to have that data encoded in key. Just an option, I would probably consider in PHP (where the thing is slow as hell already anyway, and writing str manipulation is easy too)... but in U++ I think having a vector with query[DRUM] values around and using pure "i" (or j?) is easier to write, read and maintain...
|
|
|
|
|
Re: Problem using a switch control [message #45615 is a reply to message #45610] |
Thu, 17 December 2015 10:11  |
 |
mirek
Messages: 14255 Registered: November 2005
|
Ultimate Member |
|
|
mr_ped wrote on Tue, 15 December 2015 22:19
for(int j = 0; j < n_of_drums; j++)
{
DDUMP(query[DRUM]);
dlgSelectDrums.lengthList.Set(i, AsString(query[DRUM]), ( AsString(query[METER]) + "m - N: " + AsString(k+1) + " of " + AsString(n_of_drums)));
pardon my ignorance (and laziness to check the zip with full source), but is it ok the for has "j" and the Set takes "i" in first parameter?
Also when the key is "AsString(query[DRUM])", you may produce string like "i,query[DRUM]" for keys, and then extract the query[DRUM] by splitting the key with ',', if you insist to have that data encoded in key. Just an option, I would probably consider in PHP (where the thing is slow as hell already anyway, and writing str manipulation is easy too)... but in U++ I think having a vector with query[DRUM] values around and using pure "i" (or j?) is easier to write, read and maintain...
Well you could also use MakeTuple....
|
|
|
Goto Forum:
Current Time: Sat Apr 26 14:52:13 CEST 2025
Total time taken to generate the page: 0.00833 seconds
|