Page 1 sur 1

Background windows

Publié : dim. 25/mai/2014 14:02
par Programmes
Bonjour à tous,

Je cherche à mettre une image en background pour une fenêtre. Je sais que j'y suis déjà parvenu, mais je ne sais plus comment faire.
Es-ce qu'il faut des librairies supplémentaires?
Merci à ceux qui peuvent m'aider...

Re: Background windows

Publié : dim. 25/mai/2014 14:39
par TazNormand
salut

trouvé sur le forum Anglais : http://www.purebasic.fr/english/viewtop ... 67#p429167

Code : Tout sélectionner

Win=OpenWindow(#PB_Any, 0, 0, 400, 255, "EditorGadget", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)

Im=CreateImage(#PB_Any, 400, 255)
StartDrawing(ImageOutput(Im))
	For k=0 To 255
		FrontColor(RGB(k,0,k))
		Line(0,k,400,1)
	Next
StopDrawing()

LoadFont(9,"Courier New",18)
E=EditorGadget(#PB_Any, 8, 8, 350, 210,#PB_Editor_WordWrap)
SetGadgetColor(E,#PB_Gadget_BackColor,$FF0000)
SetGadgetColor(E,#PB_Gadget_FrontColor,$FFFFFF)
SetGadgetFont(E,FontID(9))
For a = 0 To 5
	AddGadgetItem(E, a, "Line "+Str(a))
Next
SetActiveGadget(E); we put the cursor in the EditorGadget

hBrush=CreatePatternBrush_(ImageID(Im))
SetClassLongPtr_(WindowID(Win),#GCL_HBRBACKGROUND,hBrush)
InvalidateRect_(WindowID(Win),0,1)

Repeat
	Event = WaitWindowEvent()
	
Until Event = #PB_Event_CloseWindow
DeleteObject_(hBrush)

Re: Background windows

Publié : dim. 25/mai/2014 15:02
par Programmes
Merci beaucoup pour ta réponse, mais ça ne réponds pas vraiment à mon problème même si la solution est bien. En fait, ce que je voudrais, c'est choisir une image et la mettre en fond de fenêtre (un background), sois avec un bmp ou un jpg.

Re: Background windows

Publié : dim. 25/mai/2014 16:43
par kernadec
bonjour
bonne journée :D
cordialement

Code : Tout sélectionner

OpenWindow(0, 200, 100, 256, 256, "image de fond")

If LoadImage(0, #PB_Compiler_Home + "/examples/sources/Data/Background.bmp")

  ImageGadget(0, 0, 0, WindowWidth(0), WindowHeight(0), ImageID(0))

  Repeat
  Until WaitWindowEvent() = #PB_Event_CloseWindow
EndIf

Re: Background windows

Publié : dim. 25/mai/2014 17:54
par Programmes
Merci beaucoup pour ta réponse! J'ai pas réfléchi la solution était simple...
A + et bonne soirée