Page 1 of 1
[Implemented] Remove CreateGadgetList()
Posted: Sat Jun 09, 2007 8:22 pm
by Trond
How about removing CreateGadgetList()? In the rare case you want to open a window without gadgets, does it matter if a few bytes are wasted?
And what about merging OpenGadgetList() and UseGadgetList()? They do basically the same except with gadgets and windows. Illogically one takes a PB number and the other one takes an ID. If both used the ID they could be merged into one function.
Re: Remove CreateGadgetList() and merge OpenGadgetList()
Posted: Sat Jun 09, 2007 9:44 pm
by codemaniac
Trond wrote:How about removing CreateGadgetList()? In the rare case you want to open a window without gadgets, does it matter if a few bytes are wasted?
I find that's a cool idea! Although it doesn't need much typing to write CreateGadgetList(), it's still quite annoying to do it for every window you want to have some Gadgets in it. In most other programming languages that I know, there is a similar function usually named InitWidget, etc..
Posted: Sat Jun 09, 2007 11:55 pm
by AND51
What sense does it make that CreateGadgetList() acceptss hWnd's only? You cannot create gadgets onto other windows, so it would be good, if CreateGadgetList() just accepts #WindowID's.
I tried to create gadgets onto other windows (not owned by my program, but it didn't worked.
(Sorry, if I'm wrong)
Posted: Sun Jun 10, 2007 2:50 am
by PB
> You cannot create gadgets onto other windows
Trond posted something here where he added a button to an external window:
http://www.purebasic.fr/english/viewtopic.php?t=13411
Also, I remember reading that CreateGadgetList can be used to create many
lists, not just one, so the user can select which list to use at any given time,
so I think that's why the command exists.
Posted: Sun Jun 10, 2007 3:55 am
by AND51
@ PB:
Sorry, didn't know that it's so easy:
Code: Select all
c=FindWindow_(0,"Calculator")
CreateGadgetList(c)
ButtonGadget(0,0,0,100,20,"test")
iirc, I tried the same, but I've failed...

Posted: Sun Jun 10, 2007 11:28 am
by Trond
AND51 wrote:@ PB:
Sorry, didn't know that it's so easy:
Code: Select all
c=FindWindow_(0,"Calculator")
CreateGadgetList(c)
ButtonGadget(0,0,0,100,20,"test")
iirc, I tried the same, but I've failed...

Because your program then ends and PB destroys the button before you can see it...
Posted: Sun Jun 10, 2007 11:35 am
by PB
> Because your program then ends and PB destroys the button
Ahhhhhhhhhhhhh!

So that's the reason! THANK YOU!

Posted: Sun Jun 10, 2007 1:47 pm
by netmaestro
You can't do that. You can't process the window messages for an unowned window. The best you could do is create a borderless window the size of the gadget and have it move with the target app, creating the illusion that you've put a gadget on it. There is a post from the team dealing with this:
http://www.purebasic.fr/english/viewtopic.php?t=7758
Re: Remove CreateGadgetList() and merge OpenGadgetList()
Posted: Sun Jun 17, 2007 4:33 am
by PB
> How about removing CreateGadgetList()? In the rare case you want to
> open a window without gadgets, does it matter if a few bytes are wasted?
I don't get it. If you're going to open a window without gadgets, then you
wouldn't need to call CreateGadgetList at all, so what's the problem here?
Isn't that like saying: remove DeleteFile because my app won't be deleting
any files?
Posted: Sun Jun 17, 2007 4:43 am
by netmaestro
I think it would be cleaner and less coding if every window you opened automatically came with a gadgetlist unless you passed the flag #PB_Window_NoGadgetList, which you'd only do infrequently. It would save typing the CreateGadgetlist(Windowid(0)) every time you open a window. But the command is still needed for API-created windows, so it can't really be retired.
Posted: Sun Jun 17, 2007 4:45 am
by PB
Good idea about a #PB_Window_NoGadgetList flag for OpenWindow!
Posted: Sun Jun 17, 2007 10:52 am
by Fred
The flag sounds like a good solution.