Alpha Software Mobile Development Tools:   Alpha Anywhere    |   Alpha TransForm subscribe to our YouTube Channel  Follow Us on LinkedIn  Follow Us on Twitter  Follow Us on Facebook

Announcement

Collapse

The Alpha Software Forum Participation Guidelines

The Alpha Software Forum is a free forum created for Alpha Software Developer Community to ask for help, exchange ideas, and share solutions. Alpha Software strives to create an environment where all members of the community can feel safe to participate. In order to ensure the Alpha Software Forum is a place where all feel welcome, forum participants are expected to behave as follows:
  • Be professional in your conduct
  • Be kind to others
  • Be constructive when giving feedback
  • Be open to new ideas and suggestions
  • Stay on topic


Be sure all comments and threads you post are respectful. Posts that contain any of the following content will be considered a violation of your agreement as a member of the Alpha Software Forum Community and will be moderated:
  • Spam.
  • Vulgar language.
  • Quotes from private conversations without permission, including pricing and other sales related discussions.
  • Personal attacks, insults, or subtle put-downs.
  • Harassment, bullying, threatening, mocking, shaming, or deriding anyone.
  • Sexist, racist, homophobic, transphobic, ableist, or otherwise discriminatory jokes and language.
  • Sexually explicit or violent material, links, or language.
  • Pirated, hacked, or copyright-infringing material.
  • Encouraging of others to engage in the above behaviors.


If a thread or post is found to contain any of the content outlined above, a moderator may choose to take one of the following actions:
  • Remove the Post or Thread - the content is removed from the forum.
  • Place the User in Moderation - all posts and new threads must be approved by a moderator before they are posted.
  • Temporarily Ban the User - user is banned from forum for a period of time.
  • Permanently Ban the User - user is permanently banned from the forum.


Moderators may also rename posts and threads if they are too generic or do not property reflect the content.

Moderators may move threads if they have been posted in the incorrect forum.

Threads/Posts questioning specific moderator decisions or actions (such as "why was a user banned?") are not allowed and will be removed.

The owners of Alpha Software Corporation (Forum Owner) reserve the right to remove, edit, move, or close any thread for any reason; or ban any forum member without notice, reason, or explanation.

Community members are encouraged to click the "Report Post" icon in the lower left of a given post if they feel the post is in violation of the rules. This will alert the Moderators to take a look.

Alpha Software Corporation may amend the guidelines from time to time and may also vary the procedures it sets out where appropriate in a particular case. Your agreement to comply with the guidelines will be deemed agreement to any changes to it.



Bonus TIPS for Successful Posting

Try a Search First
It is highly recommended that a Search be done on your topic before posting, as many questions have been answered in prior posts. As with any search engine, the shorter the search term, the more "hits" will be returned, but the more specific the search term is, the greater the relevance of those "hits". Searching for "table" might well return every message on the board while "tablesum" would greatly restrict the number of messages returned.

When you do post
First, make sure you are posting your question in the correct forum. For example, if you post an issue regarding Desktop applications on the Mobile & Browser Applications board , not only will your question not be seen by the appropriate audience, it may also be removed or relocated.

The more detail you provide about your problem or question, the more likely someone is to understand your request and be able to help. A sample database with a minimum of records (and its support files, zipped together) will make it much easier to diagnose issues with your application. Screen shots of error messages are especially helpful.

When explaining how to reproduce your problem, please be as detailed as possible. Describe every step, click-by-click and keypress-by-keypress. Otherwise when others try to duplicate your problem, they may do something slightly different and end up with different results.

A note about attachments
You may only attach one file to each message. Attachment file size is limited to 2MB. If you need to include several files, you may do so by zipping them into a single archive.

If you forgot to attach your files to your post, please do NOT create a new thread. Instead, reply to your original message and attach the file there.

When attaching screen shots, it is best to attach an image file (.BMP, .JPG, .GIF, .PNG, etc.) or a zip file of several images, as opposed to a Word document containing the screen shots. Because Word documents are prone to viruses, many message board users will not open your Word file, therefore limiting their ability to help you.

Similarly, if you are uploading a zipped archive, you should simply create a .ZIP file and not a self-extracting .EXE as many users will not run your EXE file.
See more
See less

Changing the toolbar on an open form

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Changing the toolbar on an open form

    Does anyone have a script for how to do this? I want to change the toolbar on my Home form without closing and reopening the form. I am using the same button on 2 toolbars to toggle the user log on and log off (based on global variable USERID = "" or not), and would like to change the toolbar in each case.

    If I open another form, then I can use the OnActivate event for the Home form to show the toolbar change, otherwise I get no toolbar. I tried a msgbox but that didn't trigger the OnActivate event when it closed since it is a dialog. I found a function in the wiki for <object>.toolbarchange(toolbarname) but the example seems to be lacking more info on how to use it outside the IW.

    Here is my toolbar button script:
    Code:
    dim frm as p
    dim tbar as c
    dim msg as c
    frm = topparent.this
    with global_variables()
    msg  = "User :"+u_name
    
    select
    	case userid <> ""
    		msg  = "Logged off User :"+u_name
    		LogOff()
    		if ui_modeless_dlg_exist("Action Menu")then
    			ui_modeless_dlg_close("Action Menu")						
    		end if	
    		tbar = "LogIn Tbar"
    	case else		
    		msg  = "Logged on User :"+u_name
    		Log_In(.t.)
    		ActMenu()		
    		tbar = "Home Tbar"			
    end select
    
    frm.toolbarchange(Tbar)
    frm:u_login.refresh()      [COLOR="#0000FF"]'form level calc field to show the user name[/COLOR]
    frm.window_position("fill","fill")
    [COLOR="#0000FF"]'this didn't help[/COLOR]
    response = msgbox("",msg,0)
    if response = 0
    	:home.activate()
    end if	
    end with
    I also set the form's dynamic property for the toolbar based on userid - didn't seem to help either. I tried adding form.resynch() and form.refresh_layout() - still no toolbar shows, unless I display the control panel or open another form. Then when I come back to the Home form all is well.

    loggedoff.jpg loggedin.jpg
    Last edited by MoGrace; 09-13-2017, 05:11 PM.
    Robin

    Discernment is not needed in things that differ, but in those things that appear to be the same. - Miles Sanford

    #2
    Re: Changing the toolbar on an open form

    So does no response mean this isn't doable?
    Robin

    Discernment is not needed in things that differ, but in those things that appear to be the same. - Miles Sanford

    Comment


      #3
      Re: Changing the toolbar on an open form

      The example for .toolbarchange() suggests that the usage would be

      Code:
      select
      	case userid <> ""
      		msg  = "Logged off User :"+u_name
      		LogOff()
      		if ui_modeless_dlg_exist("Action Menu")then
      			ui_modeless_dlg_close("Action Menu")						
      		end if	
      		frm.toolbarchange("LogIn Tbar") 
      	case else		
      		msg  = "Logged on User :"+u_name
      		Log_In(.t.)
      		ActMenu()		
      		frm.toolbarchange("Home Tbar") 			
      end select
      That may just be a variation on what you tried. Don't do much with toolbars.
      Last edited by Stan Mathews; 09-14-2017, 12:35 PM.
      There can be only one.

      Comment


        #4
        Re: Changing the toolbar on an open form

        Originally posted by MoGrace View Post
        So does no response mean this isn't doable?
        You are playing in the deep end of the pool. Not sure many have been there....
        Al Buchholz
        Bookwood Systems, LTD
        Weekly QReportBuilder Webinars Thursday 1 pm CST

        Occam's Razor - KISS
        Normalize till it hurts - De-normalize till it works.
        Advice offered and questions asked in the spirit of learning how to fish is better than someone giving you a fish.
        When we triage a problem it is much easier to read sample systems than to read a mind.
        "Make it as simple as possible, but not simpler."
        Albert Einstein

        http://www.iadn.com/images/media/iadn_member.png

        Comment


          #5
          Re: Changing the toolbar on an open form

          I created a function to switch toolbars.

          Code:
          FUNCTION tbarchg AS L (name AS C )
          	tbarchg = .F.
          	if name = "MainMenu"
          		other = "Mine"
          	else
          		other = "MainMenu"
          	end if
          	parentform.toolbarchange(other)
          	tbarchg = .T.
          END FUNCTION
          I placed buttons on the form with tbarchg("MainMenu") and tbarchg("mine"). They work as expected and change the visible toolbar.

          I placed a button on each toolbar with the same code. Pressing either button causes the toolbar to disappear.
          There can be only one.

          Comment


            #6
            Re: Changing the toolbar on an open form

            This seems to work.

            Code:
            FUNCTION tbarchg AS L (name AS C )
            	tbarchg = .F.
            	if name = "MainMenu"
            		other = "Mine"
            	else
            		other = "MainMenu"
            	end if
            	tbarnow = toolbar.get(name)
            	tbarnow.close()
            	dim vl as P
            	dim tbar as P
            	vl = local_variables()
            	tbar = a5_toolbar_def_load(other)
            	a5_system_toolbar_show(vl,tbar)
            	tbarchg = .T.
            END FUNCTION
            The toolbar button code is

            tbarchg("name_of_current_toolbar")
            There can be only one.

            Comment


              #7
              Re: Changing the toolbar on an open form

              Thank you Stan. I was trying to do it as a global script and hadn't gotten to making a function yet. UDF's always seem to work better. What did work but seemed contrived, was to minimize the control panel, activate it then activate the loaded form and hide the control panel.

              Edit:

              This line: a5_system_toolbar_show(vl,tbar) was the one thing I hadn't tried!

              I adapted the function to my toolbar buttons and it worked twice successfully but on the 3rd try the toolbar did not change. So what I did was, after calling the new function added these lines to the OnActivate event for the Home form:

              this.toolbar = var->t2
              this.refresh_layout()

              This is the script the toolbar buttons call:
              Code:
              'toolbar button script used to toggle toolbar display based on global var USERID
              dim frm as p
              dim t1 as c
              dim t2 as c
              
              frm = topparent.this
              
              with global_variables()
              
              'dynamic property is also set to display Home form toolbar based on userid
              select
              	case userid <> ""		
              		'Home Tbar is current toolbar
              		LogOff()		
              		if ui_modeless_dlg_exist("Action Menu")then
              			ui_modeless_dlg_close("Action Menu")						
              		end if	
              		t1 = "Home Tbar"
              		t2 = "Login Tbar"
              	case else				
              		Log_In(.t.)		
              		ActMenu()	
              		t1 = "Login Tbar"
              		t2 = "Home Tbar"						
              end select
              
              cx_tbar(t1,t2)
              [COLOR="#0000FF"]controlpanel.Minimize()    'without this section no toolbar showed after the change
              controlpanel.Activate()
              frm.activate()
              controlpanel.Hide()[/COLOR]
              frm:u_login.refresh()
              frm.window_position("fill","fill")
              
              end with
              And this is my modified function:
              Code:
              FUNCTION cx_tbar AS L (cur_tbar AS C, new_tbar as c )
              'DESCRIPTION: Change the default form toolbar to display a different one	
              'Thanks to Stan Matthew
              	cx_tbar = .F.
              	dim lv as p
              	dim tbar1 as p		
              	dim tbar2 as p	
              	
              	lv = local_variables()
              	
              	tbar1 = toolbar.get(cur_tbar)
              	tbar1.close()	
              	
              	tbar2 = a5_toolbar_def_load(new_tbar)
              	a5_system_toolbar_show(lv,tbar2)
              	
              	cx_tbar = .T.
              END FUNCTION
              My HOME OnActivate script:
              Code:
              dim shared timer_flag as L = .t.
              'OnDeactivate turns timer_flag to .f. and timer_interval to 0
              Home.timer_interval = .25
              if controlpanel.IsVisible() then
              	controlpanel.Hide()
              end if
              statusbar.Hide()
              a5_windowbar_close()
              
              dim global userid as c
              dim t1 as c
              dim t2 as c
              if userid = "" then	
              	t1 = "Home Tbar"	
              	t2 = "LogIn Tbar"
              	if ui_modeless_dlg_exist("Action Menu") then
              		ui_modeless_dlg_close("Action Menu")
              	end if
              else
              	t1 = "Login Tbar"
              	t2 = "Home Tbar"
              	if .not. ui_modeless_dlg_exist("Action Menu") then
              		ActMenu()
              	end if
              end if
              c[COLOR="#0000FF"]x_tbar(t1, t2)
              this.toolbar = var->t2
              this.refresh_layout()[/COLOR]
              this.window_position("fill","fill")
              this.ZOrder("bottom")
              Last edited by MoGrace; 09-14-2017, 03:57 PM.
              Robin

              Discernment is not needed in things that differ, but in those things that appear to be the same. - Miles Sanford

              Comment


                #8
                Re: Changing the toolbar on an open form

                This has been working but am now getting this error from the OnActivate event:

                Script:a5_dictionary_read() line:139
                Cannot create a file when that file already exists.
                C:\Users\r\AppData

                I don't know what file AA is looking for in that directory. I didn't find anything.
                Robin

                Discernment is not needed in things that differ, but in those things that appear to be the same. - Miles Sanford

                Comment


                  #9
                  Re: Changing the toolbar on an open form

                  Have you updated to a new build recently? Possibly something is broken there.
                  There can be only one.

                  Comment


                    #10
                    Re: Changing the toolbar on an open form

                    Actually something did break and I'm trying to figure out how to fix it. Do you know if I can use the a5bak files to restore form changes to a different copy of my database that is 3 days old? The most recent files are missing forms but the back up zips are still there. I was working on network optimization for shadow files and did something to my developer adb. That dictionary read error was my first clue...

                    I used another tool to look at the tables and the data in them appears fine. I tried dropping the errant tables from the adb and re adding them but the error with the forms persists. The DD* files appear to be about the same size as my backup. I made modifications to 15 tables/ forms & field rules in the past 3 days and would hate to have to try to redo all that. HELP!
                    Last edited by MoGrace; 07-28-2018, 12:04 AM.
                    Robin

                    Discernment is not needed in things that differ, but in those things that appear to be the same. - Miles Sanford

                    Comment


                      #11
                      Re: Changing the toolbar on an open form

                      You restore a prior version of a form by right clicking on it in the control panel and choose Restore Prior Version. You should be able to copy the a5bak files from one machine to another and use them to restore as long as they reference the same table. I would rename the file being copied so as not to overwrite anything.
                      There can be only one.

                      Comment


                        #12
                        Re: Changing the toolbar on an open form

                        Well what seems to be missing after creating the shadow files is the *.sex files from my development directory. They do however exist in the runtime folder. Are these files the same as the original? The wiki doesn't mention sets under the info on network optimization or whether they are copied in full like the .dd* files or not. The sets were dropped in the dev. adb and I was not able to add them back even though they appeared in the selection list for adding a table/set.

                        Edit: Whew - they are the same so I copied the *.sex files from the shadow to the development copy and all my forms are back! The Wiki mentions being able to edit forms in the shadow copy, but adds they are local only. So that was my clue it would work.
                        Last edited by MoGrace; 07-28-2018, 10:22 AM.
                        Robin

                        Discernment is not needed in things that differ, but in those things that appear to be the same. - Miles Sanford

                        Comment

                        Working...
                        X