Skip to main content
guest
Join
|
Help
|
Sign In
Liberty BASIC Programmer's Encyc
Home
guest
|
Join
|
Help
|
Sign In
Wiki Home
Recent Changes
Pages and Files
Members
Home
General Tutorials
Advanced Tutorials
GUI Programming
Graphics and Games
Strings and Text
Numbers and Math
Using Files
Windows API
Communications
Programmer's Tools
Articles by Date
FAQs
Rosetta Code
General Articles
Newsletters Contents
Table of Contents
Demos
Submit Articles
TOS and License
ShowHideControls
Edit
1
…
0
Tags
No tags
edit
Save
Cancel
Notify
RSS
Backlinks
Source
Print
Export (PDF)
<strong>Show and Hide Controls</strong><br /> <em>[[user:Alyce]]</em><br /> <img id="wikitext@@toc@@flat" class="WikiMedia WikiMediaTocFlat" title="Table of Contents" src="/site/embedthumbnail/toc/flat?w=100&h=16"/><hr /> <h1>Create Visible Controls</h1> Windows and controls are visible by default. <br /> <br /> <h1>Create Hidden Controls</h1> We can create a control that is initially hidden if we use the STYLEBITS statement with the style _WS_VISIBLE in the "remove bits" spot. It looks like this:<br /> <br /> <pre class="lb">stylebits #1.btn, 0, _WS_VISIBLE, 0, 0</pre> <br /> _WS_VISIBLE is the constant value for "window style visible". In the code above it is in the spot for stylebits removed from the default Liberty BASIC style, so the control will not be visible when the window is opened.<br /> <br /> <h1>Command Strings</h1> In Liberty BASIC we send commands to controls as a string of text. Some controls can accept new captions or text, so a string of text sent to these controls is displayed on the control. Sending the string "hide" to a button will cause the button caption to display "hide". It will not cause the button to be hidden. Controls that accept text strings need the character <strong>!</strong> (exclamation point) to be prepended to the text string.<br /> <br /> <pre class="lb">'Change button caption to HIDE<br/>#1.btn "HIDE"<br/>'Hide the button<br/>#1.btn "!HIDE"</pre> <br /> Some examples of controls that require command strings to begin with <strong>!</strong> are buttons, textboxes, and statictext controls. Some examples of controls that do not require the prepended exclamation point in command strings are listboxes, comboboxes and graphicboxes.<br /> <br /> <h1>The SHOW statement</h1> Use the "show" statement to cause a control to be visible. If the control is already visible, it will remain visible. If the control is hidden, it will be displayed.<br /> <pre class="lb"> #1.button "!show" 'display control<br/> #1.listbox "show" 'display control</pre> <br /> <h1>The HIDE statement</h1> Use the "hide" statement to hide a control. If the control is not visible, it will remain hidden. If it is visible, it will be hidden.<br /> <pre class="lb"> #1.button "!hide" 'hide control<br/> #1.listbox "hide" 'hide control</pre> <br /> <h1>Refresh?</h1> The <strong>refresh</strong> statement is used when controls are moved with the <strong>locate</strong> statement. Controls that are moved or resized with <strong>locate</strong> do not display in their new locations or sizes until a <strong>refresh</strong> statement is sent to their parent window. The "refresh" statement is <strong>not</strong> used when controls are shown or hidden. Controls are hidden or shown as soon as they receive the "hide" or "show" command.<br /> <br /> <h1>Demo</h1> <pre class="lb">nomainwin<br/>for i = 1 to 10<br/> list$(i)="List Item ";str$(i)<br/>next<br/><br/>stylebits #1.btn, 0, _WS_VISIBLE, 0, 0<br/>stylebits #1.list, 0, _WS_VISIBLE, 0, 0<br/>button #1.btn, "Button",[nothing],UL,10,60<br/>listbox #1.list, list$(),[nothing],10,100,100,120<br/>button #1.flip, "Show",[hideShow],UL,10,10<br/>open "Hide and Show Controls" for window as #1<br/><br/>wait<br/>[quit] close #1:end<br/><br/>[hideShow]<br/>if Shown then<br/> #1.btn "!hide" 'hide control<br/> #1.list "hide" 'hide control<br/> #1.flip "Show" 'change caption<br/>else<br/> #1.btn "!show" 'display control<br/> #1.list "show" 'display control<br/> #1.flip "Hide" 'change caption<br/>end if<br/>Shown=not(Shown)<br/>wait<br/><br/>[nothing] wait<br/></pre> <hr /> <img id="wikitext@@toc@@flat" class="WikiMedia WikiMediaTocFlat" title="Table of Contents" src="/site/embedthumbnail/toc/flat?w=100&h=16"/>
Javascript Required
You need to enable Javascript in your browser to edit pages.
help on how to format text
Turn off "Getting Started"
Home
...
Loading...