Back On ShadowText
Posted: Mon Apr 10, 2017 8:38 pm
I am back trying to expand my knowledge of PB.
The following (highly condensed) code snippet draws shadowed text under Windows, but doesn't utilize the loaded font.
Questions:
1. I got an excellent answer from RASHAD in another thread, but can this this be done without using an API callback?
2. Can PB draw shadowed text under Linux?
Dave
The following (highly condensed) code snippet draws shadowed text under Windows, but doesn't utilize the loaded font.
Questions:
1. I got an excellent answer from RASHAD in another thread, but can this this be done without using an API callback?
2. Can PB draw shadowed text under Linux?
Code: Select all
; Code adapted from forum topic:
; http://purebasic.fr/german/viewtopic.php?f=6&t=18567
;
Prototype DrawShadowText(hDC,pszText,cch,p,flags,crText,crShadow,ixOffset,iyOffset)
Lib = OpenLibrary(#PB_Any, "ComCtl32.dll")
Global DrawShadowText_.DrawShadowText = GetFunction(Lib, "DrawShadowText")
; Load the text font
LoadFont(0, "Times New Roman", 12, #PB_Font_Italic)
; Define the required items
Text$ = "This Is A Test"
w = 300 : h = 50
r.RECT : r\left = 0 : r\top = 10 : r\right = w : r\bottom = h
Flags.l = #DT_CENTER | #DT_TOP
CreateImage(1, w, h)
; Start the drawing
hDC = StartDrawing(ImageOutput(1))
Box(0, 0, w, h, #White)
DrawingFont(FontID(0)) ; This appears to be the wrong option
DrawShadowText_(hDC, @Text$, Len(Text$), r, Flags, #Blue, #Gray, 4, 3)
StopDrawing()
; Obviously the font displayed is not "Times New Roman"
OpenWindow(0, 0, 0, 400, 200, "Draw Shadow Text", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
ImageGadget(1, 50, 50, w, h, ImageID(1))
Repeat : Until WaitWindowEvent() = #PB_Event_CloseWindow