Hi,
how can i place a TextGadget on top of an ImageGadget ?
Cheers
How to place text on image
-
- User
- Posts: 13
- Joined: Sun Jul 18, 2004 2:24 pm
- Location: Munich, Germany
mm, first I want to apologize for any assumptions I make in this reply 
Before you set the image in the imagegadget and after you load the image, you should be able to do something like UseImage(ImageVar), then call StartDrawing(ImageOutput()). Then call ... Locate(x,y,) where you want your text to be, then DrawTexT(TextToDraw).


Before you set the image in the imagegadget and after you load the image, you should be able to do something like UseImage(ImageVar), then call StartDrawing(ImageOutput()). Then call ... Locate(x,y,) where you want your text to be, then DrawTexT(TextToDraw).

-
- User
- Posts: 13
- Joined: Sun Jul 18, 2004 2:24 pm
- Location: Munich, Germany
pickelrobert wrote:how can i place a TextGadget on top of an ImageGadget ?
Code: Select all
; --> Create a brush for our TextGadget. This is needed in #WM_CTLCOLORSTATIC
textBGcolor = RGB(155, 200, 155)
textBGbrush = CreateSolidBrush_(textBGcolor)
; --> Set our text color
textFGcolor = RGB(0, 100, 0)
Global textBGbrush, textFGcolor
; --> Create image
CreateImage(0, 300, 200)
StartDrawing(ImageOutput())
Box(0, 0, 300, 200, textBGcolor)
StopDrawing()
; --> Window Callback
Procedure myWindowCallback(hwnd, msg, wparam, lParam)
result = #PB_ProcessPureBasicEvents
Select msg
Case #WM_CTLCOLORSTATIC
; --> Is this our TextGadget
If IsGadget(0) And lParam = GadgetID(0)
; --> If so, then color the text and background
SetTextColor_(wparam, textFGcolor)
SetBkMode_(wparam, #TRANSPARENT)
result = textBGbrush
EndIf
EndSelect
ProcedureReturn result
EndProcedure
If OpenWindow(0, 0, 0, 400, 300, #PB_Window_SystemMenu | #PB_Window_ScreenCentered, "Test") And CreateGadgetList(WindowID(0))
SetWindowCallback(@myWindowCallback())
; --> TextGadget z-order is on top of ImageGaget
TextGadget(0, 50, 140, 300, 20, "TextGadget on top of ImageGadget", #PB_Text_Center)
ImageGadget(1, 50, 50, 300, 200, UseImage(0))
; --> Let gadgets redraw on top of ImageGadget by setting #WS_CLIPSIBLINGS for ImageGadget
SetWindowLong_(GadgetID(1), #GWL_STYLE, GetWindowLong_(GadgetID(1), #GWL_STYLE) | #WS_CLIPSIBLINGS)
Repeat
event = WaitWindowEvent()
Until event = #PB_Event_CloseWindow
DeleteObject_(textBGbrush)
EndIf
What goes around comes around.
PB 5.21 LTS (x86) - Windows 8.1
PB 5.21 LTS (x86) - Windows 8.1