Handle

Got an idea for enhancing PureBasic? New command(s) you'd like to see?
GPI
PureBasic Expert
PureBasic Expert
Posts: 1394
Joined: Fri Apr 25, 2003 6:41 pm

Handle

Post by GPI »

It would be usefull, when PB also can give a handle when i, for example, i window open. More likes API.

At the moment i must give the window a number and then i can open it.

But when this is changed, all the olders Programms will not run any more.

So my idea:

GetFreeWindowNr()
GetFreeImageNr()
GetFreeSpriteNr()
GetFreeMemoryNr()

and so on.

So can i get a free nr and can with this a window open. This is very usefull, when a not clearly definted numbers of memoryblocks are reserved. Also when i want to my own included procedures (for winamp-support, for freeimage-support, etc, my standardprocedures, that i use nearly always) it is easier to add, because this included files can automatic search a free number.

Also this should than included.

ReserveMemoryNrUntil(X)

After
ReserveMemoryNrUntil(100)

GetFreeMemoryNr() will start the search for a free NR with 101.


Also a better DLL-Support would be nice. A command, that the dll will allow, that the dll can use the, for example, the imagenr of the main-programms.

example:
main

Code: Select all

  openlibrary(1,mylib)
  sharePBElementsWithDLL(1)
  LoadImage(1,"test.bmp)
  
  CallFunction(1, "test") 
dll

Code: Select all

sharePBElementsWithMain()
proceduredll test()
  resizeimage(1,20,20)
endprocedure
Also a DeclareDLL would be nice, so a function of a DLL can be used as a normal function.

Example:
In the dll are this function
test(w1,w2,w3)

Code: Select all

  openlibrary(1,"Test.dll")
  declareDLL 1,test(w1,w2,w3)

  test(1,2,3)
GPI
Fred
Administrator
Administrator
Posts: 18162
Joined: Fri May 17, 2002 4:39 pm
Location: France
Contact:

Post by Fred »

I'm on it since a while and it should be available for a few library for the next version and will be extended to all libraries in a future. It will work the following scheme (if you have a better tough, tell me):

Code: Select all

DynamicNumber = OpenWindow(#PB_Any, 0, 0, ...)
So it's no more a window handle, but the new number dynamically allocated. It can not clash with regular number, so you can freely mix the both, depending of your need. You can of course get the window handle with WindowID(). So such code are possible:

Code: Select all

OpenWindow(1, 100, 100...
Child1 = OpenWindow(#PB_Any, 2, 2, ...
El_Choni
TailBite Expert
TailBite Expert
Posts: 1007
Joined: Fri Apr 25, 2003 6:09 pm
Location: Spain

Post by El_Choni »

I undesrtand that if you don't use #PB_Any, behaviour will be the 'traditional' one, won't it? That is, will OpenWindow return the window handle in any other cases? (please X)
El_Choni
Fred
Administrator
Administrator
Posts: 18162
Joined: Fri May 17, 2002 4:39 pm
Location: France
Contact:

Post by Fred »

Yes, of course.
GPI
PureBasic Expert
PureBasic Expert
Posts: 1394
Joined: Fri Apr 25, 2003 6:41 pm

Post by GPI »

Fred wrote:Yes, of course.
Sounds good. I have think a little bit about it. How to prevent, that there is no conflict with the given nr (with #PB_Any) and a manual number. When the given nr are always negativ, there should be no problem...

Ok, what about DeclareDLL?
Amiga5k
Enthusiast
Enthusiast
Posts: 329
Joined: Fri Apr 25, 2003 8:57 pm

Post by Amiga5k »

It would be nice only to have to keep track of an ID *or* a number instead of both, yes? :D I'm used to the current approach, but it did take a little getting used to...

Russell

p.s. If the new way is implemented, I think it would be great if we make it optional, as to not break old code. #PB_Any is the best way, I think. :D

Russell
*** Diapers and politicians need to be changed...for the same reason! ***
*** Make every vote equal: Abolish the Electoral College ***
*** www.au.org ***
Post Reply