Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Can you make an undocked toolbar NOT closable?

Status
Not open for further replies.

vfp7guy

Programmer
Jul 2, 2002
45
CA
I have designed and implemented a VFP toolbar into a test system, including a popup on one of the button pairs (as in the VFP ... Samples...Sedona\newtbars.vcx). Everything appears to work well both docked and undocked, except I have one concern.

I don't want this toolbar to be able to be deleted with the upper-right "X" button that appears when undocked. I cannoy find any closable property. Is there a way to prevent this "X" box from showing?
 
Hi VFP7Guy,

The following code was given to me by Christof Wollenhaupt. I've used it to prevent a docked toolbar from closing. As far as I can see, it should work the same with an undocked one.

Code:
ON KEY LABEL MOUSE ;
  IIF(LOWER(MWINDOW()) == "MyToolbar" AND ;
  (MCOL(MWINDOW()) = -1 OR MROW(MWINDOW()) = -1),;
  EatMouseClick(), "")

PROCEDURE EatMouseClick
  WAIT WINDOW ""
ENDPROC

"MyToolbar" is the toolbar's Name property.

The only problem is that it does not hide the X button. It just makes it inactive.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

My Visual FoxPro site: www.ml-consult.co.uk
 
Thanks Mike ... I'll give it a try ... this may be what I need.
Roy
 
Roy,

Be aware that this code will run whenever you click the mouse. If you forget to clear the ON KEY LABEL when you are in the development environment, VFP will be look for a file named EatMouseClick.PRG on every mouse click. If it's not present, you'll get an error message.

I got round that by only running the above code when the program was running as an executable.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

My Visual FoxPro site: www.ml-consult.co.uk
 
Hello Vfp7guy;
The following code is to give you an idea of how to do it. You will have to expand/fine tune to suit your needs.
I am assuming the toolbar is a class and is shown with a Createobject().
****In your application start program
Public oMyToolBar, lRemoveToolBar
lRemoveToolBar = .F.
oMyToolBar = createobject("MainToolBar")
****Maintollbar is a class
oMyToolBar.show

****In your application Exit program
***Before you release any variables
lRemoveToolBar = .T.

***Toolbar.Destroy()
*** Here you can display a messagebox to ask the user if they ***want to remove the tool bar. If a "Yes" then set ***lRemovetoolbar to a .T.
If !lRemoveToolBar
oMyToolBar = createobject("MainToolBar")
oMyToolBar.show
endif
*******************************
lRemovetoolbar prevents the Tollbar from recreating itself when the application exits

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top