BACKGROUND ON A WINDOW

Post Reply
User avatar
Silvio
Posts: 3107
Joined: Fri Oct 07, 2005 6:28 pm
Location: Teramo,Italy

BACKGROUND ON A WINDOW

Post by Silvio »

I must insert an image jpg as background in a window
but I know this only for bitmap and not run for jpg

sample
#define OSFONDO "D48.JPG"
...
DEFINE BITMAP oBmpSFONDO SFONDO FILENAME OSFONDO

...

ACTIVATE WINDOW oWChld MAXIMIZED;
ON PAINT (showBitmaps( oWnd, hDC, oBmpSFONDO:hBitmap,oBmpSFONDO ) )

// this is good for BMPs

STAT FUNC shwBitmaps( oWnd, hDC, hBmp, oBitmap )
LOCAL nTop := 0
LOCAL nLeft := 0
LOCAL nWidth := oWnd:nWidth()
LOCAL nHeight := oWnd:nHeight()
Local oSay
IF hBmp = 0
RETURN NIL
ENDIF
PalBmpDraw( hDC, nTop, nLeft, hBmp , , nWidth, nHeight )
Return NIL



How I can make to show a jpg ?
Best Regards, Saludos

Falconi Silvio
User avatar
Silvio
Posts: 3107
Joined: Fri Oct 07, 2005 6:28 pm
Location: Teramo,Italy

Post by Silvio »

I made also this :

oBmpSFONDO = TImage():Define( , OSFONDO )

oWnd:oWndClient:bPainted := {|hDC| PalBmpDraw( hDC, 0, 0,oBmpSFONDO:hBitmap,,;
oWnd:oWndClient:nWidth, oWnd:oWndClient:nHeight,, .T.) }


but not run
Best Regards, Saludos

Falconi Silvio
User avatar
Antonio Linares
Site Admin
Posts: 37481
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Contact:

Post by Antonio Linares »

Silvio,

Do MsgInfo( oBmpSFONDO:hBitmap ) to check that you have a valid handle there.
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
mmercado
Posts: 782
Joined: Wed Dec 19, 2007 7:50 am
Location: Salamanca, Gto., México

Post by mmercado »

Hi Silvio:

This works for me:

Code: Select all

      @  0,  0 IMAGE oImg FILENAME C:\MG\IMAGES\MGLogom.jpg" OF oWnd:oWndClient ;
               SIZE GetSysMetrics( 0 ), GetSysMetrics( 17 ) - GetSysMetrics( 15 ) - oBar:nHeight() - ;
                    oWnd:oMsgBar:nHeight() PIXEL ADJUST
Image
Regards.

Manuel Mercado
User avatar
Silvio
Posts: 3107
Joined: Fri Oct 07, 2005 6:28 pm
Location: Teramo,Italy

Post by Silvio »

I try this sample but not run ok

Code: Select all

#include "FiveWin.ch"



#define OSFONDO   "D48.JPG"


  static oWnd



function Main()

   local oBar

   DEFINE WINDOW oWnd TITLE "Test" MDI ;
      MENU BuildMenu()

 DEFINE BUTTONBAR oBar 3DLOOK BUTTONSIZE 39,39 OF oWnd 2007


SET MESSAGE OF oWnd TO "test image" NOINSET 2007

   ACTIVATE WINDOW oWnd

return nil

function BuildMenu()

   local oMenu

   MENU oMenu
      MENUITEM "Test"
      MENU
         MENUITEM "Beach" ACTION Beach()
      ENDMENU
      oMenu:AddMdi()
   ENDMENU

return oMenu

function beach()
 LOCAL oWChld

DEFINE WINDOW oWChld OF oWnd MDICHILD  ;
TITLE 'Beach Plan'


@  0,  0 IMAGE oImg FILENAME OSFONDO OF  oWChld:oWndClient ;
               SIZE GetSysMetrics( 0 ), GetSysMetrics( 17 ) - GetSysMetrics( 15 ) - oWnd:oBar:nHeight() - ;
      oWnd:oMsgBar:nHeight() PIXEL ADJUST

          cRegistro := "OMBRELLONI : "
          cAutore   := "Liberi  : "
          cSyst     := "Occupati : "

 SET MESSAGE OF  oWChld TO "" NOINSET
 DEFINE MSGITEM OF  oWChld:oMSGBAR  prompt cregistro  size 150 ACTION    nil
 DEFINE MSGITEM OF  oWChld:oMSGBAR  prompt  cAutore  size 150 ACTION    nil
 DEFINE MSGITEM OF  oWChld:oMSGBAR  prompt cSyst  size 150 ACTION    nil

ACTIVATE WINDOW oWChld MAXIMIZED

 return nil
to try you can download the image from www.bpascal.it/d48.jpg
Best Regards, Saludos

Falconi Silvio
User avatar
mmercado
Posts: 782
Joined: Wed Dec 19, 2007 7:50 am
Location: Salamanca, Gto., México

Post by mmercado »

Hi Silvio:
Silvio wrote:I try this sample but not run ok
For a MDICHILD try this:

@0,0 IMAGE oImg FILENAME OSFONDO OF oWChld SIZE oWChld:nWidth, oWChld:nHeight PIXEL ADJUST

Just remember that oImg is not a brush of oWChld, then other controls for this child window should belong to oImg instead of oWChld

Regards

Manuel Mercado
Post Reply