Centralize image in window

Centralize image in window

Postby sambomb » Wed May 06, 2015 8:25 pm

How can I centralize an image in the center of the window regardless the user resize the window, maximize, etc?
Email: SamirSSabreu@gmail.com
MSN: SamirAbreu@hotmail.com
Skype: SamirAbreu
xHarbour 1.1.0 + FwXh 8.02
xHarbour 1.2.1 + Fwhh 10.6
User avatar
sambomb
 
Posts: 385
Joined: Mon Oct 13, 2008 11:26 am
Location: Itaocara - RJ - Brasil

Re: Centralize image in window

Postby ukoenig » Wed May 06, 2015 9:51 pm

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 :)
Since 1995 ( the first release of FW 1.9 )
i work with FW.
If you have any questions about special functions, maybe i can help.
User avatar
ukoenig
 
Posts: 4043
Joined: Wed Dec 19, 2007 6:40 pm
Location: Germany

Re: Centralize image in window

Postby sambomb » Wed May 06, 2015 9:58 pm

Worked fine! Thanks!
Email: SamirSSabreu@gmail.com
MSN: SamirAbreu@hotmail.com
Skype: SamirAbreu
xHarbour 1.1.0 + FwXh 8.02
xHarbour 1.2.1 + Fwhh 10.6
User avatar
sambomb
 
Posts: 385
Joined: Mon Oct 13, 2008 11:26 am
Location: Itaocara - RJ - Brasil

Re: Centralize image in window

Postby ukoenig » Wed May 06, 2015 10:04 pm

The results

Full screen

Image

Resized

Image

best regards
Uwe :)
Since 1995 ( the first release of FW 1.9 )
i work with FW.
If you have any questions about special functions, maybe i can help.
User avatar
ukoenig
 
Posts: 4043
Joined: Wed Dec 19, 2007 6:40 pm
Location: Germany


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 33 guests