Restored from previous forum. Originally posted by Franco.
This is the last TextWindow example; I promise...
But I had this idea... why not?
Code: Select all
; (c) 2001 - Franco's template - absolutely freeware
; OpenTextImageWindow(ID,Height,Width,Thickness,Flag,Font$,Text$,BMP$)
; Well, the big part is to adjust Height, Width and Thickness to the lenght of the String and the Font.
; You will see :)
;
; Height = Window Height
; Width = Window Width
; Thickness =FontThickness
; Flag can be: #RGN_AND or #RGN_XOR
Procedure OpenTextImageWindow(ID,Height,Width,Thickness,Flag,Font$,Text$,BMP$)
If LoadImage(0, BMP$)
If CreateImage(1, Width, Height) And StartDrawing(ImageOutput(1))
For x = 0 To Round(width/ImageWidth(0), #PB_Round_Up)
For y = 0 To Round(height/ImageHeight(0), #PB_Round_Up)
DrawImage(ImageID(0), x * ImageWidth(0), y * ImageHeight(0))
Next y
Next x
Else
ProcedureReturn 0
EndIf
StopDrawing()
RectRegion.Rect
If OpenWindow(ID, GetSystemMetrics_(#SM_CXSCREEN), GetSystemMetrics_(#SM_CYSCREEN), Width, Height, Text$,#PB_Window_SystemMenu|#WS_POPUP)
SetForegroundWindow_(WindowID(ID))
WindowDC= GetDC_(WindowID(ID))
Font = SelectObject_(WindowDC,CreateFont_(Height,0,0,0,Thickness,0,0,0,#ANSI_CHARSET,#OUT_CHARACTER_PRECIS,#CLIP_DEFAULT_PRECIS,#PROOF_QUALITY,0,Font$))
BeginPath_(WindowDC)
TextOut_(WindowDC,0,0,Text$,Len(Text$))
EndPath_(WindowDC)
Region1 = PathToRegion_(WindowDC)
GetRgnBox_(Region1,RectRegion)
Region2 = CreateRectRgnIndirect_(RectRegion)
CombineRgn_(Region2,Region2,Region1,Flag)
DeleteObject_(Region1)
ReleaseDC_(WindowID(ID),WindowDC)
SetWindowRgn_(WindowID(ID),Region2,1)
SelectObject_(WindowDC,Font)
SetWindowPos_(WindowID(ID),#HWND_TOPMOST,(GetSystemMetrics_(#SM_CXSCREEN)/2)-(WindowWidth(ID)/2),(GetSystemMetrics_(#SM_CYSCREEN)/2)-(WindowHeight(ID)/2),Width,Height,0)
ImageGadget(0, ((Width)/2)-(ImageWidth(1)/2), ((Height)/2)-(ImageHeight(1)/2), 0, 0, ImageID(1))
WindowEvent() : WindowEvent() : WindowEvent() ; Thanks to Mr.Skunk :)
EndIf
Else
ProcedureReturn 0
EndIf
ProcedureReturn 1
EndProcedure
If OpenTextImageWindow(0,130,560,300,#RGN_XOR,"Verdana","PureBasic","c:\windows\Santa Fe Stucco.bmp") ;clouds.bmp
Repeat
EventID = WaitWindowEvent()
Until EventID = #PB_Event_CloseWindow
EndIf
Have a nice day...
Franco