; by Dobro fenetre invisible
; Code Transformé pour Purebasic V4
Declare WindowCallback( WindowID ,message,wParam,lParam)
Declare Open_Window()
;- Window Constants
;
Enumeration
#Window
EndEnumeration
;- Gadget Constants
;
Enumeration
#Button_ok
#Text_0
#Image
#Image2
EndEnumeration
#CAPTUREBLT = $40000000
;- Fonts
;
Global FontID1
FontID1 = LoadFont (1, "Comic Sans MS" , 14, #PB_Font_Bold )
ExamineDesktops ()
; *************************************** Copie du fond ecran dans image (inspiré du Soldat inconu )***************
CreateImage ( #Image , DesktopWidth (0), DesktopHeight (0))
dc_bur = GetDC_ (0)
DC_im = StartDrawing ( ImageOutput ( #Image ))
BitBlt_ (DC_im,0,0 , DesktopWidth (0), DesktopHeight (0), dc_bur , 0,0 , #SRCPAINT|#CAPTUREBLT ) ; recup le bureau dans image
StopDrawing ()
ReleaseDC_ (0, dc_bur)
; ********************************************************************************************************************************
Open_Window() ; on ouvre la fenetre
; boucle principale !
Repeat
; *********************************Copie l'image dans fenetre *******************************************
Form1= WindowID ( #Window )
bitmap= ImageID ( #Image )
ps.PAINTSTRUCT
hdc= BeginPaint_ (Form1,ps)
hdcMem= CreateCompatibleDC_ (hdc)
SelectObject_ (hdcMem,bitmap)
BitBlt_ (hdc,0,0, WindowWidth ( #Window ), WindowHeight ( #Window ),hdcMem, WindowX ( #Window )+4, WindowY ( #Window ) +30, #SRCCOPY|#CAPTUREBLT )
ReleaseDC_ ( WindowID (0),hdc)
DeleteDC_ (hdcMem)
DeleteObject_ (hdcMem)
EndPaint_ (Form1,ps)
; *******************************************************************************************************************
Event = WaitWindowEvent ()
If Event = #PB_Event_Gadget
;Debug "WindowID: " + Str(EventWindowID())
GadgetID = EventGadget ()
If GadgetID = #Button_ok
End
EndIf
EndIf
;
Until Event = #PB_Event_CloseWindow
Procedure Open_Window()
If OpenWindow ( #Window , 321, 217, 257, 200, "by Dobro" , #PB_Window_SystemMenu | #PB_Window_SizeGadget | #PB_Window_TitleBar )
SetWindowColor ( #Window , RGB (0,0,0))
SetWindowCallback (@WindowCallback()) ; un callback pour que le dessin reste sur la fenetre (repaint)
If CreateGadgetList ( WindowID ( #Window ))
ButtonGadget ( #Button_ok , 102, 138, 66, 33, "oK" )
TextGadget ( #Text_0 , 57, 15, 132, 63, "fenetre Transparente" )
SetGadgetFont ( #Text_0 , FontID1)
EndIf
EndIf
EndProcedure
Procedure WindowCallback( WindowID ,message,wParam,lParam)
res= #PB_ProcessPureBasicEvents
If message= #WM_PAINT ; on repaint la fenetre
; *********** dessine un box noir pour effacer *************
memx= WindowWidth ( #Window ) :memy= WindowHeight ( #Window )
StartDrawing ( WindowOutput ( #Window ))
Box (0,0,memx,memy, RGB (0,0,0))
StopDrawing ()
; ******************************************************
; *********************************Copie l'image dans fenetre *******************************************
Form1= WindowID ( #Window )
bitmap= ImageID ( #Image )
ps.PAINTSTRUCT
hdc= BeginPaint_ (Form1,ps)
hdcMem= CreateCompatibleDC_ (hdc)
SelectObject_ (hdcMem,bitmap)
BitBlt_ (hdc,0,0, WindowWidth ( #Window ), WindowHeight ( #Window ),hdcMem, WindowX ( #Window )+4, WindowY ( #Window ) +30, #SRCCOPY|#CAPTUREBLT )
ReleaseDC_ ( WindowID ( #Window ),hdc)
DeleteDC_ (hdcMem)
DeleteObject_ (hdcMem)
EndPaint_ (Form1,ps)
; *******************system du changement de taille*** on change la taille de la fenetre pour forcer un redraw ************
; memx= WindowWidth (#Window ) :memy= WindowHeight (#Window )
; ResizeWindow (#Window ,#PB_Ignore,#PB_Ignore, memx,0)
; ResizeWindow (#Window ,#PB_Ignore,#PB_Ignore,memx, memy)
; *******************************************************************************************************************
ProcedureReturn #True
ElseIf message= #WM_MOVE ; au cas ou l'on bouge la fenetre
; ********************************************************************************************************************************
; *********************************Copie l'image dans fenetre *******************************************
Form1= WindowID ( #Window )
bitmap= ImageID ( #Image )
ps.PAINTSTRUCT
hdc= BeginPaint_ (Form1,ps)
hdcMem= CreateCompatibleDC_ (hdc)
SelectObject_ (hdcMem,bitmap)
BitBlt_ (hdc,0,0, WindowWidth ( #Window ), WindowHeight ( #Window ),hdcMem, WindowX ( #Window )+4, WindowY ( #Window ) +30, #SRCCOPY|#CAPTUREBLT )
DeleteDC_ (hdcMem)
DeleteObject_ (hdcMem)
EndPaint_ (Form1,ps)
; ******************************** on change la taille de la fenetre pour forcer un redraw ************
; tester ça : RedrawWindow_(WindowID(#FormStartER), 0, 0, #RDW_INVALIDATE|#RDW_UPDATENOW)
; ou ça : res = UpdateWindow_(WindowID(#FormStartER))
;res = UpdateWindow_(WindowID( #Window))
memx= WindowWidth ( #Window ) :memy= WindowHeight ( #Window )
ResizeWindow ( #Window , #PB_Ignore , #PB_Ignore , memx,0)
ResizeWindow ( #Window , #PB_Ignore , #PB_Ignore ,memx, memy)
;RedrawWindow_(WindowID(#Window), 0, 0, #RDW_INVALIDATE|#RDW_UPDATENOW)
; *******************************************************************************************************************
; colorisation du textgedget
ElseIf message= #WM_CTLCOLORSTATIC And lParam = GadgetID ( #Text_0 )
xg= GadgetX ( #Text_0 )
yg= GadgetY ( #Text_0 )
StartDrawing ( ImageOutput ( #image ))
Couleur = RGB ($0,$0,$0)
StopDrawing ()
TextGadgetBackground = CreateSolidBrush_ (Couleur)
TextGadgetForeground = RGB ($FF,$FF,$00) ; ici la couleur du text !!!
SetTextColor_ (wParam,TextGadgetForeground)
SetBkColor_ (wParam,Couleur ) ; ici la couleur du fond !!!
ProcedureReturn TextGadgetBackground
ProcedureReturn #True
Else
ProcedureReturn #PB_ProcessPureBasicEvents ; rend la main !
EndIf
EndProcedure