LB Booster
« Show and hide window »

Welcome Guest. Please Login or Register.
Apr 1st, 2018, 04:18am



ATTENTION MEMBERS: Conforums will be closing it doors and discontinuing its service on April 15, 2018.
We apologize Conforums does not have any export functions to migrate data.
Ad-Free has been deactivated. Outstanding Ad-Free credits will be reimbursed to respective payment methods.

Thank you Conforums members.
Speed up Liberty BASIC programs by up to ten times!
Compile Liberty BASIC programs to compact, standalone executables!
Overcome many of Liberty BASIC's bugs and limitations!
LB Booster Resources
LB Booster documentation
LB Booster Home Page
LB Booster technical Wiki
Just BASIC forum
BBC BASIC Home Page
Liberty BASIC forum (the original)

« Previous Topic | Next Topic »
Pages: 1  Notify Send Topic Print
 thread  Author  Topic: Show and hide window  (Read 208 times)
flotulopex
Junior Member
ImageImage


member is offline

Avatar




Homepage PM

Gender: Male
Posts: 94
xx 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 » User IP Logged

Roger
Richard Russell
Administrator
ImageImageImageImageImage


member is offline

Avatar




Homepage PM


Posts: 1348
xx 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.
User IP Logged

Richard Russell
Administrator
ImageImageImageImageImage


member is offline

Avatar




Homepage PM


Posts: 1348
xx 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.
« Last Edit: Jun 25th, 2017, 1:25pm by Richard Russell » User IP Logged

flotulopex
Junior Member
ImageImage


member is offline

Avatar




Homepage PM

Gender: Male
Posts: 94
xx 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 wink
User IP Logged

Roger
flotulopex
Junior Member
ImageImage


member is offline

Avatar




Homepage PM

Gender: Male
Posts: 94
xx 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.
User IP Logged

Roger
Richard Russell
Administrator
ImageImageImageImageImage


member is offline

Avatar




Homepage PM


Posts: 1348
xx 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.
User IP Logged

flotulopex
Junior Member
ImageImage


member is offline

Avatar




Homepage PM

Gender: Male
Posts: 94
xx 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'
User IP Logged

Roger
Pages: 1  Notify Send Topic Print
« Previous Topic | Next Topic »

| |

This forum powered for FREE by Conforums ©
Terms of Service | Privacy Policy | Conforums Support | Parental Controls