Publié : lun. 31/oct./2005 17:55
Il faut peut etre essayer d'envoyer un #WM_PRINT au bureau, donc on devrait recuperer l'image complete du bureau sans les fenetres du dessus (si c'est ce qui est voulu).
le problème c'est qu'on a aussi besoin des fenêtres... il faudrait qu'on puisse prendre l'image qui doit s'afficher normalement a l'ecran la zoomer et l'afficher ensuite...car ce programme doit être transparent et permettre d'utiliser d'autre programme...Fred a écrit :Il faut peut etre essayer d'envoyer un #WM_PRINT au bureau, donc on devrait recuperer l'image complete du bureau sans les fenetres du dessus (si c'est ce qui est voulu).
Code : Tout sélectionner
Procedure GetDesktop_Height() ; Retourne la hauteur du bureau
SystemParametersInfo_(#SPI_GETWORKAREA, 0, @desktop.RECT, 0)
ProcedureReturn desktop\bottom-desktop\top
EndProcedure
Procedure GetDesktop_Width() ; Retourne la largeur du bureau
SystemParametersInfo_(#SPI_GETWORKAREA, 0, @desktop.RECT, 0)
ProcedureReturn desktop\right-desktop\left
EndProcedure
hwnd=OpenWindow(0,0,0,GetDesktop_Width(),GetDesktop_Height(),#PB_Window_SystemMenu|#PB_Window_MinimizeGadget,"Le bureau est dans la fenêtre :)")
a = FindWindow_("progman", NullString) ; on recherche le handle du bureau
b = GetParent_(a) ; on regarde qui la mère de notre bureau
SetParent_( b, hwnd) ; On arrache le bureau à sa maman :)
Repeat
Until WaitWindowEvent()=#PB_Event_CloseWindow
SetParent_(a, b) ; On le lui rend ;)
End
tu as presque tout compris !!Gillou a écrit :Non, si j'ai bien compris Tryphoon il veut faire un programme qui affiche tout ce que tu vois sur l'écran en plus gros, même la fenêtre. Et avoir une sorte scrollbar sur les cotés de la fenêtre pour naviguer sue l'écran
Tryphon, c'est le prénom du professeur Tournesol, çaGillou a écrit :Non, si j'ai bien compris Tryphoon il veut faire un programme qui affiche...
Code : Tout sélectionner
Procedure GetDesktop_Height() ; Retourne la hauteur du bureau
SystemParametersInfo_(#SPI_GETWORKAREA, 0, @desktop.RECT, 0)
ProcedureReturn desktop\bottom-desktop\top
EndProcedure
Procedure GetDesktop_Width() ; Retourne la largeur du bureau
SystemParametersInfo_(#SPI_GETWORKAREA, 0, @desktop.RECT, 0)
ProcedureReturn desktop\right-desktop\left
EndProcedure
Procedure List_Windows() ; Retourne le nombre de fenêtres actuellement active
Global listwins
If listwins=0 : NewList wind.s() : listwins=1 : Else : ClearList(wind()) : EndIf
hWnd.l = FindWindow_( 0, 0 )
While hWnd <> 0
If GetWindowLong_(Hwnd, #GWL_STYLE) & #WS_VISIBLE = #WS_VISIBLE ; pour lister que les fenêtres visibles
If GetWindowLong_(Hwnd, #GWL_EXSTYLE) & #WS_EX_TOOLWINDOW <> #WS_EX_TOOLWINDOW ; pour lister que les fenêtres qui ne sont pas des ToolWindow ou barre d'outils
txt.s = Space(256)
GetWindowText_(hwnd, txt, 256)
If txt <> ""
AddElement(wind()) : wind()=txt
EndIf
EndIf
EndIf
hWnd = GetWindow_(hWnd, #GW_HWNDNEXT)
Wend
ProcedureReturn CountList(wind())
EndProcedure
Procedure.s Select_Windows(Number) ; Retourne le titre de la fenêtre sélectionnée (Number doit être compris entre 0 et ListWindows()-1)
If listwins=1
If CountList(wind())>0
If number=<CountList(wind())-1
SelectElement(wind(),number)
ProcedureReturn wind()
EndIf
EndIf
EndIf
EndProcedure
Structure WIN
hwnd.l
hwndParent.l
EndStructure
hwnd=OpenWindow(0,0,0,GetDesktop_Width(),GetDesktop_Height(),#PB_Window_SystemMenu|#PB_Window_MinimizeGadget,"Le bureau est dans la fenêtre :)")
a = FindWindow_("progman", vbNullString) ; on recherche le handle du bureau
b = GetParent_(a) ; on regarde qui la mère de notre bureau
SetParent_( b, hwnd) ; On arrache le bureau à sa maman :)
n=List_Windows()
Dim List.WIN(n)
For a=0 To n-1
list(a)\hwnd=FindWindow_(0,Select_Windows(a))
Debug List(a)\hwnd
list(a)\hwndParent=GetParent_(list(a)\hwnd)
SetParent_(list(a)\hwnd, hwnd)
Next
Repeat
Until WaitWindowEvent()=#PB_Event_CloseWindow
For a=0 To n-1
SetParent_(list(a)\hwnd, List(a)\hwndParent)
Next
SetParent_(a, b) ; On le lui rend ;)
End
Code : Tout sélectionner
DeleteObject_(CaptureScreenBMPHandle)
ProcedureDLL.l GetImageBits2(ImageID, HList) ; Transfert d'une image vers un tableau
Protected bmi.BITMAPINFO, hdc.l, Resultat, Mem, n, nn, bm.BITMAP
Resultat = 0
GetObject_(ImageID, SizeOf(BITMAP), @bm.BITMAP)
bmi\bmiHeader\biSize = SizeOf(BITMAPINFOHEADER)
bmi\bmiHeader\biWidth = bm\bmWidth
bmi\bmiHeader\biHeight = bm\bmHeight
bmi\bmiHeader\biPlanes = 1
bmi\bmiHeader\biBitCount = 32
bmi\bmiHeader\biCompression = #BI_RGB
Mem = AllocateMemory (bm\bmWidth * bm\bmHeight * 4)
If Mem
hdc = CreateCompatibleDC_(GetDC_(ImageID))
If hdc
GetDIBits_(hdc, ImageID, 0, bm\bmHeight, Mem, @bmi, #DIB_RGB_COLORS ) ; on envoie la liste dans l'image
ReleaseDC_(0, hdc)
Resultat = ImageID
Endif
; On convertit la liste dans le bon format
For n = 0 To bm\bmHeight - 1
For nn = 0 To bm\bmWidth - 1
CopyMemory (Mem + nn * 4 + (bm\bmHeight - 1 - n) * bm\bmWidth * 4, HList + n * 4 + nn * bm\bmHeight * 4, 4)
Next
Next
FreeMemory (Mem)
Endif
ProcedureReturn Resultat
EndProcedure
Procedure Longueur(x.f, y.f)
ProcedureReturn Sqr (x * x + y * y)
EndProcedure
#Pi = 3.14159265
; Copie d'écran
Largeur_Ecran = GetSystemMetrics_( #SM_CXSCREEN )
Hauteur_Ecran = GetSystemMetrics_( #SM_CYSCREEN )
DC = GetDC_(0)
CreateImage (0, Largeur_Ecran, Hauteur_Ecran)
Dessin = StartDrawing ( ImageOutput ())
BitBlt_(Dessin, 0, 0, Largeur_Ecran, Hauteur_Ecran, DC, 0, 0, #SRCPAINT )
StopDrawing ()
ReleaseDC_(0, DC)
; OpenWindow(0, 0, 0, 100, 100, #WS_MAXIMIZE | #PB_Window_BorderLess, "Sphère")
; SetWindowPos_(WindowID(), -1, 0, 0, 0, 0, #SWP_NOSIZE | #SWP_NOMOVE) ; Pour mettre la fenêtre toujours au premier plan
; UpdateWindow_(WindowID())
; On copie l'image dans un Tableau
Dim Image.l(Largeur_Ecran - 1, Hauteur_Ecran - 1)
GetImageBits2( UseImage (0), @Image())
; On ouvre l'openscreen
If InitSprite () = 0 Or InitKeyboard () = 0 Or InitMouse () = 0
MessageRequester (" Erreur ", " Impossible d'initialiser la souris ,le clavier ou l'écran. Vérifiez la présence de DirectX 7 ou supérieur. ", 0)
End
Endif
If OpenScreen (Largeur_Ecran, Hauteur_Ecran, 32, " Sphère ") = 0
MessageRequester (" Erreur ", " Impossible d'ouvrir l'écran. ", 0)
End
Endif
; Création du sprite représentant l'écran
CreateSprite (1, Largeur_Ecran, Hauteur_Ecran)
StartDrawing ( SpriteOutput (1))
DrawImage ( UseImage (0), 0, 0)
StopDrawing ()
; Calcul préliminaire
#DefinitionArcSin = 2000
Dim ArcSin.f( #DefinitionArcSin )
For n = 0 To #DefinitionArcSin
Arc Sin (n) = ASin (n / #DefinitionArcSin ) * 2 / #Pi
Next
; Initialisation des variables
#RayonMax = 150
Rayon = 100
Repeat
; On lit les évènements clavier et souris
ExamineMouse ()
ExamineKeyboard ()
; Position de la souris
x = MouseX ()
y = MouseY ()
; Agrandir ou réduire la sphère
If KeyboardPushed ( #PB_Key_Up ) And Rayon < #RayonMax
Rayon + 2
ElseIf KeyboardPushed ( #PB_Key_Down ) And Rayon > 0
Rayon - 2
Endif
; On affiche l'image
DisplaySprite (1, 0, 0)
StartDrawing ( ScreenOutput ())
; Calcul du FPS
#DefinitionFPS = 20
cpt + 1
If cpt = #DefinitionFPS
cpt = 0
fps.f = #DefinitionFPS * 1000 / ( ElapsedMilliseconds () - Temps)
Temps = ElapsedMilliseconds ()
Endif
Locate (5, 5)
DrawText ( StrF (fps, 1))
; On édite l'image
Memoire = DrawingBuffer ()
For n = -Rayon To Rayon
x2 = x + n
If x2 > 0 And x2 < Largeur_Ecran - 1 ; Si on est sur l'image en x
For nn = -Rayon To Rayon
y2 = y + nn
If y2 > 0 And y2 < Hauteur_Ecran - 1 ; Si on est sur l'image en y
Longueur.f = Longueur(n, nn) ; On calcul la distance d'un point de la sphère à partir du centre
If Longueur <= Rayon ; Si le pixel est situé dans le rayon du cercle
Longueur2.f = Arc Sin ( Int ((Longueur / Rayon * 0.25 + 0.75) * #DefinitionArcSin )) ; on calcul la distance du point de l'image correspondant à celui de la sphère
; Avec lissage
PosX.f = x + n * Longueur2
PosY.f = y + nn * Longueur2
PosX_Int = PosX
PosY_Int = PosY
Rouge.f = 0 : Vert.f = 0 : Bleu.f = 0 : SommeFacteur.f = 0
For i = PosX_Int - 1 To PosX_Int + 1
For ii = PosY_Int - 1 To PosY_Int + 1
Facteur.f = 1 - Longueur(i - PosX, ii - PosY)
If Facteur > 0
Rouge = Rouge + Red (Image(i, ii)) * Facteur
Vert = Vert + Green (Image(i, ii)) * Facteur
Bleu = Bleu + Blue (Image(i, ii)) * Facteur
SommeFacteur = SommeFacteur + Facteur
Endif
Next
Next
Couleur.l = RGB ( Int (Rouge / SommeFacteur), Int (Vert / SommeFacteur), Int (Bleu / SommeFacteur))
; Sans lissage
; Couleur.l = Image(Int(x + n * Longueur2 + 0.5), Int(y + nn * Longueur2 + 0.5))
; On affiche le pixel
Pixel_Memoire = Memoire + 4 * (x + n) + 4 * (y + nn) * Largeur_Ecran
PokeL (Pixel_Memoire, Couleur)
Endif
Endif
Next
Endif
Next
StopDrawing ()
FlipBuffers ()
If IsScreenActive () = 0
End
Endif
Until KeyboardPushed ( #PB_Key_Escape )
Code : Tout sélectionner
ProcedureDLL.l GetImageBits2(ImageID, HList) ; Transfert d'une image vers un tableau
Protected bmi.BITMAPINFO, hdc.l, Resultat, Mem, n, nn, bm.BITMAP
Resultat = 0
GetObject_(ImageID, SizeOf(BITMAP), @bm.BITMAP)
bmi\bmiHeader\biSize = SizeOf(BITMAPINFOHEADER)
bmi\bmiHeader\biWidth = bm\bmWidth
bmi\bmiHeader\biHeight = bm\bmHeight
bmi\bmiHeader\biPlanes = 1
bmi\bmiHeader\biBitCount = 32
bmi\bmiHeader\biCompression = #BI_RGB
Mem = AllocateMemory (bm\bmWidth * bm\bmHeight * 4)
If Mem
hdc = CreateCompatibleDC_(GetDC_(ImageID))
If hdc
GetDIBits_(hdc, ImageID, 0, bm\bmHeight, Mem, @bmi, #DIB_RGB_COLORS ) ; on envoie la liste dans l'image
ReleaseDC_(0, hdc)
Resultat = ImageID
EndIf
; On convertit la liste dans le bon format
For n = 0 To bm\bmHeight - 1
For nn = 0 To bm\bmWidth - 1
CopyMemory (Mem + nn * 4 + (bm\bmHeight - 1 - n) * bm\bmWidth * 4, HList + n * 4 + nn * bm\bmHeight * 4, 4)
Next
Next
FreeMemory (Mem)
EndIf
ProcedureReturn Resultat
EndProcedure
Procedure Longueur(x.f, y.f)
ProcedureReturn Sqr (x * x + y * y)
EndProcedure
#PI = 3.14159265
; Copie d'écran
Largeur_Ecran = GetSystemMetrics_( #SM_CXSCREEN )
Hauteur_Ecran = GetSystemMetrics_( #SM_CYSCREEN )
DC = GetDC_(0)
CreateImage (0, Largeur_Ecran, Hauteur_Ecran)
Dessin = StartDrawing ( ImageOutput ())
BitBlt_(Dessin, 0, 0, Largeur_Ecran, Hauteur_Ecran, DC, 0, 0, #SRCPAINT )
StopDrawing ()
ReleaseDC_(0, DC)
; OpenWindow(0, 0, 0, 100, 100, #WS_MAXIMIZE | #PB_Window_BorderLess, "Sphère")
; SetWindowPos_(WindowID(), -1, 0, 0, 0, 0, #SWP_NOSIZE | #SWP_NOMOVE) ; Pour mettre la fenêtre toujours au premier plan
; UpdateWindow_(WindowID())
; On copie l'image dans un Tableau
Dim Image.l(Largeur_Ecran - 1, Hauteur_Ecran - 1)
GetImageBits2( UseImage (0), @Image())
; On ouvre l'openscreen
If InitSprite () = 0 Or InitKeyboard () = 0 Or InitMouse () = 0
MessageRequester (" Erreur ", " Impossible d'initialiser la souris ,le clavier ou l'écran. Vérifiez la présence de DirectX 7 ou supérieur. ", 0)
End
EndIf
If OpenScreen (Largeur_Ecran, Hauteur_Ecran, 32, " Sphère ") = 0
MessageRequester (" Erreur ", " Impossible d'ouvrir l'écran. ", 0)
End
EndIf
; Création du sprite représentant l'écran
CreateSprite (1, Largeur_Ecran, Hauteur_Ecran)
StartDrawing ( SpriteOutput (1))
DrawImage ( UseImage (0), 0, 0)
StopDrawing ()
; Calcul préliminaire
#DefinitionArcSin = 2000
Dim ArcSin.f( #DefinitionArcSin )
For n = 0 To #DefinitionArcSin
ArcSin(n) = ASin(n / #DefinitionArcSin ) * 2 / #PI
Next
; Initialisation des variables
#RayonMax = 150
Rayon = 100
Repeat
; On lit les évènements clavier et souris
ExamineMouse ()
ExamineKeyboard ()
; Position de la souris
x = MouseX ()
y = MouseY ()
; Agrandir ou réduire la sphère
If KeyboardPushed ( #PB_Key_Up ) And Rayon < #RayonMax
Rayon + 2
ElseIf KeyboardPushed ( #PB_Key_Down ) And Rayon > 0
Rayon - 2
EndIf
; On affiche l'image
DisplaySprite (1, 0, 0)
StartDrawing ( ScreenOutput ())
; Calcul du FPS
#DefinitionFPS = 20
cpt + 1
If cpt = #DefinitionFPS
cpt = 0
fps.f = #DefinitionFPS * 1000 / ( ElapsedMilliseconds () - Temps)
Temps = ElapsedMilliseconds ()
EndIf
Locate (5, 5)
DrawText ( StrF (fps, 1))
; On édite l'image
Memoire = DrawingBuffer ()
For n = -Rayon To Rayon
x2 = x + n
If x2 > 0 And x2 < Largeur_Ecran - 1 ; Si on est sur l'image en x
For nn = -Rayon To Rayon
y2 = y + nn
If y2 > 0 And y2 < Hauteur_Ecran - 1 ; Si on est sur l'image en y
Longueur.f = Longueur(n, nn) ; On calcul la distance d'un point de la sphère à partir du centre
If Longueur <= Rayon ; Si le pixel est situé dans le rayon du cercle
Longueur2.f = ArcSin ( Int((Longueur / Rayon * 0.25 + 0.75) * #DefinitionArcSin )) ; on calcul la distance du point de l'image correspondant à celui de la sphère
; Avec lissage
PosX.f = x + n * Longueur2
PosY.f = y + nn * Longueur2
PosX_Int = PosX
PosY_Int = PosY
Rouge.f = 0 : Vert.f = 0 : Bleu.f = 0 : SommeFacteur.f = 0
For i = PosX_Int - 1 To PosX_Int + 1
For ii = PosY_Int - 1 To PosY_Int + 1
Facteur.f = 1 - Longueur(i - PosX, ii - PosY)
If Facteur > 0
Rouge = Rouge + Red (Image(i, ii)) * Facteur
Vert = Vert + Green (Image(i, ii)) * Facteur
Bleu = Bleu + Blue (Image(i, ii)) * Facteur
SommeFacteur = SommeFacteur + Facteur
EndIf
Next
Next
Couleur.l = RGB ( Int (Rouge / SommeFacteur), Int (Vert / SommeFacteur), Int (Bleu / SommeFacteur))
; Sans lissage
; Couleur.l = Image(Int(x + n * Longueur2 + 0.5), Int(y + nn * Longueur2 + 0.5))
; On affiche le pixel
Pixel_Memoire = Memoire + 4 * (x + n) + 4 * (y + nn) * Largeur_Ecran
PokeL (Pixel_Memoire, Couleur)
EndIf
EndIf
Next
EndIf
Next
StopDrawing ()
FlipBuffers ()
If IsScreenActive () = 0
End
EndIf
Until KeyboardPushed ( #PB_Key_Escape )
Le miens !! cherche Colorer dans la rubrique anonce !@Dobro
C'est quoi le prog que tu utilise pour générer les couleurs et la mise en forme html?