Did you already tried using only a window and only a dialog? What are the results?
EMG
PalBmpDraw transparent on main window with gradient
- Enrico Maria Giordano
- Posts: 8753
- Joined: Thu Oct 06, 2005 8:17 pm
- Location: Roma - Italia
- Has thanked: 1 time
- Been thanked: 4 times
- Contact:
Re: PalBmpDraw transparent on main window with gradient
Reinaldo,
Yes Background and logo are repainted after Wnd-resize.
Screenshots from my Logo-painter :

adjusted Gradient on Window-resize :
( Logo in Design-mode )

A Image-background :
Original Size :

Window and Logo resized.
Background-image adjusted to resized Window.
Logo moved.

Best regards
Uwe
Yes Background and logo are repainted after Wnd-resize.
Screenshots from my Logo-painter :

adjusted Gradient on Window-resize :
( Logo in Design-mode )

A Image-background :
Original Size :

Window and Logo resized.
Background-image adjusted to resized Window.
Logo moved.

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.
i work with FW.
If you have any questions about special functions, maybe i can help.
- reinaldocrespo
- Posts: 979
- Joined: Thu Nov 17, 2005 5:49 pm
- Location: Fort Lauderdale, FL
Re: PalBmpDraw transparent on main window with gradient
Uwe;
Hi and thank you for helping. On the code you provided, the gradient is never redrawn. I built your sample code and was able to see it executing. Gradient is drawn at dialog definition and never altered as the window is resized at runtime, ie. it is a static gradient. Perhaps you are testing with different code...? Check my last self-contained sample. It is quite simple and straight forward.
EMG;
No, I haven't tried either. I'm trying to reproduce a real application with a main window with ribbon bar and many dialogs that occupy the main window space at different times at run-time. I suppose that specific dialog that is used to display a presentation bmp on a gradient could be replaced by a window. That's an idea worth trying.
Reinaldo.
Hi and thank you for helping. On the code you provided, the gradient is never redrawn. I built your sample code and was able to see it executing. Gradient is drawn at dialog definition and never altered as the window is resized at runtime, ie. it is a static gradient. Perhaps you are testing with different code...? Check my last self-contained sample. It is quite simple and straight forward.
EMG;
No, I haven't tried either. I'm trying to reproduce a real application with a main window with ribbon bar and many dialogs that occupy the main window space at different times at run-time. I suppose that specific dialog that is used to display a presentation bmp on a gradient could be replaced by a window. That's an idea worth trying.
Reinaldo.
Re: PalBmpDraw transparent on main window with gradient
Reinaldo,
using it from inside my Tool, it is different ( works on the Main-window ) :
I created a Logo in Design-mode, to test Position and Size on different Backgrounds.
You need a Array for Image Top, Left, Bottom and Right-position to redraw on new Backround.
Also You need a Logical-var, to know if the Logo has to be closed.
I used STATIC :
oLogo
lVisible := .F.
aLogo[4]
aLogo[1] := 120 // Logo Start-top-pos.
aLogo[2] := 50 // Logo-Start-left-pos.
nWColorF := 16443068 // 1. Color
nWColorB := 10899511 // 2. Color
nWGradPos := 0.2 // Gradient-pos
lWDirect := .T. // Direction
cWBrush := "BluStone.Bmp" // Brush
cWImage := "Fantasy2.Jpg" // Image
cWLogo := "Logo7.bmp" // Logo
ACTIVATE WINDOW oWnd MAXIMIZED ;
ON RESIZE ( W_BACKGRD( oWnd, nWStyle, lWDirect, nWColorF, ;
nWColorB, nWGradPos, cWBrush, cWImage ), ;
PAINT_LOGO() )
The needed Functions :
using it from inside my Tool, it is different ( works on the Main-window ) :
I created a Logo in Design-mode, to test Position and Size on different Backgrounds.
You need a Array for Image Top, Left, Bottom and Right-position to redraw on new Backround.
Also You need a Logical-var, to know if the Logo has to be closed.
I used STATIC :
oLogo
lVisible := .F.
aLogo[4]
aLogo[1] := 120 // Logo Start-top-pos.
aLogo[2] := 50 // Logo-Start-left-pos.
nWColorF := 16443068 // 1. Color
nWColorB := 10899511 // 2. Color
nWGradPos := 0.2 // Gradient-pos
lWDirect := .T. // Direction
cWBrush := "BluStone.Bmp" // Brush
cWImage := "Fantasy2.Jpg" // Image
cWLogo := "Logo7.bmp" // Logo
ACTIVATE WINDOW oWnd MAXIMIZED ;
ON RESIZE ( W_BACKGRD( oWnd, nWStyle, lWDirect, nWColorF, ;
nWColorB, nWGradPos, cWBrush, cWImage ), ;
PAINT_LOGO() )
The needed Functions :
Code: Select all | Expand
FUNCTION PAINT_LOGO()
/*
// INCLUDE-Info
// ----------------
@ <nRow>, <nCol> Image [ <oBmp> ] ;
[ <resource: NAME, RESNAME, RESOURCE> <cResName> ] ;
[ <file: FILE, FILENAME, DISK> <cBmpFile> ] ;
[ <NoBorder:NOBORDER, NO BORDER> ] ;
[ SIZE <nWidth>, <nHeight> ] ;
[ <of: OF, WINDOW, DIALOG> <oWnd> ] ;
[ <lClick: ON CLICK, ON LEFT CLICK> <uLClick> ] ;
[ <rClick: ON RIGHT CLICK> <uRClick> ] ;
[ <scroll: SCROLL> ] ;
[ <adjust: ADJUST> ] ;
[ CURSOR <oCursor> ] ;
[ <pixel: PIXEL> ] ;
[ MESSAGE <cMsg> ] ;
[ <update: UPDATE> ] ;
[ WHEN <uWhen> ] ;
[ VALID <uValid> ] ;
[ <lDesign: DESIGN> ] ;
*/
IF lVisible = .T. // close for Repainting
oLogo:End()
ELSE // on first Start, get original Logo-size
DEFINE IMAGE oImage FILENAME c_path + "\Images\" + cWLogo
aLogo[1] := aLogo[1] // Top-pos. on Start
aLogo[2] := aLogo[2] // Left-pos on Start
aLogo[3] := oImage:nWidth
aLogo[4] := oImage:nHeight
oImage:End()
ENDIF
lVisible := .T.
@ aLogo[1], aLogo[2] IMAGE oLogo ;
FILENAME c_Path + "\Images\" + cWLogo ;
NOBORDER ;
SIZE aLogo[3], aLogo[4] ;
OF oWnd ;
PIXEL ;
UPDATE ;
DESIGN ;
TRANSPARENT
oLogo:SetFocus()
oLogo:bMoved := {|| ( aLogo[1] := oLogo:nTop(), ; // Top
aLogo[2] := oLogo:nLeft(), ; // Left
aLogo[3] := oLogo:nWidth(), ;
aLogo[4] := oLogo:nHeight() ) }
oLogo:bResized := {|| ( aLogo[1] := oLogo:nTop(), ; // Top
aLogo[2] := oLogo:nLeft(), ; // Left
aLogo[3] := oLogo:nWidth(), ;
aLogo[4] := oLogo:nHeight() ) }
oLogo:bRClicked := {|| MsgAlert( ( "Top : " + ALLTRIM(STR(oLogo:nTop())) + CRLF + ;
"Left : " + ALLTRIM(STR(oLogo:nLeft())) + CRLF + ;
"Width : " + ALLTRIM(STR(oLogo:nWidth())) + CRLF + ;
"Height : " + ALLTRIM(STR(oLogo:nHeight())) ), "Logo - Pos. and Size" ) }
RETURN ( NIL )
// -------- WINDOW - Background ---------------
FUNCTION W_BACKGRD( oWnd, nStyle, lDirect, nColor1, nColor2, nMove, cBrush, cImage )
local oBrush
IF nStyle = 1 // COLOR
DEFINE BRUSH oBrush COLOR nColor1
// FillRect( oBitmap:hDC, aRect, oNewbrush:hBrush )
ENDIF
IF nStyle = 2 // GRADIENT
aGrad := { { nMove, nColor1, nColor2 }, { nMove, nColor2, nColor1 } }
hDC = CreateCompatibleDC( oWnd:GetDC() )
hBmp = CreateCompatibleBitMap( oWnd:hDC, oWnd:nWidth, oWnd:nHeight )
hBmpOld = SelectObject( hDC, hBmp )
GradientFill( hDC, 0, 0, oWnd:nHeight, oWnd:nWidth, aGrad, lDirect )
DeleteObject( oWnd:oBrush:hBrush )
oBrush := TBrush():New( ,,,, hBmp )
oBrush:Cargo := aGrad
SelectObject( hDC, hBmpOld )
ReleaseDC(hDC)
ENDIF
IF nStyle = 3 // BMP-BRUSH
DEFINE BRUSH oBrush FILE c_path + "\Images\" + cBrush
ENDIF
IF nStyle = 4 // Image ADJUSTED
DEFINE IMAGE oImage FILE c_path + "\Images\" + cImage
oBrush := TBrush():new( ,,,, ResizeBmp( oImage:hBitmap, oWnd:nWidth, oWnd:nHeight , .T. ) )
oImage:End()
ENDIF
oWnd:SetBrush( oBrush )
oBrush:End()
RETURN( NIL )
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.
i work with FW.
If you have any questions about special functions, maybe i can help.