Hide Gadget on load

BlitzPlus Forums/BlitzPlus Programming/Hide Gadget on load

mattm591(Posted 2007) [#1]
Hi,
I have an application which at current uses two windows. One for the main app, the second for an options window. The options window is style 17.

When the app loads I load the two windows so it doesn't come up with Invalid gadget errors later.

The problem is despite putting HideGadget optwin directly below the line creating the options window it still is shown upon loading the application and is quite irritating.

How can I hide the gadget prior to making it, or make it never come up. I'd even settle with covering it up. But I can't find any solution.

Any help appreciated!

Thanks,
Matt


Kev(Posted 2007) [#2]
one possable way would be to add a function to check if the windows handle is valid before adding gadgets check its valid if not then create it. dont create it until its needed. ie the user selects options.

kev


CS_TBL(Posted 2007) [#3]
create the window above the screen?

window=CreateWindow("bla",0,-480,660,480)


mattm591(Posted 2007) [#4]
Thanks both of you. CS_TBL, great idea never thought of anything as simple as that! Cheers, works great.

It has however given me a different problem now.

I made this function

Function CenterWindow(gadget,width,height,wtype)

x=(ClientWidth(wtype)-width)/2

y=(ClientWidth(wtype)-height)/2

Return SetGadgetShape(gadget,x,y,width,height)

End Function

and it says "Illegal type conversion" when I try to use it. Why is that?
Thanks


CS_TBL(Posted 2007) [#5]
clientwidth(gadget) and clientheight(gadget) perhaps? :P


mattm591(Posted 2007) [#6]
Nope same problem :( I was using the extra wtype variable so it could be centred either relative to another gadget or to Desktop()


CS_TBL(Posted 2007) [#7]
So, what you want is a function that centralizes any window?


mattm591(Posted 2007) [#8]
Yes, but not create the window. Move an already made window so it is centered.


CS_TBL(Posted 2007) [#9]
I haven't tested this one, no B+ here on my notebook, and I'm remote atm. So, let me know whether it works or not.. :P

Function CenterWindow(window)
    If Not window Return

    dw=ClientWidth(Desktop())
    dh=ClientHeight(Desktop())

    ww=ClientWidth(window)
    wh=ClientHeight(window)

    x=(dw/2)-(ww/2)
    y=(dh/2)-(wh/2)
    
    If x<0 x=0
    If y<0 y=0

    SetGadgetshape window,x,y,ww,wh

End Function



mattm591(Posted 2007) [#10]
Thanks a lot that works great! :D

I have an unrelated problem which maybe you could help me with instead of me starting a new topic.

I have a set of labels and check box buttons at the top of the main window which show fine so long as the window is of a certain size, but once it starts to shrink although they don't move out of place (which is good) they also don't jump to the next line if they will no longer fit on.

Here is an example of one

C0day=CreateButton("",GadgetX(Lanime)+GadgetWidth(Lanime)+10,10,15,15,mainwindow,2)

SetGadgetLayout(C0day,1,0,1,0)

L0day=CreateLabel("Apps/0DAY",GadgetX(C0day)+GadgetWidth(C0day),10,StringWidth("Apps/0DAY"),F1height,mainwindow)

SetGadgetLayout(L0day,1,0,1,0)


I don't really understand exactly how your supposed to get items to move nicely when windows are resized in B+ so any light you can shed on this matter will be very much appreciated!
Thanks


CS_TBL(Posted 2007) [#11]
uh.. hold it, just checking, you mean like:

+----------------------+v+
+----------------------+^+
|[ ][ ][ ][ ][ ][ ][ ][ ]|
|                        |
|                        |
|                        |
|                        |
+------------------------+

+----------+v+
+----------+^+
|[ ][ ][ ][ ]|
|[ ][ ][ ][ ]|
|            |
|            |
|            |
|            |
+------------+


where [ ] is a button, label etc.
?


mattm591(Posted 2007) [#12]
Exactly right


CS_TBL(Posted 2007) [#13]
Rite, well, it's not difficult, just a matter of relocating gadgets based on their combined width in relation to the width of the window's clientwidth, while keeping an x and y var to remember where the next gadget is to be relocated. I don't have B+ at hand here, only Maxgui. So I'm not really able to make an example or even a handy function/system right now.


mattm591(Posted 2007) [#14]
I had thought of something like that, but if the labels and boxes are generated and then the user resizes the window after it doesn't seem to reshape them.


CS_TBL(Posted 2007) [#15]
There is an event which is fired when the user changes the windowsize. If this event occurs the user -you- changes all these labels etc. It's prolly some $80x number, look it up in the manual.


mattm591(Posted 2007) [#16]
Yeah I have that, the only thing is this seems like an incredibly complicated method!!! I have about 20 labels so it would have to check that each one is fitting in, if not move it and then if the previous one has moved then it will need to move all the recurring ones and then check to see if they need to go on a third line etc. Is there no simpler way to do it?


CS_TBL(Posted 2007) [#17]
Not that *I* know. But consider this: if you want to code this in a one-shot way, then it might appear to be complicated and/or messy. What you want to do is to make a uniform function that manages a strip o' thingies like this. Code it once and grab the fruits forever. I can recommend banks for this.. tho I'm prolly the only one to do so.. :P


mattm591(Posted 2007) [#18]
Ok, it seems I'm gonna have to learn some more advanced stuff. This is far more complicated than I expected :P Thanks for your help. Quick (further) question. I presume this would require some extra dll or something, but do you know of anywhere that I can find a way to get BlitzPlus apps to minimize to the system tray.


CS_TBL(Posted 2007) [#19]
No, but that's mainly because it never interested me. Try the search function of the forum, I've seen similar requests before.


mattm591(Posted 2007) [#20]
Alright, thanks for all your help.


TAS(Posted 2010) [#21]
The screen isn't cleaned up until until you give control back to Windows

Two easy solutions
After you create the window want to hide add a Waitevent(1)

or if the hidden window is inside the main window do a cls, flipcanvas


Gladclef - Ben B(Posted 2010) [#22]
Quick (further) question. I presume this would require some extra dll or something, but do you know of anywhere that I can find a way to get BlitzPlus apps to minimize to the system tray.

There's already a dll created for this by gman, here:
http://www.blitzbasic.com/codearcs/codearcs.php?code=1140

It's called ggtray. Works really great.


Heliotrope(Posted 2010) [#23]
have you used ENDGRAPHICS.


Stamm(Posted 2010) [#24]
btw when window is resized EventX() and EventY() contain new width/height of window