gadget ID numbers

Share your advanced PureBasic knowledge/code with the community.
User avatar
waffle
Enthusiast
Enthusiast
Posts: 129
Joined: Mon May 12, 2003 1:34 pm
Location: USA
Contact:

gadget ID numbers

Post by waffle »

after trying everything to isolate a bug, i found out that i was using the same GadgetID number in two seperate windows. For some reason when i access the second window and then exit back to the main window, PB forgets that the gadget with the same ID exists in the first window and would no longer update it. It was a listicongadget while the second window was a text gadget. I thought each gadgetlist was unique to each window and did not think to worry much about each GadgetID.

just though I would help warn others about this potential problem with using the Visual Designer for generating constants for the gadgets.

Is this a bug or just a poorly executed great idea :?
I guess this goes back to my suggestion for manually setting constants in the visual editor.

or maybe a compiler warning about gadgets of the same ID :idea:
User avatar
tinman
PureBasic Expert
PureBasic Expert
Posts: 1102
Joined: Sat Apr 26, 2003 4:56 pm
Location: Level 5 of Robot Hell
Contact:

Re: gadget ID numbers

Post by tinman »

waffle wrote:second window was a text gadget. I thought each gadgetlist was unique to each window and did not think to worry much about each GadgetID.
I think the manual states that each gadget ID must be unique across all gadgets. And if it doesn't it should (something that I also got caught with before).
If you paint your butt blue and glue the hole shut you just themed your ass but lost the functionality.
(WinXPhSP3 PB5.20b14)
User avatar
waffle
Enthusiast
Enthusiast
Posts: 129
Joined: Mon May 12, 2003 1:34 pm
Location: USA
Contact:

Post by waffle »

so this one was my fault as i expected.....
but the visual design tool automatically assigned the ID numbers.
Lots of things could be done to prevent this...

1 - compiler warning for duplicate gadget ID
2 - compiler warning for reassign constant values
3 - Permit user assigned constants in the visual designer
so I could pick a starting number like 1000 for the first window,
2000 for the next and so on. Each gadget ID would then enumerate
starting with the Window ID +1

but hey, can't expect perfection on the first draft of any idea,
including my own projects :D
freak
PureBasic Team
PureBasic Team
Posts: 5941
Joined: Fri Apr 25, 2003 5:21 pm
Location: Germany

Post by freak »

1 - bad idea! It is a good feature. You can give all gadgets you never need
to change the same id (like textgadgets for example)

2 - also not a good idea (IMHO) This is good for creating enumerations of constants

Code: Select all

#Index = 1
#Const1 = #Index: #Index = #Index + 1
#Const2 = #Index: #Index = #Index + 1
#Const3 = #Index: #Index = #Index + 1
#Const4 = #Index: #Index = #Index + 1
#Const5 = #Index
3 - would be a good idea, but i recommend not stzarting at number 1000
for the first window, as PB reserves memory for items 0-999 as well.

btw: the Visual Designer supports multiple windows, so just create both your windows in one project, and you should not have a conatant problem
any more.

Timo
quidquid Latine dictum sit altum videtur
Berikco
Administrator
Administrator
Posts: 1326
Joined: Wed Apr 23, 2003 7:57 pm
Location: Belgium
Contact:

Re: gadget ID numbers

Post by Berikco »

waffle wrote:just though I would help warn others about this potential problem with using the Visual Designer for generating constants for the gadgets.
Fixed in today's release
A user in German forum gave me an exact discription of this problem.

http://users.pandora.be/berikco/download/vd.zip
Post Reply