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:
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
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
loggedoff.jpg loggedin.jpg
Comment