Transparent Labels?
Transparent Labels?
I know that you are able to change the background-color with some callback-commands.
Is it possible to create Labels with real transparent background?
Is it possible to create Labels with real transparent background?
Re: Transparent Labels?
> Is it possible to create Labels with real transparent background?
Do you mean something like this:
viewtopic.php?t=9202
Do you mean something like this:
viewtopic.php?t=9202
Last edited by PB on Tue Jun 29, 2004 12:41 pm, edited 1 time in total.
Transparrent means you can look through them.-
If you place an image then places a label on top:
If the label(textgadget) is transparrent (opacity) then you cant see the box sorrouning the text. If it is solid, you see the box.
What i mean is the background of a textgadget would be nice to have transperrent.
If you place an image then places a label on top:
If the label(textgadget) is transparrent (opacity) then you cant see the box sorrouning the text. If it is solid, you see the box.
What i mean is the background of a textgadget would be nice to have transperrent.
I think they're looking for something like this, only using TextGadget rather than the DrawText as shown in image.pb example.
Code: Select all
;
; ------------------------------------------------------------
;
; PureBasic - Image example file
;
; (c) 2001 - Fantaisie Software
;
; ------------------------------------------------------------
;
Procedure WindowCallback(WindowID, Message, lParam, wParam)
If Message = #WM_PAINT
StartDrawing(WindowOutput())
DrawImage(UseImage(0), 20, 10)
DrawImage(UseImage(1), 320, 80)
DrawImage(UseImage(2), 320, 200)
StopDrawing()
EndIf
ProcedureReturn #PB_ProcessPureBasicEvents
EndProcedure
If OpenWindow(0, 100, 100, 500, 300, #PB_Window_SystemMenu, "PureBasic - Image")
Gosub CreateImage
SetWindowCallback(@WindowCallback())
Repeat
EventID = WaitWindowEvent()
Until EventID = #PB_EventCloseWindow ; If the user has pressed on the close button
EndIf
End ; All the opened windows are closed automatically by PureBasic
;
; Some 2D graphics functions...
;
CreateImage:
If CreateImage(0, 255, 255)
StartDrawing(ImageOutput())
For k=0 To 255
FrontColor(k,0, k) ; a rainbow, from black to pink
Line(0, k, 255, 0)
Next
DrawingMode(1)
Locate(40, 50)
FrontColor(255,255,255) ; print the text to white !
DrawText("An image created easely...")
StopDrawing() ; This is absolutely needed when the drawing operations are finished !!! Never forget it !
EndIf
CopyImage(0, 1)
ResizeImage(1, 100, 100)
GrabImage(0, 2, 100, 60, 150, 40)
Return What goes around comes around.
PB 5.21 LTS (x86) - Windows 8.1
PB 5.21 LTS (x86) - Windows 8.1
@sparkie is right.
In VB you can just turn label transperrency on and then the labels are transperrent.
Can you use drawtext on a normal window with buttongadgets and that stuff? This is most for use when drawing on images, thats why drawtext() can be used, but if you could just make the textgadgets transperrent, it would be easier.
In VB you can just turn label transperrency on and then the labels are transperrent.
Can you use drawtext on a normal window with buttongadgets and that stuff? This is most for use when drawing on images, thats why drawtext() can be used, but if you could just make the textgadgets transperrent, it would be easier.
> I'll post some code that does this later on today...
Too late, I just modified your (and Danilo's) code to do it
Too late, I just modified your (and Danilo's) code to do it
Code: Select all
; Original code by Danilo and Num3 (thanks, guys).
; Modified by PB to get a transparent TextGadget.
Global TextGadgetBackground,TextGadgetForeground
TextGadgetBackground=GetStockObject_(#HOLLOW_BRUSH)
TextGadgetForeground=RGB($FF,$00,$00)
Procedure WinProc(hWnd,Msg,wParam,lParam)
If Msg=#WM_CTLCOLORSTATIC And lParam=GadgetID(0)
SetBkMode_(wParam,#TRANSPARENT)
SetTextColor_(wParam,TextGadgetForeground)
ProcedureReturn TextGadgetBackground
Else
ProcedureReturn #PB_ProcessPureBasicEvents
EndIf
EndProcedure
OpenWindow(0,0,0,250,100,#PB_Window_SystemMenu|#PB_Window_ScreenCentered,"test")
SetWindowCallback(@WinProc()) : CreateGadgetList(WindowID())
TextGadget(0,0,0,225,13,"This TextGadget has a transparent background")
r=LoadImage(1,"Babe.bmp") : ImageGadget(1,0,0,0,0,r)
Repeat : Until WaitWindowEvent()=#PB_EventCloseWindow
DeleteObject_(TextGadgetBackground)
HELP! - this only works on the first drawing of the window.
If you minimize or the window gets hidden behind another window, then the text either disappears or the Window background show thru as the TextGadget background instead of the Image.
I have searched these forums and tried all of the code examples, but cannot find a solution when you load a bitmap from a file. I need to load a bitmap from a file, not draw one on the fly or draw a gradient. I really need a solution to draw (and re-draw if necessary) a transparent text gadget ontop of a real bitmap.
please help.
Thanks in advance
If you minimize or the window gets hidden behind another window, then the text either disappears or the Window background show thru as the TextGadget background instead of the Image.
I have searched these forums and tried all of the code examples, but cannot find a solution when you load a bitmap from a file. I need to load a bitmap from a file, not draw one on the fly or draw a gradient. I really need a solution to draw (and re-draw if necessary) a transparent text gadget ontop of a real bitmap.
please help.
Thanks in advance
- netmaestro
- PureBasic Bullfrog

- Posts: 8452
- Joined: Wed Jul 06, 2005 5:42 am
- Location: Fort Nelson, BC, Canada
Code: Select all
; Original code by Danilo and Num3 (thanks, guys).
; Modified by PB to get a transparent TextGadget.
Global TextGadgetBackground,TextGadgetForeground
TextGadgetBackground=GetStockObject_(#HOLLOW_BRUSH)
TextGadgetForeground=RGB($FF,$00,$00)
Procedure WinProc(hWnd,Msg,wParam,lParam)
If Msg=#WM_CTLCOLORSTATIC And lParam=GadgetID(0)
SetBkMode_(wParam,#TRANSPARENT)
SetTextColor_(wParam,TextGadgetForeground)
ProcedureReturn TextGadgetBackground
Else
ProcedureReturn #PB_ProcessPureBasicEvents
EndIf
EndProcedure
OpenWindow(0,0,0,250,100,"test",#PB_Window_SystemMenu|#PB_Window_ScreenCentered)
SetWindowCallback(@WinProc()) : CreateGadgetList(WindowID(0))
TextGadget(0,0,0,225,13,"This TextGadget has a transparent background")
hBrush = CreatePatternBrush_(LoadImage(1,"c:\purebasiclogo.bmp"))
SetClassLong_(WindowID(0), #GCL_HBRBACKGROUND, hBrush)
InvalidateRect_(WindowID(0), 0, #True)
Repeat : Until WaitWindowEvent()=#PB_Event_CloseWindow
DeleteObject_(TextGadgetBackground)
BERESHEIT
ROCK & ROLL! That works. Thanks netmaestro, you're awesome. I don't care WHAT Num3 says about you.
Why isn't this in the CodeArchiv? hey Andre....
For others who run into the same thing, the operative code here is to use the following instead of an ImageGadget:
Cheers and thanks for saving my day.
Why isn't this in the CodeArchiv? hey Andre....
For others who run into the same thing, the operative code here is to use the following instead of an ImageGadget:
Code: Select all
hBrush = CreatePatternBrush_(LoadImage(1,"c:\purebasiclogo.bmp"))
SetClassLong_(WindowID(0), #GCL_HBRBACKGROUND, hBrush)
InvalidateRect_(WindowID(0), 0, #True)
-
Edwin Knoppert
- Addict

- Posts: 1073
- Joined: Fri Apr 25, 2003 11:13 pm
- Location: Netherlands
- Contact:




