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

PictureButton / CommandButton 1

Status
Not open for further replies.

knbarton

Programmer
Jun 21, 2004
3
US
I need to place a picture along with text on a CommandButton / PictureButton. When I put a picture on a picture button the text shows on top of the picture. Does anyone have any ideas on how to place a picture to the left and text to the right on a button or can point me to someone who has created a custom control to do this?
 
Create a bitmap with the picture and the text the way you want it and then use that on the picturebutton control. Leave the text property blank.
 
You need this two objects:
Make simply import.

Code:
$PBExportHeader$u_timing.sru
forward
global type u_timing from timing
end type
end forward

global type u_timing from timing
end type
global u_timing u_timing

on u_timing.create
call super::create
TriggerEvent( this, "constructor" )
end on

on u_timing.destroy
TriggerEvent( this, "destructor" )
call super::destroy
end on

Code:
$PBExportHeader$u_pictbtn.sru
forward
global type u_pictbtn from userobject
end type
type p_1 from picture within u_pictbtn
end type
type st_1 from statictext within u_pictbtn
end type
type st_2 from statictext within u_pictbtn
end type
type io_timing from u_timing within u_pictbtn
end type
end forward

global type u_pictbtn from userobject
integer width = 654
integer height = 212
long backcolor = 67108864
string text = "none"
borderstyle borderstyle = styleraised!
long tabtextcolor = 33554432
long picturemaskcolor = 536870912
event ue_open pbm_open
event ue_clicked ( )
event ue_unclick ( )
p_1 p_1
st_1 st_1
st_2 st_2
io_timing io_timing
end type
global u_pictbtn u_pictbtn

type variables
string	is_pict_path
string	is_text

end variables

event ue_open;st_1.text = is_text
p_1.PictureName = is_pict_path

end event

event ue_clicked;st_2.BorderStyle = StyleLowered! 
st_1.x += 5
st_1.y += 5
p_1.x += 5
p_1.y += 5

io_timing.start (0.1)



		
end event

event ue_unclick;io_timing.stop ()
st_2.BorderStyle = StyleRaised! 
st_1.x -= 5
st_1.y -= 5
p_1.x -= 5
p_1.y -= 5

end event

on u_pictbtn.create
this.p_1=create p_1
this.st_1=create st_1
this.st_2=create st_2
this.io_timing=create io_timing
this.Control[]={this.p_1,&
this.st_1,&
this.st_2}
end on

on u_pictbtn.destroy
destroy(this.p_1)
destroy(this.st_1)
destroy(this.st_2)
destroy(this.io_timing)
end on

type p_1 from picture within u_pictbtn
integer x = 64
integer y = 60
integer width = 87
integer height = 76
boolean originalsize = true
string picturename = ""
boolean focusrectangle = false
end type

event clicked;parent.event ue_clicked ()
end event

type st_1 from statictext within u_pictbtn
integer x = 160
integer y = 68
integer width = 439
integer height = 60
integer textsize = -8
integer weight = 400
fontcharset fontcharset = ansi!
fontpitch fontpitch = variable!
fontfamily fontfamily = swiss!
string facename = "MS Sans Serif"
long textcolor = 33554432
long backcolor = 67108864
string text = "none"
boolean focusrectangle = false
end type

event clicked;parent.event ue_clicked ()
end event

type st_2 from statictext within u_pictbtn
integer x = 9
integer y = 8
integer width = 645
integer height = 196
integer textsize = -8
integer weight = 400
fontcharset fontcharset = ansi!
fontpitch fontpitch = variable!
fontfamily fontfamily = swiss!
string facename = "MS Sans Serif"
long textcolor = 33554432
long backcolor = 67108864
boolean border = true
borderstyle borderstyle = styleraised!
boolean focusrectangle = false
end type

event clicked;parent.event ue_clicked ()
end event

type io_timing from u_timing within u_pictbtn descriptor "pb_nvo" = "true" 
end type

on io_timing.create
call super::create
end on

on io_timing.destroy
call super::destroy
end on

event timer;call super::timer;parent.event ue_unclick()
end event

 
Thank you for the ideas. I have everything working except for the sytleraised when the mouse is clicked and then moves off of the button.
 
New version.

Now you need no timing-object. And a simple leftbutton-click produced button lowering too.

Code:
$PBExportHeader$u_pictbtn.sru
forward
global type u_pictbtn from userobject
end type
type p_1 from picture within u_pictbtn
end type
type st_1 from statictext within u_pictbtn
end type
type st_2 from statictext within u_pictbtn
end type
end forward

global type u_pictbtn from userobject
integer width = 498
integer height = 184
long backcolor = 67108864
string text = "none"
borderstyle borderstyle = styleraised!
long tabtextcolor = 33554432
long picturemaskcolor = 536870912
event ue_open pbm_open
event ue_btndown ( )
event ue_btnup ( )
event ue_clicked ( )
event clicked ( )
p_1 p_1
st_1 st_1
st_2 st_2
end type
global u_pictbtn u_pictbtn

type variables
string		is_pict_path
string		is_text
protected boolean	ib_clicked
end variables
event ue_open;st_1.text = is_text
p_1.PictureName = is_pict_path

end event
event ue_btndown;st_2.BorderStyle = StyleLowered! 
st_1.x += 5
st_1.y += 5
p_1.x += 5
p_1.y += 5

ib_clicked = true



		
end event

event ue_btnup;if ib_clicked then
	st_2.BorderStyle = StyleRaised! 
	st_1.x -= 5
	st_1.y -= 5
	p_1.x -= 5
	p_1.y -= 5
	ib_clicked = false
end if	

end event
on u_pictbtn.create
this.p_1=create p_1
this.st_1=create st_1
this.st_2=create st_2
this.Control[]={this.p_1,&
this.st_1,&
this.st_2}
end on

on u_pictbtn.destroy
destroy(this.p_1)
destroy(this.st_1)
destroy(this.st_2)
end on

type p_1 from picture within u_pictbtn
event lbuttondown pbm_lbuttondown
event lbuttonup pbm_lbuttonup
integer x = 69
integer y = 48
integer width = 87
integer height = 76
boolean originalsize = true
string picturename = "D:\Projekte\Resources\Bmp\ARR_DN1.bmp"
boolean focusrectangle = false
end type

event lbuttondown;parent.event ue_btndown()
end event

event lbuttonup;parent.event ue_btnup()
end event

event clicked;parent.event clicked ()
end event

type st_1 from statictext within u_pictbtn
event lbuttonup pbm_lbuttonup
event lbuttondown pbm_lbuttondown
integer x = 165
integer y = 56
integer width = 265
integer height = 60
integer textsize = -8
integer weight = 400
fontcharset fontcharset = ansi!
fontpitch fontpitch = variable!
fontfamily fontfamily = swiss!
string facename = "MS Sans Serif"
long textcolor = 33554432
long backcolor = 67108864
string text = "none"
boolean focusrectangle = false
end type

event lbuttonup;parent.event ue_btnup()
end event

event lbuttondown;parent.event ue_btndown()
end event

event clicked;parent.event clicked ()
end event

type st_2 from statictext within u_pictbtn
event lbuttondown pbm_lbuttondown
event lbuttonup pbm_lbuttonup
integer x = 18
integer y = 16
integer width = 462
integer height = 152
integer textsize = -8
integer weight = 400
fontcharset fontcharset = ansi!
fontpitch fontpitch = variable!
fontfamily fontfamily = swiss!
string facename = "MS Sans Serif"
long textcolor = 33554432
long backcolor = 67108864
boolean border = true
borderstyle borderstyle = styleraised!
boolean focusrectangle = false
end type

event lbuttondown;parent.event ue_btndown()

end event

event lbuttonup;parent.event ue_btnup()

end event

event clicked;parent.event clicked()
end event
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top