Author |
Topic: Show and hide window (Read 208 times) |
|
flotulopex
Junior Member
member is offline
Gender:
Posts: 94
|
|
Show and hide window
« Thread started on: Jun 24th, 2017, 10:00pm » |
|
Hi,
I'm having difficulties making a window (sidebar "Side") appear over a first one (background "Back").
I'm trying to display any background image and when my mouse almost touches the right screen edge, a blue "sidebar" will appear.
Unfortunately, it works only one time (the first time after the program is run); afterwards, it will display a white sidebar.
There might be a "simple way" to show and/or hide a window...or does it have to be open/closed every time it is used?
This is my code I simplified for this thread and it will not run with LB but it will with LBB(!).
Code:' TwoWindows.bas
NOMAINWIN
GRAPHICBOX #Main.GBx1,0,0,1920,1080
STYLEBITS #Main.GBx1,0,_WS_BORDER,0,0
GRAPHICBOX #Side.GBx1,0,0,200,1080
STYLEBITS #Side.GBx1,0,_WS_BORDER,0,0
[MAIN]
WindowWidth = 1920
WindowHeight = 1080
LOADBMP "Back", DefaultDir$ + "\" + "BACK.bmp" '1920x1080 bmp file
OPEN "BACK" FOR window_popup AS #Main
#Main "TRAPCLOSE [QuitMain]"
#Main.GBx1 "down"
#Main.GBx1 "drawbmp Back 0 0"
#Main.GBx1 "when leftButtonDown [MouseLeftButton]"
#Main.GBx1 "when mouseMove [MouseMove]"
WAIT
[QuitMain]
CLOSE #Main
END
[SIDE]
UpperLeftX = 1720
UpperLeftY = 0
WindowWidth = 200
WindowHeight = 1080
LOADBMP "Side", DefaultDir$ + "\" + "SIDE.bmp" '200x1080 bmp file
OPEN "SIDE" FOR window_popup AS #Side
#Side "TRAPCLOSE [QuitSide]"
#Side.GBx1 "down"
#Side.GBx1 "drawbmp Side 0 0"
WAIT
[QuitSide]
CLOSE #Side
WAIT
[MouseLeftButton]
IF (MouseX < 10 AND MouseY < 10) THEN GOTO [QuitMain] 'clic on top left = QUIT
WAIT
[MouseMove]
IF MouseX > 1900 THEN GOTO [SIDE] 'open "SIDE"
IF MouseX < 1720 THEN GOTO [QuitSide] 'close "SIDE"
WAIT
Any idea what I'm doing wrong?
|
« Last Edit: Jun 24th, 2017, 10:05pm by flotulopex » |
Logged
|
Roger
|
|
|
Richard Russell
Administrator
member is offline
Posts: 1348
|
|
Re: Show and hide window
« Reply #1 on: Jun 24th, 2017, 11:21pm » |
|
on Jun 24th, 2017, 10:00pm, flotulopex wrote:There might be a "simple way" to show and/or hide a window...or does it have to be open/closed every time it is used? |
|
I think you can use the 'show' and 'hide' GUI commands with a window as well as with a control. Something like this might work:
Code:[MouseMove]
IF MouseX > 1900 THEN #Side "show"
IF MouseX < 1720 THEN #Side "hide"
WAIT Richard.
|
|
Logged
|
|
|
|
Richard Russell
Administrator
member is offline
Posts: 1348
|
|
Re: Show and hide window
« Reply #2 on: Jun 25th, 2017, 09:30am » |
|
on Jun 24th, 2017, 11:21pm, Richard Russell wrote:I think you can use the 'show' and 'hide' GUI commands with a window as well as with a control. |
|
Here's your entire program adapted accordingly; it seems to work for me. I've commented out the LOADBMP statements because I don't have your bitmaps; instead I've filled the 'side' window with red to make it visible:
Code:' TwoWindows.bas
NOMAINWIN
GRAPHICBOX #Main.GBx1,0,0,DisplayWidth,DisplayHeight
STYLEBITS #Main.GBx1,0,_WS_BORDER,0,0
GRAPHICBOX #Side.GBx1,0,0,200,DisplayHeight
STYLEBITS #Side.GBx1,0,_WS_BORDER,0,0
[MAIN]
WindowWidth = DisplayWidth
WindowHeight = DisplayHeight
' LOADBMP "Back", DefaultDir$ + "\" + "BACK.bmp" 'DisplayWidthxDisplayHeight bmp file
OPEN "BACK" FOR window_popup AS #Main
#Main "TRAPCLOSE [QuitMain]"
#Main.GBx1 "down"
#Main.GBx1 "drawbmp Back 0 0"
#Main.GBx1 "when leftButtonDown [MouseLeftButton]"
#Main.GBx1 "when mouseMove [MouseMove]"
UpperLeftX = DisplayWidth-200
UpperLeftY = 0
WindowWidth = 200
WindowHeight = DisplayHeight
'LOADBMP "Side", DefaultDir$ + "\" + "SIDE.bmp" '200xDisplayHeight bmp file
STYLEBITS #Side,0,_WS_VISIBLE,0,0
OPEN "SIDE" FOR window_popup AS #Side
#Side.GBx1 "down; fill red"
#Side.GBx1 "drawbmp Side 0 0"
WAIT
[QuitMain]
CLOSE #Main
CLOSE #Side
END
[MouseLeftButton]
IF (MouseX < 10 AND MouseY < 10) THEN GOTO [QuitMain] 'clic on top left = QUIT
WAIT
[MouseMove]
IF MouseX > DisplayWidth-20 THEN #Side "show"
IF MouseX < DisplayWidth-200 THEN #Side "hide"
WAIT Richard.
|
|
|
|
flotulopex
Junior Member
member is offline
Gender:
Posts: 94
|
|
Re: Show and hide window
« Reply #3 on: Jun 25th, 2017, 10:16am » |
|
Thanks a lot Richard. It works effectively.
I spent all my Saturday afternoon searching for this (...).
Thank you again
|
|
Logged
|
Roger
|
|
|
flotulopex
Junior Member
member is offline
Gender:
Posts: 94
|
|
Re: Show and hide window
« Reply #4 on: Jun 25th, 2017, 10:39am » |
|
BTW, where can I find info about the _WS_VISIBLE stylebit?
I can't find it in the help file.
These area the ones listed in the help file: _WS_BORDER Creates a window that has a thin-line border. _WS_CAPTION Creates a window that has a title bar (includes the WS_BORDER style). _WS_HSCROLL Creates a window that has a horizontal scroll bar. _WS_MAXIMIZE Creates a window that is initially maximized. _WS_MAXIMIZEBOX Creates a window that has a Maximize button. _WS_MINIMIZE Creates a window that is initially minimized. Same as the WS_ICONIC style. _WS_MINIMIZEBOX Creates a window that has a Minimize button. _WS_VSCROLL Creates a window that has a vertical scroll bar.
|
|
Logged
|
Roger
|
|
|
Richard Russell
Administrator
member is offline
Posts: 1348
|
|
Re: Show and hide window
« Reply #5 on: Jun 25th, 2017, 11:20am » |
|
on Jun 25th, 2017, 10:39am, flotulopex wrote:BTW, where can I find info about the _WS_VISIBLE stylebit? |
|
MSDN has a list of style bits here, including that one.
I'm not sure it is strictly necessary in your program, but I wanted to avoid the side window initially appearing, even if only for a brief 'flash'.
Richard.
|
|
Logged
|
|
|
|
flotulopex
Junior Member
member is offline
Gender:
Posts: 94
|
|
Re: Show and hide window
« Reply #6 on: Jun 25th, 2017, 3:35pm » |
|
Quote:I wanted to avoid the side window initially appearing, even if only for a brief 'flash'. |
|
This is just perfect! Looks much more "pro".
Thanks again.
Rog'
|
|
Logged
|
Roger
|
|
|
|