Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
A container needed to emulate a button.
Message
 
To
03/05/1997 18:02:10
General information
Forum:
Visual FoxPro
Category:
Other
Miscellaneous
Thread ID:
00022050
Message ID:
00030761
Views:
42
>>
>> I need to use a container object to emulate a command button. I've set the
>> intial .SpecialEffect property to 0 (raised) to look like a button. The
>> problem is that I cannot make it look sunken (1) by clicking it. I've
>> tried changing the .SpecialEffect property in the .MouseDown/Up events and
>> in the .Click event to no avail. The button does not change it's
>> appearance. Anyone else done this? How does one make the container look
>> "clicked" at runtime?
>>
>> Thanks,
>> Steve Despres
>to do that you have to under the mouse down command use code first you
>have to have three picture boxes then put oen where you want the custom
>buttom then put to invisible picture boxes the put the first picture
>that would be in the box when it is not cliced then put the picture of
>the button when pressed in the third one and here is the code
>
>private sub mouse down
>picture1.picture = picture2.picture
>end sub
>
>
>private sub mouse up
>picture1.picture = picture3.picture
>end sub
>
>hope i helped you bye

I have build a special button class with a one container, one label and two shapes.

With this button i can set a caption to more than only one line.
BTW the behavior of this button is the one you want.

I cut out the code from the class browser for you.

**************************************************
*-- Class: button
*-- ParentClass: container
*-- BaseClass: container
*---- Special button
*-----With this button you can set the caption to more than only one line
*---------Just set the caption of the label to something like:
*--------- label.caption = "first line"+chr(13)+"second line!"
*-- To use this button you just have to put your code on the Click event of Command1

DEFINE CLASS button AS container

Width = 103
Height = 44
BackColor = RGB(192,192,192)
Name = "button"


ADD OBJECT label1 AS label WITH ;
BackStyle = 0, ;
AutoSize = .T., ;
Name = "Label1"


ADD OBJECT shape2 AS shape WITH ;
BackStyle = 0, ;
BorderWidth = 1, ;
BorderColor = RGB(255,255,255), ;
Name = "Shape2"

ADD OBJECT shape1 AS shape WITH ;
BackStyle = 0, ;
BorderWidth = 1, ;
Name = "Shape1"


ADD OBJECT command1 AS commandbutton WITH ;
top = 3, ;
left = 3, ;
Caption = "Command1", ;
Style = 1, ;
Name = "Command1"


PROCEDURE centretext
this.label1.left = (this.width - this.label1.width)/2
this.label1.top = (this.height - this.label1.height)/2
ENDPROC


PROCEDURE resizebouton
this.shape2.width = this.width +1
this.shape1.width = this.width -2
this.shape2.height = this.height +1
this.shape1.height = this.height -2
this.command1.width = this.width -8
this.command1.height = this.height -8
ENDPROC


PROCEDURE Init
this.centretext
this.resizebouton
this.command1.width = this.width-8
this.command1.height = this.height-8
ENDPROC


PROCEDURE Refresh
this.label1.enabled = this.enabled
this.command1.enabled = this.enabled
this.shape1.bordercolor = iif(this.enabled,rgb(0,0,0),rgb(128,128,128))
ENDPROC


PROCEDURE command1.MouseUp
LPARAMETERS nButton, nShift, nXCoord, nYCoord
thisform.lockscreen = .t.
this.parent.shape2.left = 1
this.parent.shape2.top = 1
this.parent.label1.left = this.parent.label1.left-1
this.parent.label1.top = this.parent.label1.top-1
thisform.lockscreen = .f.
ENDPROC


PROCEDURE command1.MouseDown
LPARAMETERS nButton, nShift, nXCoord, nYCoord
thisform.lockscreen = .t.
this.parent.shape2.left = -2
this.parent.shape2.top = -2
this.parent.label1.left = this.parent.label1.left+1
this.parent.label1.top = this.parent.label1.top+1
thisform.lockscreen = .f.
ENDPROC

ENDDEFINE
*
*-- EndDefine: button
**************************************************
If we exchange an apple, we both get an apple.
But if we exchange an idea, we both get 2 ideas, cool...


Gérald Santerre
Independant programmer - internet or intranet stuff - always looking for contracts big or small :)
http://www.siteintranet.qc.ca
Previous
Reply
Map
View

Click here to load this message in the networking platform