Page 1 of 1

Centralize image in window

PostPosted: Wed May 06, 2015 8:25 pm
by sambomb
How can I centralize an image in the center of the window regardless the user resize the window, maximize, etc?

Re: Centralize image in window

PostPosted: Wed May 06, 2015 9:51 pm
by ukoenig
The needed calculation on window-resize
( I can add a compiled sample + source if needed )

Logo :

@ nLTop, nLLeft IMAGE oLogo ; // Top / Left
FILENAME c_Path1 + cLogo ;
NOBORDER ;
OF oWnd PIXEL UPDATE TRANSPARENT


The calculation to center the image-position on window-resize :

oWnd:bResized := {|| nLTop := INT( ( ( oWnd:nHeight ) / 2 ) - ( oLogo:nHeight / 2 ) ), ;
nLLeft := INT( ( ( oWnd:nWidth - 18 ) / 2 ) - ( oLogo:nWidth / 2 ) ), ;
oLogo:Move( nLTop, nLLeft, , , .T. ) }


best regards
Uwe :)

Re: Centralize image in window

PostPosted: Wed May 06, 2015 9:58 pm
by sambomb
Worked fine! Thanks!

Re: Centralize image in window

PostPosted: Wed May 06, 2015 10:04 pm
by ukoenig
The results

Full screen

Image

Resized

Image

best regards
Uwe :)