There must be several ways out there, but I am looking for the easiest and still well way, maybe you can help me?
Also this could be a library entry for others who search for the same question.
How to do it?
Hi es_91. If I understand you correctly, this should do the trick:es_91 wrote:Hi, how can you make buttons that have images above the text or before the text?
Code: Select all
Enumeration
#MainWindow
#imgBtn
#img
#font
EndEnumeration
wFlags = #PB_Window_SystemMenu | #PB_Window_ScreenCentered
OpenWindow(#MainWindow, 0, 0, 200, 200, "ButtonImage", wFlags)
LoadImage(#img, "x:\xxx.bmp") ;replace with your image file
LoadFont(#font, "Times New Roman", 14)
ResizeImage(#img, 150, 150)
StartDrawing(ImageOutput(#img))
DrawingMode(#PB_2DDrawing_Transparent)
DrawingFont(FontID(#font))
FrontColor(RGB(255, 100, 100))
;BackColor(RGB(220, 220, 0))
DrawText(40, 50, "Click Me")
StopDrawing()
ButtonImageGadget(#imgBtn, 25, 25, 150, 150, ImageID(#img))
While WaitWindowEvent() ! #PB_Event_CloseWindow : Wend
Hi Tenaja. The additional code in my example was simply for adding text to the button, as requested. But basically, it was the built-in ButtonImageGadget().Tenaja wrote:Or this, using a built in command:
http://www.purebasic.com/documentation/ ... adget.html