Page 1 sur 1

Effacer qu'une partie d'une fenetre skinée [Résolu]

Publié : mer. 16/janv./2008 14:41
par Kwai chang caine
Bonjour les copains

Voila j'ai une image avec deux lignes.
Je voudrais n'effacer que la deuxieme.

J'ai eu l'aide de SROD qui m'a proposé un code qui marche mais que j'ai du mal à insérer dans mon appli qui a déja pas mal de fonction dans la callback et pas mal de skins sur mes fenetres et gadgets.
Et en plus le temps de redessiner tous les texts de la fenetre ça fait un sautement pas tres joli :cry:

Code de SROD :
(Bidouillé par KCC pour rajouter l'image de fond)

Code : Tout sélectionner

Global flag 
#FontArial14Gras = 10 
#ImageCompteur = 11 
LoadFont(#FontArial14Gras, "Arial", 14,#PB_Font_Bold) 

Procedure callBack(hWnd, uMsg, wParam, lParam) 
  Result = #PB_ProcessPureBasicEvents 
  Select uMsg 
    Case #WM_PAINT  
      StartDrawing(WindowOutput(0)) 
        DrawingMode(1) 
        FrontColor(RGB(255, 255, 255)) 
        DrawingFont(FontID(#FontArial14Gras)) 
        DrawText(140, 54, "Premiere phrase") 
      If flag=#False 
          DrawText(140, 204, "Seconde phrase") 
      EndIf 
      StopDrawing() 
      ValidateRect_(hWnd, 0) 
  EndSelect 
  ProcedureReturn result 
EndProcedure 

LoadImage(#ImageCompteur, "C:\Fond.bmp") 
hWnd = OpenWindow(0, 30, 30, 383, 377, "Essais", #PB_Window_BorderLess|#PB_Window_ScreenCentered) 

; Display image 
hBrushP.l = CreatePatternBrush_(ImageID(#ImageCompteur)) 
SetClassLong_(WindowID(0), #GCL_HBRBACKGROUND, hBrushP) 

; Add #WS_EX_LAYERED style and set transparent color 
SetWindowLong_(WindowID(0), #GWL_EXSTYLE, GetWindowLong_(WindowID(0), #GWL_EXSTYLE) | #WS_EX_LAYERED) 
SetLayeredWindowAttributes_(WindowID(0), #White, 10, #LWA_COLORKEY) 
UpdateWindow_(hWnd) 
SetWindowCallback(@callback()) 

InvalidateRect_(hWnd, 0, 1) 
UpdateWindow_(hWnd) 
Delay(5000) 
flag = #True 

RedrawWindow_(hWnd, 0,0, #RDW_ERASE|#RDW_INVALIDATE|#RDW_ERASENOW) 

Repeat  
  Evenement = WaitWindowEvent () 
Until Evenement = #PB_Event_CloseWindow
Il m'a parlé aussi d'utiliser beginpaint et endpaint, si je ne voulais pas redessiner toute la fenetre et c'est exactement ce que je voudrais faire.
Je n'ai jamais fait de graphisme, alors tout ça c'est plus que du chinois pour moi.

J'ai aussi eu un super code de Demivec qui utilise GrabImage mais qui apparement ne fonctionne qu'avec un gadgetImage. :cry:

Code : Tout sélectionner

#ImageCompteur = 11 
#ImageSource =12 
#FontArial14Gras = 10 
OpenWindow(0, 30, 30, 383, 377, "Essais") 
CreateGadgetList(WindowID(0)) 
LoadImage(#ImageSource,"c:\Fond.bmp") 
CopyImage(#ImageSource,#ImageCompteur) 
ImageGadget(1, 0, 0,20,50,ImageID(#ImageCompteur)) 
LoadFont(#FontArial14Gras, "Arial", 14,#PB_Font_Bold) 

StartDrawing(ImageOutput(#ImageCompteur)) 
DrawingMode(1) 
FrontColor(RGB(255, 255, 255)) 
DrawingFont(FontID(#FontArial14Gras)) 
DrawText(140, 54, "Premiere phrase") 
DrawText(140, 204, "Seconde phrase") 
StopDrawing() 

SetGadgetState(1,ImageID(#ImageCompteur)) 
Delay(2000) 

;erase text by copying source image over it 
StartDrawing(ImageOutput(#ImageCompteur)) 
DrawingFont(FontID(#FontArial14Gras)) 
provisoireImage = GrabImage(#ImageSource,#PB_Any,140,204,TextWidth("Seconde phrase"),TextHeight("Seconde phrse")) 
DrawImage(ImageID(provisoireImage),140,204) 
FreeImage(provisoireImage) 
StopDrawing() 
SetGadgetState(1,ImageID(#ImageCompteur)) 

Repeat 
  Evenement = WaitWindowEvent () 
Until Evenement = #PB_Event_CloseWindow
Je voudrais savoir si quelqu'un d'entre vous, aurait une combine au plus simple pour effacer cette @#\*¤!! de deuxieme ligne pour pouvoir y ecrire un autre texte àla place, avec laquelle je me bat depuis hier.

Voici l'image :
http://purebasic.myftp.org/files/413/Fond.bmp

Et voici mon code:

Code : Tout sélectionner

#Font = 10 
#Image = 11 

LoadFont(#Font, "Arial", 14,#PB_Font_Bold) 
LoadImage(#Image, "C:\Fond.bmp") 

OpenWindow(0, 30, 30, 383, 377, "Essais", #PB_Window_BorderLess|#PB_Window_ScreenCentered) 

; Display image 
hBrushP.l = CreatePatternBrush_(ImageID(#Image)) 
SetClassLong_(WindowID(0), #GCL_HBRBACKGROUND, hBrushP) 

; Add #WS_EX_LAYERED style and set transparent color 
SetWindowLong_(WindowID(0), #GWL_EXSTYLE, GetWindowLong_(WindowID(0), #GWL_EXSTYLE) | #WS_EX_LAYERED) 
SetLayeredWindowAttributes_(WindowID(0), #White, 10, #LWA_COLORKEY) 
UpdateWindow_(WindowID(0)) 

StartDrawing(WindowOutput(0)) 
DrawingMode(1) 
FrontColor(RGB(233, 233, 233)) 
DrawingFont(FontID(#Font)) 
DrawText(110, 74, "Premiere phrase") 
DrawText(110, 224, "Seconde phrase") 

Repeat : Evenement = WaitWindowEvent():Delay(1) :Until GetAsyncKeyState_(#VK_ESCAPE)
Merci de votre aide

Publié : mer. 16/janv./2008 15:02
par gnozal
Je ne sais pas si j'ai compris ce que tu veux, mais voilà un exemple avec un brush de fond :

Code : Tout sélectionner

#ImageCompteur = 11 
#ImageSource =12 
#FontArial14Gras = 10 
OpenWindow(0, 30, 30, 400, 330, "Essais") 
CreateGadgetList(WindowID(0)) 

LoadImage(#ImageSource,"c:\Fond.bmp")
LoadFont(#FontArial14Gras, "Arial", 14,#PB_Font_Bold) 
StartDrawing(ImageOutput(#ImageSource)) 
DrawingMode(1) 
FrontColor(RGB(255, 255, 255)) 
DrawingFont(FontID(#FontArial14Gras)) 
DrawText(140, 54, "Premiere phrase") 
StopDrawing() 
CopyImage(#ImageSource,#ImageCompteur)


BackgroundImage_Original_Brush = CreatePatternBrush_(ImageID(#ImageSource))
SetClassLong_(WindowID(0), #GCL_HBRBACKGROUND, BackgroundImage_Original_Brush)
RedrawWindow_(WindowID(0), 0, 0, #RDW_ERASE | #RDW_FRAME | #RDW_INVALIDATE | #RDW_ALLCHILDREN)
While WindowEvent() : Wend

LoadFont(#FontArial14Gras, "Arial", 14,#PB_Font_Bold) 
StartDrawing(ImageOutput(#ImageCompteur)) 
DrawingMode(1) 
FrontColor(RGB(255, 255, 255)) 
DrawingFont(FontID(#FontArial14Gras)) 
DrawText(140, 204, "Seconde phrase") 
StopDrawing() 

BackgroundImage_Compteur_Brush = CreatePatternBrush_(ImageID(#ImageCompteur))
SetClassLong_(WindowID(0), #GCL_HBRBACKGROUND, BackgroundImage_Compteur_Brush)
RedrawWindow_(WindowID(0), 0, 0, #RDW_ERASE | #RDW_FRAME | #RDW_INVALIDATE | #RDW_ALLCHILDREN)
While WindowEvent() : Wend

Delay(2000) 

SetClassLong_(WindowID(0), #GCL_HBRBACKGROUND, BackgroundImage_Original_Brush)
RedrawWindow_(WindowID(0), 0, 0, #RDW_ERASE | #RDW_FRAME | #RDW_INVALIDATE | #RDW_ALLCHILDREN)
While WindowEvent() : Wend


Repeat 
  Evenement = WaitWindowEvent () 
Until Evenement = #PB_Event_CloseWindow

DeleteObject_(BackgroundImage_Compteur_Brush)
DeleteObject_(BackgroundImage_Original_Brush)

Publié : mer. 16/janv./2008 15:11
par Kwai chang caine
Merci mon bon GNOZAL
J'ai vu que tu rodais dans le coin, alors j'avais l'espoir .... :D
Je n'ai pas été déçu (Comme dab :wink: )

J'avais du oublier le code pour le SKIN
Je l'ai rajouté, et aussi des WindowUpdate un peu de partout, car ça a du mal chez moi à tout apparaitre :?

Ton code marche super avec tout ça.
Je vais essayer de l'insérer dans le miens, et en plus pas de callback 8)
Ca devrait etre plus facile pour moi.

Voila ce que ça donne.
Si tu vois un bleme ou une incompatibilité entre ton code et le SKIN que je viens de rajouter, dizilemeleu :D

Mille merci.

PS:
ça fait du bien de te parler en français, je comprend tout ce que tu dis :D

Code : Tout sélectionner

#ImageCompteur = 11 
#ImageSource =12 
#FontArial14Gras = 10 
OpenWindow(0, 30, 30, 383, 377, "Essais", #PB_Window_BorderLess|#PB_Window_ScreenCentered) 
CreateGadgetList(WindowID(0)) 

LoadImage(#ImageSource,"c:\Fond.bmp") 
LoadFont(#FontArial14Gras, "Arial", 14,#PB_Font_Bold) 
StartDrawing(ImageOutput(#ImageSource)) 
DrawingMode(1) 
FrontColor(RGB(255, 255, 255)) 
DrawingFont(FontID(#FontArial14Gras)) 
DrawText(140, 54, "Premiere phrase") 
StopDrawing() 
CopyImage(#ImageSource,#ImageCompteur) 

; Display image 
hBrushP.l = CreatePatternBrush_(ImageID(#ImageCompteur)) 
SetClassLong_(WindowID(0), #GCL_HBRBACKGROUND, hBrushP) 

; Add #WS_EX_LAYERED style and set transparent color 
SetWindowLong_(WindowID(0), #GWL_EXSTYLE, GetWindowLong_(WindowID(0), #GWL_EXSTYLE) | #WS_EX_LAYERED) 
SetLayeredWindowAttributes_(WindowID(0), #White, 10, #LWA_COLORKEY) 
UpdateWindow_(hWnd) 

BackgroundImage_Original_Brush = CreatePatternBrush_(ImageID(#ImageSource)) 
SetClassLong_(WindowID(0), #GCL_HBRBACKGROUND, BackgroundImage_Original_Brush) 
RedrawWindow_(WindowID(0), 0, 0, #RDW_ERASE | #RDW_FRAME | #RDW_INVALIDATE | #RDW_ALLCHILDREN) 
While WindowEvent() : Wend 
UpdateWindow_(WindowID(0))

LoadFont(#FontArial14Gras, "Arial", 14,#PB_Font_Bold) 
StartDrawing(ImageOutput(#ImageCompteur)) 
DrawingMode(1) 
FrontColor(RGB(255, 255, 255)) 
DrawingFont(FontID(#FontArial14Gras)) 
DrawText(140, 204, "Seconde phrase") 
StopDrawing() 
UpdateWindow_(WindowID(0))

BackgroundImage_Compteur_Brush = CreatePatternBrush_(ImageID(#ImageCompteur)) 
SetClassLong_(WindowID(0), #GCL_HBRBACKGROUND, BackgroundImage_Compteur_Brush) 
RedrawWindow_(WindowID(0), 0, 0, #RDW_ERASE | #RDW_FRAME | #RDW_INVALIDATE | #RDW_ALLCHILDREN) 
While WindowEvent() : Wend 
UpdateWindow_(WindowID(0))

Delay(2000) 

SetClassLong_(WindowID(0), #GCL_HBRBACKGROUND, BackgroundImage_Original_Brush) 
RedrawWindow_(WindowID(0), 0, 0, #RDW_ERASE | #RDW_FRAME | #RDW_INVALIDATE | #RDW_ALLCHILDREN) 
While WindowEvent() : Wend 
UpdateWindow_(WindowID(0))

Repeat 
  Evenement = WaitWindowEvent () 
Until Evenement = #PB_Event_CloseWindow 

DeleteObject_(BackgroundImage_Compteur_Brush) 
DeleteObject_(BackgroundImage_Original_Brush)

Publié : mer. 16/janv./2008 15:24
par gnozal
Je ne peux pas tester complètement le code (sous NT4, pas de transparences ...) mais ceci me semble correct :

Code : Tout sélectionner

#ImageCompteur = 11 
#ImageSource =12 
#FontArial14Gras = 10 
OpenWindow(0, 30, 30, 383, 377, "Essais", #PB_Window_BorderLess|#PB_Window_ScreenCentered) 
CreateGadgetList(WindowID(0)) 

LoadImage(#ImageSource,"c:\internet.tmp\Fond.bmp") 
LoadFont(#FontArial14Gras, "Arial", 14,#PB_Font_Bold) 
StartDrawing(ImageOutput(#ImageSource)) 
DrawingMode(1) 
FrontColor(RGB(255, 255, 255)) 
DrawingFont(FontID(#FontArial14Gras)) 
DrawText(140, 54, "Premiere phrase") 
StopDrawing() 
CopyImage(#ImageSource,#ImageCompteur) 

; Add #WS_EX_LAYERED style and set transparent color 
; SetWindowLong_(WindowID(0), #GWL_EXSTYLE, GetWindowLong_(WindowID(0), #GWL_EXSTYLE) | #WS_EX_LAYERED) 
; SetLayeredWindowAttributes_(WindowID(0), #White, 10, #LWA_COLORKEY) 
; UpdateWindow_(hwnd) 

BackgroundImage_Original_Brush = CreatePatternBrush_(ImageID(#ImageSource)) 
SetClassLong_(WindowID(0), #GCL_HBRBACKGROUND, BackgroundImage_Compteur_Brush) 
RedrawWindow_(WindowID(0), 0, 0, #RDW_ERASE | #RDW_FRAME | #RDW_INVALIDATE | #RDW_ALLCHILDREN) 
UpdateWindow_(WindowID(0)) 

LoadFont(#FontArial14Gras, "Arial", 14,#PB_Font_Bold) 
StartDrawing(ImageOutput(#ImageCompteur)) 
DrawingMode(1) 
FrontColor(RGB(255, 255, 255)) 
DrawingFont(FontID(#FontArial14Gras)) 
DrawText(140, 204, "Seconde phrase") 
StopDrawing() 

BackgroundImage_Compteur_Brush = CreatePatternBrush_(ImageID(#ImageCompteur)) 
SetClassLong_(WindowID(0), #GCL_HBRBACKGROUND, BackgroundImage_Compteur_Brush) 
RedrawWindow_(WindowID(0), 0, 0, #RDW_ERASE | #RDW_FRAME | #RDW_INVALIDATE | #RDW_ALLCHILDREN) 
UpdateWindow_(WindowID(0)) 


Delay(2000) 

SetClassLong_(WindowID(0), #GCL_HBRBACKGROUND, BackgroundImage_Original_Brush) 
RedrawWindow_(WindowID(0), 0, 0, #RDW_ERASE | #RDW_FRAME | #RDW_INVALIDATE | #RDW_ALLCHILDREN) 


Repeat 
  Evenement = WaitWindowEvent () 
Until Evenement = #PB_Event_CloseWindow 

DeleteObject_(BackgroundImage_Compteur_Brush) 
DeleteObject_(BackgroundImage_Original_Brush)

Publié : mer. 16/janv./2008 15:26
par Kwai chang caine
Avec les lignes que tu as commenté les bords blancs apparaissent :cry:
Si je les décommentes c'est nickel :D

Publié : mer. 16/janv./2008 15:28
par gnozal
Kwai chang caine a écrit :Avec les lignes que tu as commenté les bords blancs apparaissent :cry:
Ben oui, sous NT4 SetLayeredWindowAttributes_() n'existe pas.
Il faut bien entendu les 'décommenter' sous XP.

Publié : mer. 16/janv./2008 15:34
par Kwai chang caine
D'accord, je sais, je suis une plaie :oops:

J'avais pas compris que ça plantait chez toi, mais juste que tu avais commenté car elles etait inutiles.

Bah dis donc déjà que je me plaint qu'au boulot on est en retard avec notre W2000 :roll:
NT4 c'est l'avant guerre, remarque y'a que 2 ans qu'on est passé tout sous W2000 et ils ont meme viré la couche reseau que l'année derniere pour tout passer sous W2000.

Pour le code, c'est nickel, je me jette sur mon code pour voir si ça "craque" comme dirait les mécanos :D

Je te remercie encore beaucoup de ta gentillesse 8)

Publié : mer. 16/janv./2008 15:52
par Kwai chang caine
J'suis dégouté j'arrive pas à réécrire au meme endroit :cry:

Code : Tout sélectionner

; http://www.purebasic.fr/french/viewtopic.php?p=77873

#ImageCompteur = 11 
#ImageSource =12 
#FontArial14Gras = 10 
OpenWindow(0, 30, 30, 383, 377, "Essais", #PB_Window_BorderLess|#PB_Window_ScreenCentered) 
CreateGadgetList(WindowID(0)) 

LoadImage(#ImageSource,"c:\Fond.bmp") 
LoadFont(#FontArial14Gras, "Arial", 14,#PB_Font_Bold) 
StartDrawing(ImageOutput(#ImageSource)) 
DrawingMode(1) 
FrontColor(RGB(255, 255, 255)) 
DrawingFont(FontID(#FontArial14Gras)) 
DrawText(140, 54, "Premiere phrase") 
StopDrawing() 

CopyImage(#ImageSource,#ImageCompteur) 

StartDrawing(ImageOutput(#ImageCompteur)) 
DrawingMode(1) 
FrontColor(RGB(255, 255, 255)) 
DrawingFont(FontID(#FontArial14Gras)) 
DrawText(140, 204, "Seconde phrase") 
StopDrawing() 

;Add #WS_EX_LAYERED style And set transparent color 
SetWindowLong_(WindowID(0), #GWL_EXSTYLE, GetWindowLong_(WindowID(0), #GWL_EXSTYLE) | #WS_EX_LAYERED) 
SetLayeredWindowAttributes_(WindowID(0), #White, 10, #LWA_COLORKEY) 

BackgroundImage_Original_Brush = CreatePatternBrush_(ImageID(#ImageSource)) 
BackgroundImage_Compteur_Brush = CreatePatternBrush_(ImageID(#ImageCompteur)) 

SetClassLong_(WindowID(0), #GCL_HBRBACKGROUND, BackgroundImage_Compteur_Brush) 
RedrawWindow_(WindowID(0), 0, 0, #RDW_ERASE | #RDW_FRAME | #RDW_INVALIDATE | #RDW_ALLCHILDREN) 
While WindowEvent() : Wend 
UpdateWindow_(WindowID(0)) 

Delay(1000) 

SetClassLong_(WindowID(0), #GCL_HBRBACKGROUND, BackgroundImage_Original_Brush) 
RedrawWindow_(WindowID(0), 0, 0, #RDW_ERASE | #RDW_FRAME | #RDW_INVALIDATE | #RDW_ALLCHILDREN) 

Delay(1000) 

StartDrawing(ImageOutput(#ImageCompteur)) 
DrawingMode(1) 
FrontColor(RGB(255, 255, 255)) 
DrawingFont(FontID(#FontArial14Gras)) 
DrawText(140, 204, "Seconde phrase") 
StopDrawing() 
UpdateWindow_(WindowID(0)) 

Repeat 
  Evenement = WaitWindowEvent () 
Until Evenement = #PB_Event_CloseWindow 

DeleteObject_(BackgroundImage_Compteur_Brush) 
DeleteObject_(BackgroundImage_Original_Brush)

Publié : mer. 16/janv./2008 16:03
par gnozal

Code : Tout sélectionner

; http://www.purebasic.fr/french/viewtopic.php?p=77873 

#ImageCompteur = 11 
#ImageSource =12 
#FontArial14Gras = 10 
OpenWindow(0, 30, 30, 383, 377, "Essais", #PB_Window_BorderLess|#PB_Window_ScreenCentered) 
CreateGadgetList(WindowID(0)) 

LoadImage(#ImageSource,"c:\internet.tmp\Fond.bmp") 
LoadFont(#FontArial14Gras, "Arial", 14,#PB_Font_Bold) 
StartDrawing(ImageOutput(#ImageSource)) 
DrawingMode(1) 
FrontColor(RGB(255, 255, 255)) 
DrawingFont(FontID(#FontArial14Gras)) 
DrawText(140, 54, "Premiere phrase") 
StopDrawing() 

CopyImage(#ImageSource,#ImageCompteur) 

StartDrawing(ImageOutput(#ImageCompteur)) 
DrawingMode(1) 
FrontColor(RGB(255, 255, 255)) 
DrawingFont(FontID(#FontArial14Gras)) 
DrawText(140, 204, "Seconde phrase") 
StopDrawing() 

; ;Add #WS_EX_LAYERED style And set transparent color 
SetWindowLong_(WindowID(0), #GWL_EXSTYLE, GetWindowLong_(WindowID(0), #GWL_EXSTYLE) | #WS_EX_LAYERED) 
SetLayeredWindowAttributes_(WindowID(0), #White, 10, #LWA_COLORKEY) 

BackgroundImage_Original_Brush = CreatePatternBrush_(ImageID(#ImageSource)) 
BackgroundImage_Compteur_Brush = CreatePatternBrush_(ImageID(#ImageCompteur)) 

SetClassLong_(WindowID(0), #GCL_HBRBACKGROUND, BackgroundImage_Compteur_Brush) 
RedrawWindow_(WindowID(0), 0, 0, #RDW_ERASE | #RDW_FRAME | #RDW_INVALIDATE | #RDW_ALLCHILDREN) 
UpdateWindow_(WindowID(0)) 

Delay(1000) 

SetClassLong_(WindowID(0), #GCL_HBRBACKGROUND, BackgroundImage_Original_Brush) 
RedrawWindow_(WindowID(0), 0, 0, #RDW_ERASE | #RDW_FRAME | #RDW_INVALIDATE | #RDW_ALLCHILDREN) 
UpdateWindow_(WindowID(0)) 

Delay(1000) 

FreeImage(#ImageCompteur)
CopyImage(#ImageSource,#ImageCompteur) 
StartDrawing(ImageOutput(#ImageCompteur)) 
DrawingMode(1) 
FrontColor(RGB(255, 255, 255)) 
DrawingFont(FontID(#FontArial14Gras)) 
DrawText(140, 204, "Une autre phrase") 
StopDrawing() 
UpdateWindow_(WindowID(0)) 
DeleteObject_(BackgroundImage_Compteur_Brush) 
BackgroundImage_Compteur_Brush = CreatePatternBrush_(ImageID(#ImageCompteur)) 
SetClassLong_(WindowID(0), #GCL_HBRBACKGROUND, BackgroundImage_Compteur_Brush) 
RedrawWindow_(WindowID(0), 0, 0, #RDW_ERASE | #RDW_FRAME | #RDW_INVALIDATE | #RDW_ALLCHILDREN) 



While WindowEvent() : Wend 
UpdateWindow_(WindowID(0)) 


Repeat 
  Evenement = WaitWindowEvent () 
Until Evenement = #PB_Event_CloseWindow 

DeleteObject_(BackgroundImage_Compteur_Brush) 
DeleteObject_(BackgroundImage_Original_Brush)

Publié : mer. 16/janv./2008 16:18
par Kwai chang caine
Merci beaucoup :D
Cette fois c'est le TOP !! 8)

En attendant ta réponse j'a mélangé tous vos codes et j'ai pondu ce gros ZEU 8O

Qu'est ce que t'en pense, vois tu un bleme ?

Code : Tout sélectionner

#Font = 10 
#Image = 11 
#ImageSav = 12

LoadFont(#Font, "Arial", 14,#PB_Font_Bold) 
LoadImage(#Image, "C:\Fond.bmp") 
CopyImage(#Image,#ImageSav)

OpenWindow(0, 30, 30, 383, 377, "Essais", #PB_Window_BorderLess|#PB_Window_ScreenCentered) 

hBrushP.l = CreatePatternBrush_(ImageID(#Image)) 
SetClassLong_(WindowID(0), #GCL_HBRBACKGROUND, hBrushP) 

SetWindowLong_(WindowID(0), #GWL_EXSTYLE, GetWindowLong_(WindowID(0), #GWL_EXSTYLE) | #WS_EX_LAYERED) 
SetLayeredWindowAttributes_(WindowID(0), #White, 10, #LWA_COLORKEY) 
UpdateWindow_(WindowID(0)) 

StartDrawing(WindowOutput(0)) 
DrawingMode(1) 
FrontColor(RGB(233, 233, 233)) 
DrawingFont(FontID(#Font)) 
DrawText(110, 74, "Premiere phrase") 
DrawText(110, 224, "Seconde phrase") 

provisoireImage = GrabImage(#ImageSav,#PB_Any,110,224,TextWidth("Seconde phrase   "),TextHeight("Seconde phrase")) 
Delay (1000)
DrawImage(ImageID(provisoireImage),110,224)
Delay (1000)
DrawText(110, 224, "Troisieme phrase") 
Delay (1000)
DrawImage(ImageID(provisoireImage),110,224)
Delay (1000)
DrawText(110, 224, "Quatrieme phrase") 
Delay (1000)
DrawImage(ImageID(provisoireImage),110,224)
Delay (1000)
DrawText(130, 224, "Bon ça suffit.....") 
DrawText(40, 244, "GNOZAL à autre chose à foutre !!") 
FreeImage(provisoireImage) 
StopDrawing() 
Delay (3000)
End

Publié : mer. 16/janv./2008 16:26
par gnozal
çà m'a l'air très bien, mais si tu écris directement sur la fenêtre (StartDrawing(WindowOutput(0))) il va falloir gérer les rafraichissements (#WM_PAINT ...) non ?
Sinon j'ai continué l'exemple précédent :

Code : Tout sélectionner

; http://www.purebasic.fr/french/viewtopic.php?p=77873 

#ImageCompteur = 11 
#ImageSource =12 
#FontArial14Gras = 10 
OpenWindow(0, 30, 30, 383, 377, "Essais", #PB_Window_BorderLess|#PB_Window_ScreenCentered) 
CreateGadgetList(WindowID(0)) 

LoadFont(#FontArial14Gras, "Arial", 14,#PB_Font_Bold) 

Procedure CreationImageOriginale()
  Shared BackgroundImage_Original_Brush
  LoadImage(#ImageSource,"c:\internet.tmp\Fond.bmp") 
  StartDrawing(ImageOutput(#ImageSource)) 
  DrawingMode(1) 
  FrontColor(RGB(255, 255, 255)) 
  DrawingFont(FontID(#FontArial14Gras)) 
  DrawText(140, 54, "Premiere phrase") 
  StopDrawing() 
  BackgroundImage_Original_Brush = CreatePatternBrush_(ImageID(#ImageSource)) 
EndProcedure

Procedure AffichageImageOriginale()
  Shared BackgroundImage_Original_Brush
  SetClassLong_(WindowID(0), #GCL_HBRBACKGROUND, BackgroundImage_Original_Brush) 
  RedrawWindow_(WindowID(0), 0, 0, #RDW_ERASE | #RDW_FRAME | #RDW_INVALIDATE | #RDW_ALLCHILDREN) 
  UpdateWindow_(WindowID(0))
EndProcedure

Procedure AffichageImageSecondeImage(Texte.s)
  Shared BackgroundImage_Compteur_Brush
  If IsImage(#ImageCompteur)
    FreeImage(#ImageCompteur)
  EndIf
  CopyImage(#ImageSource,#ImageCompteur) 
  StartDrawing(ImageOutput(#ImageCompteur)) 
  DrawingMode(1) 
  FrontColor(RGB(255, 255, 255)) 
  DrawingFont(FontID(#FontArial14Gras)) 
  DrawText(140, 204, Texte) 
  StopDrawing() 
  If BackgroundImage_Compteur_Brush
    DeleteObject_(BackgroundImage_Compteur_Brush) 
  EndIf
  BackgroundImage_Compteur_Brush = CreatePatternBrush_(ImageID(#ImageCompteur)) 
  SetClassLong_(WindowID(0), #GCL_HBRBACKGROUND, BackgroundImage_Compteur_Brush) 
  RedrawWindow_(WindowID(0), 0, 0, #RDW_ERASE | #RDW_FRAME | #RDW_INVALIDATE | #RDW_ALLCHILDREN) 
  UpdateWindow_(WindowID(0))
EndProcedure

; ;Add #WS_EX_LAYERED style And set transparent color 
SetWindowLong_(WindowID(0), #GWL_EXSTYLE, GetWindowLong_(WindowID(0), #GWL_EXSTYLE) | #WS_EX_LAYERED) 
SetLayeredWindowAttributes_(WindowID(0), #White, 10, #LWA_COLORKEY) 

CreationImageOriginale()
AffichageImageOriginale()

Delay(1000) 

AffichageImageSecondeImage("Seconde phrase")

Delay(1000) 

AffichageImageOriginale()

Delay(1000) 

AffichageImageSecondeImage("Une autre phrase")

Delay(1000) 

AffichageImageOriginale()

Delay(1000) 

AffichageImageSecondeImage("Encore une !")

Repeat 
  Evenement = WaitWindowEvent () 
Until Evenement = #PB_Event_CloseWindow 

DeleteObject_(BackgroundImage_Compteur_Brush) 
DeleteObject_(BackgroundImage_Original_Brush)

Publié : mer. 16/janv./2008 16:41
par Kwai chang caine
çà m'a l'air très bien, mais si tu écris directement sur la fenêtre (StartDrawing(WindowOutput(0))) il va falloir gérer les rafraichissements (#WM_PAINT ...) non ?
Bah tu sais, je fais copier .....puis coller ......je pioche dans les codes de tous mes gentils copains comme toi, qui veulent bien me tendre une main.
Mais je comprend pas tous ce que j'écris :oops:
Mais PB, il comprend que c'est pas bien, car il fait souvent "BLING!!!"
Parfois j'ai l'impression de jouer au flipper... :D
Je redoute le GAME OVER :? mais avec PB on peux rejouer sans payer :D

Alors, si tu le dis c'est que c'est vrai :D

Pour le code
Alors là on touche le sublime, l'extreme, la perfection, l'aphrodisiaque et encore je reste modeste :D

Je crois que tu va avoir le dernier mot, et c'est tant mieux car quand je met tes mots à toi dans le panneau jaune, ça marche :D

Je teste ......

Publié : mer. 16/janv./2008 18:03
par Kwai chang caine
Un seul mot me viens à l'esprit

NICKEL !!

Encore merci pour ton aide.
Je te souhaite une excelente soirée