Center bitmap

Center bitmap

Postby cdmmaui » Wed Dec 12, 2007 4:29 am

Hello,

I have a blank area between menu and message and I need to place a bitmap (logo) in this area. Can someone send me code to place a bitmap centerd in maximized window based on length and width of bitmap and length and width of display?

Thank you,
*~*~*~*~*~*~*~*~*~*
Darrell Ortiz
CDM Software Solutions, Inc.
https://www.cdmsoft.com
User avatar
cdmmaui
 
Posts: 689
Joined: Fri Oct 28, 2005 9:53 am
Location: Houston ∙ Chicago ∙ Los Angeles ∙ Miami ∙ London ∙ Hong Kong

Postby James Bott » Wed Dec 12, 2007 8:50 am

Darrell,

Try the example below.

James

Code: Select all  Expand view  RUN
> #INCLUDE "C:\FW192\INCLUDE\FIVEWIN.CH"
> *
> STATIC oWnd,nWndWid,nWndHgt
> *
> FUNCTION Main()
> DEFINE WINDOW oWnd;
>             FROM 1,2 TO MaxRow()-3,MaxCol()-2;
>              TITLE "BMP Logo Centering"
> ACTIVATE WINDOW oWnd ON INIT (Calc_Wnd(),Disp_Bmp())
> RETURN nil
> *
> STATIC FUNCTION Disp_Bmp()
> LOCAL oBmp,nRow,nCol,nBmpWid,nBmpHgt,cFile:="TEST.BMP"
> IF File(cFile)
>   DEFINE BITMAP oBmp FILE cFile OF oWnd
>   nRow = nWndHgt/2 - oBmp:nHeight/2
>   nCol = nWndWid/2 - oBmp:nWidth/2
>   oBmp:End()
>   @ nRow,nCol BITMAP oBmp FILE cFile PIXEL NOBORDER OF oWnd
> ENDIF
> RETURN nil
> *
> STATIC FUNCTION Calc_Wnd()
> LOCAL x1,y1,x2,y2,aWind:=oWnd:GetRect()
> x1 = aWind[1]
> y1 = aWind[2]
> x2 = aWind[3]
> y2 = aWind[4]
> nWndHgt = x2 - x1
> nWndWid = y2 - y1
> RETURN nil
> **************
>
> Hope this helps.
>
> Gary Beam
> Extensions Software Corp.
> http://www.ext.com
User avatar
James Bott
 
Posts: 4840
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA

Postby James Bott » Wed Dec 12, 2007 8:58 am

Darrell,

I found some old code where I did it like this. This code will redraw the bitmap centered whenever the window is resized.

James

Code: Select all  Expand view  RUN
     ACTIVATE WINDOW ownd maximized ;
          on paint (PalBmpDraw( oWnd:oWndClient:hDC, (oWnd:nHeight/2-oBmp:nHeight/2)-50,(oWnd:nWidth/2-oBmp:nWidth/2), oBmp:hBitmap, oBmp:hPalette )
User avatar
James Bott
 
Posts: 4840
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA

Postby cdmmaui » Thu Dec 13, 2007 1:22 pm

Hi James,

Thank you very much!
*~*~*~*~*~*~*~*~*~*
Darrell Ortiz
CDM Software Solutions, Inc.
https://www.cdmsoft.com
User avatar
cdmmaui
 
Posts: 689
Joined: Fri Oct 28, 2005 9:53 am
Location: Houston ∙ Chicago ∙ Los Angeles ∙ Miami ∙ London ∙ Hong Kong


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 31 guests