Background windows

Vous débutez et vous avez besoin d'aide ? N'hésitez pas à poser vos questions
Programmes
Messages : 80
Inscription : mer. 24/mai/2006 12:12

Background windows

Message 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...
Avatar de l’utilisateur
TazNormand
Messages : 1297
Inscription : ven. 27/oct./2006 12:19
Localisation : Calvados (14)

Re: Background windows

Message 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)
Image
Image
Programmes
Messages : 80
Inscription : mer. 24/mai/2006 12:12

Re: Background windows

Message 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.
Avatar de l’utilisateur
kernadec
Messages : 1606
Inscription : ven. 25/avr./2008 11:14

Re: Background windows

Message 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
Programmes
Messages : 80
Inscription : mer. 24/mai/2006 12:12

Re: Background windows

Message par Programmes »

Merci beaucoup pour ta réponse! J'ai pas réfléchi la solution était simple...
A + et bonne soirée
Répondre