Normal Topic Hiding Command Buttons (Read 1154 times)
NHUser
Full Member
***
Offline



Posts: 320
Location: Amherst, NH
Joined: Aug 2nd, 2010
Hiding Command Buttons
Jul 26th, 2016 at 7:52pm
Print Post Print Post  
I have a need to isolate certain records in one of my database files.  I've been playing with the programming below to make all the elements in certain records invisible.  This has the desired effect   The key line is "visibility(ThisElement,0).

This works great for all the elements, but it leaves behind all the command buttons.  Is there a similar command i can use?  Like "ThisCommandButton"?

Thanks for your help!



I'm using the programming below to

vElements = @StringArrayElementList()
           vCnt = @CountStringArray(vElements)
           vLoop = 0
           While vLoop < vCnt
           {
                 vLoop = vLoop + 1
                   vName = @AccessStringArray(vElements, vLoop)
                   SetThisElement(vName)
                 vNN = @ElementType(ThisElement)
                 If (vNN > 999 and vNN < 1009)
                 {
                       Visibility(ThisElement,0)
                 }
           }
  
Back to top
 
IP Logged
 
Ray the Reaper
Global Moderator
Members
Lantica Support
*****
Offline


The One & The Only

Posts: 2480
Joined: Aug 20th, 2003
Re: Hiding Command Buttons
Reply #1 - Jul 26th, 2016 at 8:41pm
Print Post Print Post  
Hi Paul,

ThisElement can be used to access all elements on a form, including command buttons. To include Command Buttons, You just need to change your code to:

Code
Select All
If ((vNN > 999 And vNN < 1009) Or (vNN = 1014))
{
	Visibility(ThisElement,0)
} 



Also you should be calling UnsetThisElement() after the If statement but still inside the loop in case you have other code on your form that uses the ThisElement element reference.

-Ray
  

Raymond Yoxall Consulting
ray.yoxall@gmail.com
ryoxall@lantica.com
Sesame Applications, Design and Support
Back to top
IP Logged
 
NHUser
Full Member
***
Offline



Posts: 320
Location: Amherst, NH
Joined: Aug 2nd, 2010
Re: Hiding Command Buttons
Reply #2 - Jul 28th, 2016 at 6:04pm
Print Post Print Post  
The file I'm working on has so many command buttons and elements it became too difficult to use the programing as previously discussed.  The reason was that after I hid everything, the programming became difficult to turn on the appropriate command buttons and elements appropriate for each user or group.

I came up with a solution that is much simpler and does the same thing.  I created a tab set and made it large enough for all my command buttons and elements to fit on the first tab.  Now, instead of hiding all the elements and command buttons, I simply use throwfocus() to move to an element on the second tab.  By clicking on Hide Tab Labels in my design programming, the first tab is not accessible.

I ran into one slight problem while testing it.  I have one file that has an @MsgBox command attached to a certain file condition.  I set this file to be blocked as described above using the ThrowFocus command as the first line in my programming.  However, the file opens with the first tab visible and the message box on the screen.  This leaves everything visible that I'm trying to hide!

Is there some way to make my ThrowFocus() command activate before any of the other programming occurs?
  
Back to top
 
IP Logged
 
Ray the Reaper
Global Moderator
Members
Lantica Support
*****
Offline


The One & The Only

Posts: 2480
Joined: Aug 20th, 2003
Re: Hiding Command Buttons
Reply #3 - Jul 29th, 2016 at 1:43pm
Print Post Print Post  
Hello Paul,

ThrowFocus() is by design deferred so no it can't run first for a variety of reasons.

Rather then Throwing focus to the second tab page(Which is kind of clunky), What I would suggest is to use @ContainedElementList() to get a string array list of all the elements on that tab page. Then use StringArrayAttribute() to set the visibility of those elements.

-Ray
  

Raymond Yoxall Consulting
ray.yoxall@gmail.com
ryoxall@lantica.com
Sesame Applications, Design and Support
Back to top
IP Logged
 
NHUser
Full Member
***
Offline



Posts: 320
Location: Amherst, NH
Joined: Aug 2nd, 2010
Re: Hiding Command Buttons
Reply #4 - Aug 1st, 2016 at 9:07pm
Print Post Print Post  
Ray,

I have too many elements and command buttons that are on/off depending on the user.  I started using the visibility condition but it got too complicated.

The use of the tabs and the throwFocus() command works great.  I think I can develop a work around for the @MsgBox command.

However, I've run into another problem!  I have two command buttons for "Next Record" and "Prior Record" to move through the records.  The programming is below.  If I go into a record that is hidden (via Search mode), the "hiding" works fine.  BUT, if I click on either of those two command buttons, the record is now visible!

Why is this happening?

/* Move to the previous record IF there is one or present a message if there is not
You must select the proper Menu Tree Item based on where you currently are in the
application */

Var vNav as Int

     visibility(ViewQualityAlert0,0)
     Visibility(VSP,0)
     Visibility(VEC,0)
     Visibility(VFC,0)
     Visibility(VFL,0)
     visibility(VPF,0)
     visibility(VMD,0)
     visibility(VTR,0)
     visibility(VTW,0)
     visibility(VIS,0)
     visibility(VAS,0)      

// SET ALL TAB COLORS TO THE BASIC SETUP

//      INSP
           RGBColor(TABPAGE9,0,0,0,204,204,204)
           RGBColor(Print Final I_P Process,0,0,0,204,204,204)      
           RGBColor(le3, 0, 0, 0, 204, 204, 204)
           RGBColor(le24, 0, 0, 0, 204, 204, 204)
           RGBColor(le10, 0, 0, 0, 204, 204, 204)


If @ResultSetCurrentPosition()>1 and @Mode()=1 
     {
     vNav = @SelectTreeItem("Search Update Menu!Navigation!Previous Record (F9)")

           If @Group<>"Master" and Itar="Yes" then
           {
                 ThrowFocus(DCNumberDuplicate)
           }
           Else
           {
                 ThrowFocus(Certs)
           }

     }
If @ResultSetCurrentPosition()<2 and @Update Then
     {
     @Msg("There are No Previous Records In This Set")

           If @Group<>"Master" and Itar="Yes" then
           {
                 ThrowFocus(DCNumberDuplicate)
           }
           Else
           {
                 ThrowFocus(Certs)
           }

     }

If @ResultSetCurrentPosition()>1 and @Mode()=0 
     {
     vNav = @SelectTreeItem("Add Data Menu!Navigation!Previous Record (F9)")
     }
If @ResultSetCurrentPosition()<2 and @Add Then
     {
     @Msg("There are No Previous Records In This Set")
     }
  
Back to top
 
IP Logged
 
NHUser
Full Member
***
Offline



Posts: 320
Location: Amherst, NH
Joined: Aug 2nd, 2010
Re: Hiding Command Buttons
Reply #5 - Aug 2nd, 2016 at 12:31pm
Print Post Print Post  
Never mind!

As usual, it is programmer error!

I've got it working now that I'm attaching the program to the correct command button!!
  
Back to top
 
IP Logged