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

Creating a toolbar

Status
Not open for further replies.

AndrewMozley

Programmer
Oct 15, 2005
621
GB
I have a toolbar class (mytoolbar) defined in my project (Thisproj.pjx). I would like to create a toolbar of this class which I can call from my main (start-up program). How do I do this?

I have (optimistically) tried :
CREATE Toolbar A1bar as mytoolbar from classes\mytoolbar.vcx
. . .This gives a syntax error

Have tried
CREATE FORM A1bar as mytoolbar from classes\mytoolbar.vcx
. . . VFP states correctly "Class mytoolbar is not a form class".

I have the Microsoft Visual FoxPro 6 Programmers Guide - is the creation of a toolbar defined there? (In fact I am using VFP9)

Thanks. Andrew
 
There is no CREATE TOOLBAR command. The syntax of the CREATE command does not have toolbar as any option, you have to create a toolbar class. There is no file extension for toolbars, therefore it can't be a first level option, toolbars always are classes of VCXes, like most baseclasses can only be inherited as classes, not as standalone files.

Also, you don't want to create but to use the toolbar. You use a class by creating an object (aka instance) from it at runtime via the CREATEOBJECT() function. You may also use a class by dragging it into a container it can live in, eg into a form. That'll make VFP ask you, if you want a formset. No other thing but a formset can contain a toolbar, which is a disadvantage, but as said you could also create it separately via CREATEOBJECT() in code at runtime, then it has no parent container, it'll be "self contained" as a form.

Bye, Olaf.
 
Thank you Olaf.

I am still keen to use the toolbar class. How can I create a toolbar class, based on my existing class, mytoolbar, which I can then save as (say) A1bar in file mytoolbar.vcx. I would then like to modify toolbar a1bar, putting command buttons on it &c.

Then, at run time I will instantiate a1bar with NEWOBJECT("A1Bar","mytoolbar,vcx")

It is the creation of toolbar class A1bar which I need to be able to do. I will then (I believe) be able to modify it with the command MODIFY CLASS A1bar OF c:\stage2\newcms\classes\mytoolbar.vcx.

Sorry to be making heavy weather of this.
 
Andrew,

I think this is what you want:

1. In the command window, type [tt]CREATE CLASS[/tt].

2. In the resulting dialogue, enter a name for your new toolbar.

3. Click the three-dots button to the right of the Based On control; navigate to your base toolbar class.

4. Click the three-dots button to the right of the Store In control; navigate to the library where you want to store your new toolbar.

5. Click OK.

6. You are now in the Class Designer, and you can go ahead and work on your new toolbar to your heart's content.

Mike




__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads
 
Thank you both; I had not realised that, although it is a sort of form which never gets focus, a Toolbar (unlike a form), can only ever exist in the file system as a class : it needs to be instantiated at run-time.

I have followed your instructions and am indeed working on the toolbar to my heart's content.

Andrew
 
You can do some trickery, but you don't get around having a toolbar class.
You create a form in Documents, you drag the toolbar into it. The form designer asks for generating a form set, you confirm that.
Now in the Form menu you can remove form and then have the toolbar in the form set, you can then remove form set and have a standalone toolbar in an SCX file.

Now you can start the toolbar with DO FORM, but that's the only difference and I wouldn't even consider it an advantage over needing to create a toolbar object via NEWOBJECT or CREATEOBJECT.

Bye, Olaf.

PS: The only interesting thing I came about when testing this is, you can't drag a toolbar from the Toolbox to a form. Also not, if you first manually create a form set. Actually a bug of the Toolbox.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top