Gradient-Backgrounds for Dialogs ( problem solved )

Gradient-Backgrounds for Dialogs ( problem solved )

Postby ukoenig » Tue Apr 29, 2008 12:36 pm

Hello,

In the Tools i added a background-gradient-option
for dialogs
Everything : colors, pictures, brushes is working
because they have been defined, before i open the dialog.
To calculate a gradient, the dialog has to be open for the
calculation.
The calculation is ok, but the gradient-brush is outside of the dialog
It seems, it is painted on the main-window.

Image

Code: Select all  Expand view  RUN
FUNCTION SHOW_FILE( nPOSITION )
Local oDlg5, oBrush3

IF SD_POS < 8   // Colors
   DEFINE BRUSH oBrush3  COLOR SD_COLOR1
ENDIF
IF SD_POS = 8  // Brushes
   DEFINE BRUSH oBrush3  STYLE BORLAND
ENDIF
IF SD_POS = 9
   DEFINE BRUSH oBrush3  STYLE TILED
ENDIF
IF SD_POS = 10
   DEFINE BRUSH oBrush3  STYLE BRICKS
ENDIF
IF SD_POS = 11 // Brush
   DEFINE BRUSH oBrush3  FILE  cSHOWLOGO
ENDIF
IF SD_POS = 12 // Picture
   IF !FILE( "&cSHOWLOGO" )
      MsgAlert("Your selected Logo : " + cSHOWLOGO + CRLF + ;
                     "is not found in the directory : " + c_path + CRLF + ;
                "When you select the Button INI-FILE-Setting" + CRLF + ;
                "you can choose a different BACKGROUND", "ATTENTION" )
   ENDIF
        DEFINE IMAGE oImage FILENAME cSHOWLOGO
ENDIF
// SD_POS = 13 //  Gradient Horizontal
// SD_POS = 14 //  Gradient Vertical



DEFINE DIALOG oDlg5  RESOURCE "TEST4"  TITLE "Dialog-Preview" PIXEL BRUSH oBrush3  TRANSPARENT

ACTIVATE DIALOG oDlg5 CENTERED ;
ON INIT DBACK_GRD(oDlg5,SD_COLOR1,SD_COLOR2, SD_POS)  // Gradient-Test

RETURN( NIL )

// ---------------------------------------

FUNCTION DBACK_GRD(oDlg5, vCOLOR,bCOLOR,nPOS)

IF nPOS = 13 .or. nPOS = 14
   aRect := GETCLIENTRECT( oDlg5:hWnd )
   hdc := GetDC( oDlg5 )
   nGRADIENT := 0

   IF nPOS = 13  // Horizontal
      nGRADIENT := Gradient( hDC, { aRect[1], aRect[2], aRect[3], aRect[4] }, ;
                                vCOLOR, bCOLOR, .F. )  // .T.  Horizontal
   ENDIF
   IF nPOS = 14 // Vertical
      nGRADIENT := Gradient( hDC,  { aRect[1], aRect[2], aRect[3], aRect[4] }, ;
                                vCOLOR, bCOLOR, .T. )  // .F.  Vertical
   ENDIF

   oBrush3 := TBrush():New( , nGRADIENT ) 
   ReleaseDC( oDlg5:hWnd, hDC )
ENDIF



All other backgrounds are working

Image

I think, the gradient must be defined, before i open the dialog.

Regards

Uwe :o [/code]
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

Gradient as a background in Dialogs

Postby ukoenig » Wed Apr 30, 2008 8:13 am

The problem is solved
As well, i found a solution, to do a gradient starting in the middle.

Image

Code: Select all  Expand view  RUN

FUNCTION SHOW_FILE( nPOSITION )
Local oDlg5

// SD_COLOR1      1. Color
// SD_COLOR2      2. Color
// SD_POS              Horizontal or Vertical
// SD_GRADIENT   Yes or No

DEFINE DIALOG oDlg5  RESOURCE "TEST4"  TITLE "Dialog-Preview" PIXEL TRANSPARENT
....
....
....
....

ACTIVATE DIALOG oDlg5 CENTERED ;
ON PAINT  IIF( SD_GRADIENT = .T., ;
                    DBACK_GRD(oDlg5, hDC, SD_COLOR1,SD_COLOR2, SD_POS), NIL )

RETURN( NIL )

// ---------------------------------------

FUNCTION DBACK_GRD(oDlg5, hDC, vColor, bColor, nPos)
LOCAL oBrush

aRect := GETCLIENTRECT( oDlg5:hWnd )
IF nPos = 13
   nGRADIENT := Gradient( hDC, { aRect[1], aRect[2], aRect[3], aRect[4] }, ;
   vColor, bColor, .F. )  // .T.  Horizontal
ENDIF
IF nPos = 14
   nGRADIENT := Gradient( hDC, { aRect[1], aRect[2], aRect[3], aRect[4] }, ;
   vColor, bColor, .T. )   // .F.  Vertical
ENDIF

// That was the problem !!!
// ----------------------------
DEFINE BRUSH oBrush COLOR nGRADIENT   // !!!!!!!!!!
FillRect( hDC, aRect, oBrush:hBrush )  // !!!!!!!!!!       

ReleaseDC( oDlg5:hWnd, hDC )

RETURN( NIL )



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


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 71 guests