Page 1 of 1
BACKGROUND ON A WINDOW
Posted: Thu Mar 06, 2008 11:52 am
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 ?
Posted: Thu Mar 06, 2008 11:58 am
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
Posted: Thu Mar 06, 2008 1:03 pm
by Antonio Linares
Silvio,
Do MsgInfo( oBmpSFONDO:hBitmap ) to check that you have a valid handle there.
Posted: Thu Mar 06, 2008 2:29 pm
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
Regards.
Manuel Mercado
Posted: Fri Mar 07, 2008 9:50 am
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
Posted: Fri Mar 07, 2008 11:25 am
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