It is currently Wed Jun 19, 2013 5:51 am

All times are UTC + 1 hour




Post new topic Reply to topic  [ 2 posts ] 
Author Message
 Post subject:
PostPosted: Fri Oct 19, 2001 11:18 pm 
Offline
PureBasic Guru
PureBasic Guru

Joined: Tue Apr 22, 2003 7:42 pm
Posts: 16777210
Restored from previous forum. Originally posted by Franco.

This is the last TextWindow example; I promise...
But I had this idea... why not?

Code:
; (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$)
  InitGadget(0)
  If LoadImage(0, BMP$)
    Structure Rect
      Left.l
      Top.l
      Right.l
      Bottom.l
    EndStructure

    RectRegion.Rect

    If OpenWindow(ID, GetSystemMetrics_(#SM_CXSCREEN), GetSystemMetrics_(#SM_CYSCREEN), Width, Height,#PB_Window_SystemMenu|#WS_POPUP, Text$)
      If CreateGadgetList(WindowID())
        SetForegroundWindow_(WindowID())
        WindowDC= GetDC_(WindowID())
        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(),WindowDC)
        SetWindowRgn_(WindowID(),Region2,1)
        SelectObject_(WindowDC,Font)
        SetWindowPos_(WindowID(),#HWND_TOPMOST,(GetSystemMetrics_(#SM_CXSCREEN)/2)-(WindowWidth()/2),(GetSystemMetrics_(#SM_CYSCREEN)/2)-(WindowHeight()/2),Width,Height,0)
        ImageGadget(0, ((Width)/2)-(ImageWidth()/2), ((Height)/2)-(ImageHeight()/2), 0, 0, UseImage(0))
        WindowEvent() : WindowEvent() : WindowEvent() ; Thanks to Mr.Skunk :)
      EndIf
    EndIf
  Else
    ProcedureReturn 0
  EndIf
  ProcedureReturn 1
EndProcedure

If OpenTextImageWindow(0,130,560,300,#RGN_XOR,"Verdana","PureBasic","c:\windows\clouds.bmp")
  Repeat
    EventID = WaitWindowEvent()
  Until EventID = #PB_EventCloseWindow
EndIf





Have a nice day...
Franco


Top
 Profile  
 
 Post subject:
PostPosted: Fri Oct 19, 2001 11:22 pm 
Offline
PureBasic Guru
PureBasic Guru

Joined: Tue Apr 22, 2003 7:42 pm
Posts: 16777210
Restored from previous forum. Originally posted by Franco.

And here is the example code:

Code:
; (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$)
  InitGadget(0)
  If LoadImage(0, BMP$)
    Structure Rect
      Left.l
      Top.l
      Right.l
      Bottom.l
    EndStructure

    RectRegion.Rect

    If OpenWindow(ID, GetSystemMetrics_(#SM_CXSCREEN), GetSystemMetrics_(#SM_CYSCREEN), Width, Height, #WS_POPUP, Text$)
      If CreateGadgetList(WindowID())
        SetForegroundWindow_(WindowID())
        WindowDC= GetDC_(WindowID())
        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(),WindowDC)
        SetWindowRgn_(WindowID(),Region2,1)
        SelectObject_(WindowDC,Font)
        SetWindowPos_(WindowID(),#HWND_TOPMOST,(GetSystemMetrics_(#SM_CXSCREEN)/2)-(WindowWidth()/2),(GetSystemMetrics_(#SM_CYSCREEN)/2)-(WindowHeight()/2),Width,Height,0)
        ImageGadget(0, ((Width)/2)-(ImageWidth()/2), ((Height)/2)-(ImageHeight()/2), 0, 0, UseImage(0))
        WindowEvent() : WindowEvent() : WindowEvent() ; Thanks to Mr.Skunk :)
      EndIf
    EndIf
  EndIf
EndProcedure

OpenTextImageWindow(0,130,560,300,#RGN_XOR,"Verdana","PureBasic","c:\windows\clouds.bmp")
Delay(1000)
CloseWindow(0)
OpenTextImageWindow(1,100,580,100,#RGN_XOR,"Verdana","Feel The Pure","c:\windows\clouds.bmp")
Delay(1000)
CloseWindow(1)
OpenTextImageWindow(2,150,560,1500,#RGN_AND,"Verdana","POWER","c:\windows\clouds.bmp")
Delay(2000)
CloseWindow(2)


That's it!




Have a nice day...
Franco


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ] 

All times are UTC + 1 hour


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  

 


Powered by phpBB © 2008 phpBB Group
subSilver+ theme by Canver Software, sponsor Sanal Modifiye