Here’s an example of an object definition program, MYTOOLBR.PRG, which defines a basic two-button toolbar for use in any form or application.

parameter FormObj

if pcount() < 1

msgbox("DO mytoolbr.prg WITH <form reference>") 

return 

endif

t = findinstance("myTBar")

if empty(t)

? "Creating toolbar" 

t = new myTBar() 

endif

try

t.attach(FormObj) 

catch (Exception e)

// Ignore already attached error 

? "Already attached" 

endtry

class myTBar of toolbar

this.imagewidth = 16 

this.flat = true 

this.floating = false 

this.b1 = new toolbutton(this) 

this.b1.bitmap = 'filename ..\artwork\button\dooropen.bmp'  

this.b1.onClick = {;msgbox("door is open")} 

this.b1.speedtip = 'button1' 

this.b2 = new toolbutton(this) 

this.b2.bitmap = 'filename ..\artwork\button\doorshut.bmp'  

this.b2.onClick = {;msgbox("door is shut")} 

this.b2.speedtip = 'button2' 

endclass