Is there a way to increase the 10,000 gadget limit?
Is there a way to increase the 10,000 gadget limit?
Is there a way to increase the 10,000 gadget limit?
To explain: Its not that I have 10,000 actual gadgets, but I do have an application where I would like to use the gadget numbers sparsely to find the gadget that someone has clicked on. In the application I display a number of tabs with a scroll view containing a number of components. Each component is composed of 16 gadgets, I might have up to 16 components on a tab, I may have up to 32 tabs in the application.
This is working fine but it is running close to the 10,000 gadget limit.
The tabs are using 8192 potential gadget IDs without considering all the other gadgets that the application needs and without being able to expand the application very much.
In the event loop I use the gadget id number to locate the tab and the component that the user has just clicked on - this is the main reason I want to use specific numbers for the gadgets.
To explain: Its not that I have 10,000 actual gadgets, but I do have an application where I would like to use the gadget numbers sparsely to find the gadget that someone has clicked on. In the application I display a number of tabs with a scroll view containing a number of components. Each component is composed of 16 gadgets, I might have up to 16 components on a tab, I may have up to 32 tabs in the application.
This is working fine but it is running close to the 10,000 gadget limit.
The tabs are using 8192 potential gadget IDs without considering all the other gadgets that the application needs and without being able to expand the application very much.
In the event loop I use the gadget id number to locate the tab and the component that the user has just clicked on - this is the main reason I want to use specific numbers for the gadgets.
No it is a purebasic compiler limit
The purebasic compiler displays an error message when you use a gadgetID greater than 10,000.
To see it do this:-
The purebasic compiler displays an error message when you use a gadgetID greater than 10,000.
To see it do this:-
Code: Select all
;
If OpenWindow(0, 0, 0, 230, 90, "Event handling example...", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
If CreateGadgetList(WindowID(0))
ButtonGadget (10001, 10, 10, 200, 30, "Click me")
EndIf
Repeat
Event = WaitWindowEvent()
Until Event = #PB_Event_CloseWindow
EndIf
Thanks very much everyone for your help; that makes sense Freak, I assumed that the debugger warning was a fatal message when I encountered it in a real program that I was debugging, and I did some work to pair things down to fit into that limit.
I am using GadgetEvent() Sparkie its just that at the moment I get the x,y position (in my data) and the gadget number out of the gadget id that it returns. Now I know these IDs are using an array internally - I can gain some memory back by doing things another way.
I am using GadgetEvent() Sparkie its just that at the moment I get the x,y position (in my data) and the gadget number out of the gadget id that it returns. Now I know these IDs are using an array internally - I can gain some memory back by doing things another way.
The limit for such objects is 18.000 (per process)
http://msdn.microsoft.com/en-us/library ... S.85).aspx
http://msdn.microsoft.com/en-us/library ... S.85).aspx
How many, exactly?.freak wrote:The IDs are allocated in an array, so using them sparsely is a waste of memory.
It isn't the same thing 4 bytes (a pointer), or 1000 bytes (a fixed length structure), by every unused gadget.
I'm using gadgets from 1000 to 9999 and I like to know if I need to change my programs to reduce memory used.
EDIT:
Is this valid for the rest of objects?... as images, menus, shortcuts...
Yes, it's valid for images and other things as well.
PureBasic objects
Introduction
The purpose of this section is to describe the behaviour, creation, and handling of objects in PureBasic. For the demonstration, we will use the Image object, but the same logic applies to all other PureBasic objects. When creating an Image object, we can do it in two ways: indexed and dynamic.
I. Indexed numbering
The static, indexed way, allows you to reference an object by a predefined numeric value. The first available index number is 0 and subsequent indexes are allocated sequentially. This means that if you use the number 0 and then the number 1000, 1001 indexes will be allocated and 999 (from 1 to 999) will be unused, which is not an efficient way to use indexed objects. If you need a more flexible method, use the dynamic way of allocating objects, as described in section II. The indexed way offers several advantages:
- Easier handling, since no variables or arrays are required.
- 'Group' processing, without the need to use an intermediate array.
- Use the object in procedures without declaring anything in global (if using a constant or a number).
- An object that is associated with an index is automatically freed when re-using that index.
very clearfreak wrote:Its not that much actually. Currently every gadget takes up 32bytes, so if you start at 1000, you have 32k of unused memory.
Its the same for other object types. Every entry takes the space of a small data structure.

so it's recommend to use Enumeration /EndEnumeration or PB_Any i mean ?
What do you mean exactly ?? If I do something like this:freak wrote:The IDs are allocated in an array, so using them sparsely is a waste of memory.
Code: Select all
#ID_GADGET=2000
ButtonGadget(#ID_GADGET,9,9,33,33,"Button",#PB_Button_Toggle)
