PalBmpDraw transparent on main window with gradient

Re: PalBmpDraw transparent on main window with gradient

Postby Enrico Maria Giordano » Tue Mar 13, 2012 3:11 pm

Did you already tried using only a window and only a dialog? What are the results?

EMG
User avatar
Enrico Maria Giordano
 
Posts: 8725
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Re: PalBmpDraw transparent on main window with gradient

Postby ukoenig » Tue Mar 13, 2012 4:03 pm

Reinaldo,

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

Image

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

Image

A Image-background :

Original Size :

Image

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

Image

Best regards
Uwe :lol:
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: PalBmpDraw transparent on main window with gradient

Postby reinaldocrespo » Tue Mar 13, 2012 4:25 pm

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.
User avatar
reinaldocrespo
 
Posts: 979
Joined: Thu Nov 17, 2005 5:49 pm
Location: Fort Lauderdale, FL

Re: PalBmpDraw transparent on main window with gradient

Postby ukoenig » Tue Mar 13, 2012 4:53 pm

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 :
Code: Select all  Expand view  RUN

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.
User avatar
ukoenig
 
Posts: 4043
Joined: Wed Dec 19, 2007 6:40 pm
Location: Germany

Previous

Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 29 guests