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 biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Putting toolbars on forms

Status
Not open for further replies.

StewartUK

Programmer
Feb 19, 2001
860
GB
Hello All,

I am trying to get a toolbar to appear on my form, but it always seems to appear in the VFP screen instead.

I tried following the guidance in the Programmers Guide, without success.

Is there some way to have it in the form? I've set the form to be As Top-Level Form and the toolbar is set to be In Top-Level Form. I know that the form has to be in a formset, but am I missing something?

Thanks

Stewart
 
StewartUK

When you say trying to get a toolbar to appear on my form, are you refering to a FoxPro system toolbar or a toolbar class?

Chris :)
 
Stewart

Check the .Init Event of the toolbar class.

You might find THIS.Dock(0), which will place the toolbar under the menu. (.Dock(1),(2),(3) will dock the toolbar left, right and bottom)

Change THIS.Dock(0) to THIS.Dock(-1,x,y), -1 placing the toolbar in the form and x and y being screen coordinates

Chris :)
 
Chris,

Thanks for your suggestion.

I've got in the toolbar init event
Code:
THIS.Dock(-1,10,10)
and in the formset's init event I've put
Code:
this.addobject("tbrtest","atoolbar")
THIS.tbrtest.show
However the toolbar always ends up in the SCREEN rather than on the form. Am I right in thinking that toolbars can only appear in the _SCREEN??

Any further ideas would be welcome,

Stewart
 
Stewart

and in the formset's init event I've put

Unless you specifically need to use a formset for other purposes, you don't need to use one to facilitate the use of a toolbar.

The following code comes from a MAIN.prg and illustrates, for future use, how you can dock toolbars in sequence.

tbrPrint = CREATEOBJECT([tbrPrint])
tbrPrint.SetAll([Enabled],.F.)

tbrEdit = CREATEOBJECT([tbrEdit])
tbrEdit.SetAll([Enabled],.F.)

tbrMain = CREATEOBJECT([tbrMain])
tbrMain.SetAll([Enabled],.F.)

tbrNavigation = CREATEOBJECT([tbrNavigation])
tbrNavigation.SetAll([Enabled],.F.)

* Set Positions
tbrPrint.Dock(0,0,0)
tbrPrint.Show

tbrEdit.Dock(0,tbrPrint.Width,0)
tbrEdit.Show

tbrMain.Dock(0,tbrPrint.Width + tbrEdit.Width,0)
tbrMain.Show

tbrNavigation.Dock(0,tbrPrint.Width + tbrEdit.Width + tbrMain.Width,0)
tbrNavigation.Show

If possible I would abandon the formset and you should then find the toolbar appearing in the form although it is not a form object.

Chris :)

 
Stewart

Please disregard the last post - I failed to notice you are setting the form to be Top-Level, and therefore the comments are invalid.

Chris :)
 
I do not know if this will work, but try putting a menu in your top level form.

Just create a menu with the menu designer (f.i. mymenu.mpr) and put in the init() event of the form:

Do MyMenu WITH THIS

and then try if the toolbar will dock on your form below your menu.

HTH,

Weedz (Wietze Veld)
veld4663@exact.nl

They cling emotionally to code and fix development rather than choosing practices based on analytical assesments of what works best.

After the GoldRush - Steve McConnell
 
Stewart

You can set the toolbar class .ShowWindow = 1, which will show the toolbar in a form also with .ShowWindow = 1, not with .ShowWindow = 2.

You could then try using a Top-Level form, (.ShowWindow = 2), as a container to house your, what was Top-Level, form and the toolbar should then show in the second form.

Modify the second form so that on the resize event, it follows the dimensions of its parent, and remove title bar, borders etc

Untested, untried but worth a shot.

Chris :)
 
In the MSDN help the dock method states:

Arguments

nLocation

Specifies where the toolbar is docked. The values for nLocation are:

Value Constant Description
–1 Undocks the toolbar.
0 Docks the toolbar at the top of the main Visual FoxPro window.
1 Docks the toolbar at the left side of the main Visual FoxPro window.
2 Docks the toolbar at the right side of the main Visual FoxPro window.
3 Docks the toolbar at the bottom of the main Visual FoxPro window.

I guess you can only use a toolbar on the main VFP window.

Weedz (Wietze Veld)
veld4663@exact.nl

They cling emotionally to code and fix development rather than choosing practices based on analytical assesments of what works best.

After the GoldRush - Steve McConnell
 
Thanks for your tip Wietze. I had thought along the same lines, but it didn't work.

I've come across an interesting bit in the help for ShowWindow, which says:

If nExpr is set to 1 when the top-level form is the main Visual FoxPro window, Visual FoxPro automatically resets nExpr to 0.

Does this mean that, if I don't set SCREEN=OFF in the config file, that the main VFP window is going to be the top level form?

Stewart
 
Hello.

Instead, you can use the ActiveBar OCX from DataDynamics.com.

It works great in VFP and you can easy put the toolbar on every form. More than that: toolbar have the same comportament as MS Office toolbars.

Hope this helps.

Grigore Dolghin
Class Software
Bucharest, Romania
 
Thanks Grigore, I'll look into that.

Thanks for everyone's input.

I kind of get the impression that either not very many developers are making use of toolbars, or else are using the VFP screen to hold them?

Stewart
 
Stewart

I kind of get the impression that either not very many developers are making use of toolbars, or else are using the VFP screen to hold them?

I suspect you are right on both counts.

It's a pity because the learning curve for toolbars is short by comparison to other control containers.

Chris :)
 
I had the same problem, and I got around it by creating the toolbar in the Active method of the main form.

I have a property '.toolbar' which is set to null in the forms init. When the form Activates...
if this.toolbar = null
this.toolbar = createobj('toolbarclassname')
endif

Hope this helps

Wayne
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top