Newbe Q Giant IdNumbers

Just starting out? Need help? Post your questions and find answers here.
SiggeSvahn
User
User
Posts: 40
Joined: Wed Oct 06, 2010 9:37 pm

Newbe Q Giant IdNumbers

Post by SiggeSvahn »

Hi Forum!
Appologises for this newbe question:

I need to create windows and gadgets dynamically. Why am I getting giant ID-numbers? Shouldn't they start on, like, zero or something and then increase by one at a time?

If I keep on creating a few gadgets PB throws a warning: "Do you really want to use this big gadget number!".

Using PB ver. 4.51 and WinXP.
I have restarted my computer, running "no" other apps in the background.

Code: Select all

EnableExplicit

Debug OpenWindow(#PB_Any, 0, 0, 99, 99, "Test Dynamic WindowNumber")

;"Why am I getting such a high window_number 3.943.872 ?"

End
Newbie
cas
Enthusiast
Enthusiast
Posts: 597
Joined: Mon Nov 03, 2008 9:56 pm

Re: Newbe Q Giant IdNumbers

Post by cas »

It is fine to get these numbers when you use #PB_Any.
Problem is only when you use big constant instead of #PB_Any:

Code: Select all

#WINDOW_1=9999
OpenWindow(#WINDOW_1, 0, 0, 99, 99, "")
SiggeSvahn
User
User
Posts: 40
Joined: Wed Oct 06, 2010 9:37 pm

Re: Newbe Q Giant IdNumbers

Post by SiggeSvahn »

Thanks for fast answer. I will try to duplicate my original code later cause now I have stuck to manual handling the dynamic "handles" by a ctr.
Newbie
Trond
Always Here
Always Here
Posts: 7446
Joined: Mon Sep 22, 2003 6:45 pm
Location: Norway

Re: Newbe Q Giant IdNumbers

Post by Trond »

The dynamic numbers are very big to prevent them from clashing with the static numbers.

So if you do this it will work perfectly:

Code: Select all

ButtonGadget(0, ....)
ButtonGadget(1, ....)
StringGadget(#PB_Any, ...)
StringGadget(2, ...) ; <- Notice that this does not clash with the other string gadget, because #PB_Any selected a huge number.
Be aware that you can't re-use dynamic numbers, but you can re-use static numbers:

Code: Select all

CreateImage(12, ....)
CreateImage(12, ....) ; Frees the old image #12 and creates a new one

i = CreateImage(#PB_Any, ....)
; CreateImage(i, ...) ; <- RE-USE OF DYNAMIC NUMBER NOT ALLOWED
; Do this:
FreeImage(i)
i = CreateImage(#PB_Any, ....)
IdeasVacuum
Always Here
Always Here
Posts: 6426
Joined: Fri Oct 23, 2009 2:33 am
Location: Wales, UK
Contact:

Re: Newbe Q Giant IdNumbers

Post by IdeasVacuum »

I suggest that your dynamic code also defines the Gadget IDs rather than using PB_Any.
IdeasVacuum
If it sounds simple, you have not grasped the complexity.
SiggeSvahn
User
User
Posts: 40
Joined: Wed Oct 06, 2010 9:37 pm

Re: Newbe Q Giant IdNumbers

Post by SiggeSvahn »

Thanks all! Trond had the solution. I must have tried to re-use some dynamic handle numbers. Thanks to you guys i did dare to rewrite the rather big code and it is now working. Lesson learned - don't try to create (re-create) gadgets with already used handle numbers which was created by #PB_Any.
Newbie
Post Reply