Straight forward with Right mouse click
# 1:
Code: Select all
Procedure PBbutton(id,x,y,w,h,bcolor,fcolor,txt1.s,txt2.s,txt3.s,txt4.s,txt5.s)
img = CreateImage(#PB_Any,w,h,24,bcolor)
StartDrawing(ImageOutput(img))
DrawingMode(#PB_2DDrawing_Transparent)
DrawingFont(#PB_Default)
DrawText(5,5,txt1,fcolor)
length = TextWidth(txt2)
DrawText(w-5-length,5,txt2,fcolor)
height = TextHeight(txt3)
DrawText(5,h-5-height,txt3,fcolor)
length = TextWidth(txt4)
DrawText(w-5-length,h-5-height,txt4,fcolor)
length = TextWidth(txt5)
DrawText(w/2-length/2,h/2-height/2,txt5,fcolor)
StopDrawing()
ButtonImageGadget(id, x,y,w,h, ImageID(img))
EndProcedure
If OpenWindow(0, 0, 0, 200, 200, "ButtonImageGadget", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
PBbutton(0,10,10,100,100,$00FFFF,$0000FF,"Paid","32","156","GF","Push me")
Repeat
Select WaitWindowEvent()
Case #PB_Event_CloseWindow
Quit = 1
Case #WM_RBUTTONDOWN,#WM_RBUTTONUP
GetCursorPos_ (@p.POINT)
ScreenToClient_ (WindowID(0), @p)
Select ChildWindowFromPoint_ (WindowID(0), p\y<< 32+p\x)
Case GadgetID(0)
Debug "PBbutton got the Focus"
EndSelect
EndSelect
Until Quit = 1
EndIf
# 2:
Code: Select all
Procedure PBbutton(id,x,y,w,h,bcolor,fcolor,txt1.s,txt2.s,txt3.s,txt4.s,txt5.s)
img = CreateImage(#PB_Any,w,h,24,bcolor)
StartDrawing(ImageOutput(img))
DrawingMode(#PB_2DDrawing_Transparent)
DrawingFont(#PB_Default)
DrawText(5,5,txt1,fcolor)
length = TextWidth(txt2)
DrawText(w-5-length,5,txt2,fcolor)
height = TextHeight(txt3)
DrawText(5,h-5-height,txt3,fcolor)
length = TextWidth(txt4)
DrawText(w-5-length,h-5-height,txt4,fcolor)
length = TextWidth(txt5)
DrawText(w/2-length/2,h/2-height/2,txt5,fcolor)
StopDrawing()
ButtonImageGadget(id, x,y,w,h, ImageID(img))
EndProcedure
If OpenWindow(0, 0, 0, 200, 200, "ButtonImageGadget", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
PBbutton(0,10,10,100,100,$00FFFF,$0000FF,"Paid","32","156","GF","Push me")
Repeat
Select WaitWindowEvent()
Case #PB_Event_CloseWindow
Quit = 1
Case #WM_RBUTTONDOWN,#WM_RBUTTONUP
GetCursorPos_ (@p.POINT)
ScreenToClient_ (WindowID(0), @p)
Select ChildWindowFromPoint_ (WindowID(0), p\y<< 32+p\x)
Case GadgetID(0)
FreeGadget(0)
PBbutton(0,10,10,100,100,$F0F0F0,$FF0000,"Paid","3200","156","GFFF","Push me #2")
EndSelect
EndSelect
Until Quit = 1
EndIf
# 3:
Using CanvasGadget()
Code: Select all
Procedure PBbutton(id,x,y,w,h,bcolor,fcolor,txt1.s,txt2.s,txt3.s,txt4.s,txt5.s)
img = CreateImage(#PB_Any,w,h,24,bcolor)
StartDrawing(ImageOutput(img))
DrawingMode(#PB_2DDrawing_Outlined)
Box(0,0,w,h,$0)
DrawingMode(#PB_2DDrawing_Transparent)
DrawingFont(#PB_Default)
DrawText(5,5,txt1,fcolor)
length = TextWidth(txt2)
DrawText(w-5-length,5,txt2,fcolor)
height = TextHeight(txt3)
DrawText(5,h-5-height,txt3,fcolor)
length = TextWidth(txt4)
DrawText(w-5-length,h-5-height,txt4,fcolor)
length = TextWidth(txt5)
DrawText(w/2-length/2,h/2-height/2,txt5,fcolor)
StopDrawing()
CanvasGadget(id, x,y,w,h)
SetGadgetAttribute(id,#PB_Canvas_Image ,ImageID(img))
EndProcedure
If OpenWindow(0, 0, 0, 200, 200, "ButtonImageGadget", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
PBbutton(0,10,10,100,100,$00FFFF,$0000FF,"Paid","32","156","GF","Push me")
Repeat
Select WaitWindowEvent()
Case #PB_Event_CloseWindow
Quit = 1
Case #WM_RBUTTONDOWN,#WM_RBUTTONUP
GetCursorPos_ (@p.POINT)
ScreenToClient_ (WindowID(0), @p)
Select ChildWindowFromPoint_ (WindowID(0), p\y<< 32+p\x)
Case GadgetID(0)
FreeGadget(0)
PBbutton(0,10,10,100,100,$F0F0F0,$FF0000,"Paid","3200","156","GFFF","Push me #2")
EndSelect
EndSelect
Until Quit = 1
EndIf