Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
How to make a toolbar?
Message
 
À
17/07/2001 06:57:30
Information générale
Forum:
Visual FoxPro
Catégorie:
Gestionnaire d'écran & Écrans
Divers
Thread ID:
00531430
Message ID:
00531674
Vues:
11
>hi, in a form its posible to insert a toolbars right? how can i make a toolbars in my form?
>
>jay
Here's one method to do it with an activex bar
* SNIPS to add OCX ToolBar to a form

* IN forms init event
TPAddImageList(thisform)
ORAddContainer(thisform) &&Add the container
ORAddToolBar(thisform,thisform.IL) && Add the tool bar
*

* In a PRG or methods containers
* To use the OCX - best to put inside container
define class cntToolBarClass as Container
left=0
height=26
width=1
top=0
enddef && class cntToolBar as Container

* Define sub class for OCX tool bar
define class ocxToolBarClass as Olecontrol
* Click the regualar buttons
procedure ButtonClick(Button)
ocxToolBarClassButtonClick(button.key)
endproc &&ButtonClick(Button)
* Click the button menu
procedure ButtonMenuClick(buttonmenu)
ocxToolBarButtonMenuClick(Buttonmenu.key,Buttonmenu.text)
endproc
enddef && oxcToolBar as Olecontrol

* Add the container to form
procedure ORAddContainer(oForm)
oForm.AddObject('cntToolBar','cntToolBarClass')
with oform.cntToolBar
.width=oForm.width
.BorderWidth=2
.height=26
endwith &&oform.tbc
endproc

* Add the tool bar and some buttons
procedure ORAddToolBar(oForm,oImageList)
oForm.cntToolBar.AddObject('ocxToolBar','ocxORToolBarClass','MSComctlLib.Toolbar.2')
with oForm.cntToolBar.ocxToolBar
.imagelist=oImageList
.AllowCustomize=.f.
.Appearance=0
.Wrappable=.f.
.Style=1
.top=2
.left=4
.width=oForm.Width
.buttonheight=20
.buttonwidth=20
.buttons.add(,[PRINT],,0,[PRINT])
.buttons([PRINT]).ToolTipText=[Order Reports]
.buttons.add(,[SAVE],,0,[SAVE])
.buttons([SAVE]).ToolTipText=[Save Order]
.buttons.add(,[UNDO],,0,[UNDO])
.buttons([UNDO]).ToolTipText=[Undo to last or blank]
.buttons.add(,[DELETE],,0,[DELETE])
.buttons([DELETE]).ToolTipText=[Delete order]
endwith
with oForm.cntToolBar
store .t. to .ocxToolBar.Visible
endwith
endproc

* Process the buttons this uses the click event of Command Buttons to do the work
procedure ORToolBarButtonClicks(lcButtonKey,oForm) 
with oForm
if lcButtonKey=[UNDO] AND .cmdClear.Enabled
   oForm.cmdClear.SetFocus
   KeyBoard '{SPACEBAR}'
else
if lcButtonKey=[SAVE] AND .cmdSave.Enabled
   .cmdSave.Click
else
if lcButtonKey=[DELETE] AND .cmdRemove.Enabled
   .cmdRemove.Click
else
if lcButtonKey=[PRINT]
   .cmdReport.Click
else
if lcButtonKey=[ORDAT] AND !.neworder
   do form OrderDate with .txtOrdr_Date.Value
endif
endif
endif
endif
endif
endwith
endproc &&ocxToolBarButtonClick(ButtonKey) 

* Add your image control
procedure TPAddImageList(oForm)
oForm.addobject('IL','Olecontrol','MSComctlLib.ImageListCtrl.2')
with oForm.IL
.imageheight=16
.imagewidth=16
.listimages.Add(1,"SAVE",LoadPicture("IMX\SAVE.BMP")) && 1
.listimages.Add(1,"HELP",LoadPicture("IMX\HELP.BMP")) && 1
.listimages.Add(1,"DELETE",LoadPicture("IMX\DELETE.BMP"))
.listimages.Add(1,"PRINT",LoadPicture("IMX\PRINT.BMP"))
.listimages.Add(1,"UNDO",LoadPicture("IMX\UNDO.BMP"))
endwith
endproc
Imagination is more important than knowledge
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform