Hello, i need to center the backdrop image of a Window, somebody knows how can i do it?
centeredBackdrop = new picture(me.width, me.height) centredBackdrop.DrawPicture(me.backdrop, me.width / 2 - (me.backdrop.width / 2), me.height / 2 - (me.backdrop.height)) me.backdrop = centeredBackdrop
Didn’t test the code but should give you an idea on how it’s done.
But, “CenteredBackdrop” ist a Picture? Because don’t exist “.DrawPicture” in a Picture
replace yourpicture with the name of your image
dim bgPic as Picture = yourpicture
g.DrawPicture (bgPic, me.width / 2 - (bgPic.width / 2), (me.height / 2) - (bgPic.height / 2))
you want to set the windows backdrop property to an image that is centered ?
not sure what event you want to do this in as there are several possibilities
but lets just put it in the Window.Open event for now
dim centeredBackdrop as new picture(me.width, me.height) centeredBackdrop.graphics.DrawPicture image_to_center, me.width / 2 - (image_to_center.width / 2), me.height / 2 - (image_to_center.height/2) me.backdrop = centeredBackdrop
this sets a new background that is centered
you could do this in any one of several events (paint, resized, resizing, etc)
The paint event is really flexible BUT it gets called a fair bit so reducing your overhead when redrawing might work by setting the backdrop
Either works and there are pro’s & cons to each
Thanks to all!