I am relatively new to PB, although I do have some previous Basic coding experience. Currently using PB5.6
A little Windows program I am writing requires a window with a Windowed Screen. The screen has a image background with text overlaid on top of the image. The text needs to have a transparent background, which can't be done with #PB_Gadget_BackColor, so I am using the Windows API for this. So far, so good, everything is working perfectly. Now I want to change the screen's font, but the normal SetGadgetFont(1, LoadFont(0, "Arial", 12)) doesn't appear to work, probably because it needs to be set via the Windows API. Here is a snippet from my code:
The callback procedure:
Code: Select all
Procedure winCB(hWnd, uMsg, wParam, lParam)
Result = #PB_ProcessPureBasicEvents
Select uMsg
Case #WM_DRAWITEM
*lpdis.DRAWITEMSTRUCT = lParam
Select *lpdis\CtlType
Case #ODT_STATIC
hdc=GetDC_(GadgetID(1))
SetBkMode_(hdc, #TRANSPARENT)
SetTextColor_(hdc,$FFFFFF)
TextOut_(hdc, 0, 0, @Text$, Len(Text$))
EndSelect
EndSelect
ProcedureReturn Result
EndProcedure
Code: Select all
hWin=OpenWindow(10,0,0,sw+2,sw+1, "",#PB_Window_BorderLess)
SetWindowCallback(@winCB())
OpenWindowedScreen(WindowID(10),0,0,sw,sw,0,0,0)
; Other unrelated code...
ImageGadget(0, 0, 0, sw, sh, 0, 0)
TextGadget(1, (sw/2)-(Len(Text$))/2, 5, Len(Text$), 20, "",#SS_OWNERDRAW)
; Other unrelated code...
SetGadgetText(1,Text$) ; Text$ is global
Thanks & Regards
Dave