>Hello, I need someone to teach me now how to put up my own define toolbar before I call up my form.
>
>Please tell me in step by step, with codes. Thank you, as I am not good in VFP. I am using VFP 5.0
>
>Leo
It's a little tough from your message to decipher exactly what you are trying to do so I have to assume. I assume that you are asking how to bring up a custom toolbar when the form comes up and have the toolbar go away when the form goes away.
The method, then, calls for you to create a toolbar class and store it in a .VCX. Then, you instantiate the toolbar in the INIT() of the form.
To illustrate this, I created a toolbar class called "MyToolBar" and stored it in TEMP.VCX. I put two buttons to simulate navigation buttons in the form (one next and one prior). Then I instantiated the toolbar in a form when I run the form.
Here's the code (exported from the class browser).
First, here's the code for the toolbar.
**************************************************
*-- Class: mytoolbar (e:\code\temp.vcx)
*-- ParentClass: toolbar
*-- BaseClass: toolbar
*
DEFINE CLASS mytoolbar AS toolbar
Caption = "Toolbar1"
Height = 31
Left = 0
Top = 0
Width = 55
Name = "mytoolbar"
ADD OBJECT command1 AS commandbutton WITH ;
Top = 5, ;
Left = 5, ;
Height = 22, ;
Width = 23, ;
Caption = "N", ;
ToolTipText = "Next", ;
Name = "Command1"
ADD OBJECT command2 AS commandbutton WITH ;
Top = 5, ;
Left = 27, ;
Height = 22, ;
Width = 23, ;
Caption = "P", ;
ToolTipText = "Prior", ;
Name = "Command2"
PROCEDURE command1.Click
_screen.activeform.next()
ENDPROC
PROCEDURE command2.Click
_screen.activeform.prior()
ENDPROC
ENDDEFINE
*
*-- EndDefine: mytoolbar
**************************************************
Now, here's the code for the form.
**************************************************
*-- Form: form1 (e:\code\test.scx)
*-- ParentClass: form
*-- BaseClass: form
*
DEFINE CLASS form1 AS form
DoCreate = .T.
Caption = "Form1"
Name = "Form1"
otoolbar = .F.
PROCEDURE Destroy
this.oToolbar = .NULL.
ENDPROC
PROCEDURE Init
this.oToolBar = CREATEOBJECT("myToolBar")
this.oToolbar.SHow()
ENDPROC
PROCEDURE Load
SET CLASSLIB TO temp.vcx
ENDPROC
PROCEDURE next
WAIT WINDOW "I would move to the next record here!"
ENDPROC
PROCEDURE prior
WAIT WINDOW "I would move to the prior record here!"
ENDPROC
ENDDEFINE
*
*-- EndDefine: form1
**************************************************
Notice that I have a custom property called oToolBar that contains the reference to the toolbar. Note how the toolbar class communicates with the form.
HTH