Page 1 of 1

Maximum number of gadgets

Posted: Tue Jul 25, 2006 12:23 pm
by neuronic
Hi

I am working on a small application and I would like to use lots of gadgets. Is there any way I can use more gadgets then 10.000? If i create a lot I get the message: #Gadget object number is very high (over 10.000).

Any ideas?????

Neuronic

Re: Maximum number of gadgets

Posted: Tue Jul 25, 2006 12:37 pm
by Phoenix
How can a small application have more than 10000 gadgets????

Posted: Tue Jul 25, 2006 12:50 pm
by Dreglor
I believe that is only a warning from the debugger you can still continue execution.

I'm not sure but i think the real limit is 65000

Re: Maximum number of gadgets

Posted: Tue Jul 25, 2006 12:55 pm
by oldBear
Phoenix wrote:How can a small application have more than 10000 gadgets????
He probably doesn't. He's may be referrring to a gadget by an improper id for the gadget in question.

I thought the message was 100,000 not 10,000 but my references to it may have been something other than on a gadget.

cheers

Posted: Tue Jul 25, 2006 1:26 pm
by Jan Vooijs
For files it is a 1000, had that exception yesterday try-ing to open a file with the number 1005, so why not for gadgets?

Jan V.

Posted: Tue Jul 25, 2006 2:09 pm
by neuronic
Hi again

I would really like to have that many gadgets. It is not a wrong id number or anything similar. The application is a simple map editor, where i need ImageGadgets depending on the size of the map.

If I turn the debugger off the execution goes on, but there are no more gadgets created.

Off course I can use a different method, where i don't need thousands of gadgets, but using this is the easiest way.

Bye
Neuronic

Posted: Tue Jul 25, 2006 3:00 pm
by ts-soft
Without #PB_Any you can create only 10000 Gadgets.
Use #PB_Any, you can create Gadgets with max from OS

Posted: Tue Jul 25, 2006 3:31 pm
by netmaestro
I almost replied with ts-soft's answer, as I believed it to work like that. It does work like that with windows as opposed to gadgets. But I ran a little test and it seems like there is an upper limit of 9999 for gadgets:

Code: Select all

Dim gadgets(100000)
OpenWindow(0,0,0,800,600,"")
CreateGadgetList(WindowID(0))
CreateImage(0,1,1)
gadgetcount = 1
gadgets(gadgetcount) = ImageGadget(#PB_Any, Random(799),Random(599),1,1,ImageID(0))
While IsGadget(gadgets(gadgetcount)) <> 0
  gadgetcount+1
  gadgets(gadgetcount) = ImageGadget(#PB_Any, Random(799),Random(599),1,1,ImageID(0))
Wend
Debug "Number of gadgets created: "+Str(gadgetcount)
Repeat:Until WaitWindowEvent()=#WM_CLOSE
See what result you get, but I can't ever get more than 9999 successful gadget creations.

Posted: Tue Jul 25, 2006 4:23 pm
by ts-soft
You can Create Gadget from 0 to 9999 and Window from 0 to 4999 with
Constants! More only with #PB_Any

Posted: Wed Jul 26, 2006 3:45 pm
by Demivec
netmaestro wrote:See what result you get, but I can't ever get more than 9999 successful gadget creations.
I modified your sample code to create 9000 gadgets with constants 1-9000 and then create as many additional ones as were possible with #PB_Any. I still only came to 9999 total. So it seems that combinations of constant numbering and #PB_Any doesn't seem to increase the total possible.


Demivec

Posted: Wed Jul 26, 2006 3:59 pm
by Konne
I would say If u have 10000 Gadgets ure program will be so slow that u want to look for anoothert possiblility. In U#re case i would use an openscreen (also faster)

Posted: Wed Jul 26, 2006 4:42 pm
by Fred
It's probably a Windows limitation, as each control is an handle and 10 000 handle for only one application is way too much. Somebody can do a loop of CreateWindowEx() to see if it's reproducible with API only ?

BTW, the debugger warning about the maximum reached is just a warning, it doesn't prevent the creation.

Posted: Wed Jul 26, 2006 4:58 pm
by netmaestro
Good idea, Fred:

Code: Select all

hwnd=OpenWindow(0,0,0,320,240,"")
Repeat
  MyText=CreateWindowEx_(#WS_EX_LEFT,"Static","",#WS_CHILD|#SS_CENTER,0,100,200,20,hwnd,0,GetModuleHandle_(0),0) 
  cc+1
Until mytext=0
Debug cc
This code is debugging 9999 here. I vote for Windows limitation :wink:

[edit] The max# of open windows seems to be 10000, as if I remove the OpenWindow() from the above snip and take out the #WS_CHILD style, it dies at 10000 instead of 9999.