Another erratic problem: sometimes the dialog with the gradient suddenly becomes transparent (never saw under XP, only under Vista and Win7). Any ideas?
EMG
Another erratic problem: sometimes the dialog with the gradient suddenly becomes transparent (never saw under XP, only under Vista and Win7). Any ideas?
EMG
Can you make it more clear please? Does the dialog suddenly behave like a transparent dialog? Or the entire dialog becomes transparent showing the background behind the dialog like when using null brush?
Can you post a sample code?
nageswaragunupudi wrote:Can you make it more clear please? Does the dialog suddenly behave like a transparent dialog? Or the entire dialog becomes transparent showing the background behind the dialog like when using null brush?
nageswaragunupudi wrote:Can you post a sample code?
//--------- Backgrounds ------------------------
// c_path := CURDRIVE() + ":\" + GETCURDIR()
// Samples :
// ACTIVATE WINDOW oWnd MAXIMIZED ;
// ON INIT WND_BRUSH( oWnd, ; // Object to fill
// nWStyle, ; // 1=Color, 2=Gradient, 3=Brush, 4=Image, 5-7= Pred.-styles
// lWGrad, ; // .T. = vertical, .F. = horizontal
// nWColorF, ; // 1.Gradient- or plain Color with Style = 1
// nWColorB, ; // 2. Gradient-color
// nWGradPos, ; // Color-position 0 - 1
// cWBrush, ; // Brush
// cWImage ) // Image
// Embedded inside the Dialog, can be changed at Runtime
//
// DEFINE DIALOG oDlg SIZE 950, 600 OF oWnd PIXEL TRANSPARENT ;
// FONT oFont1 TITLE 'Title / xBrowse and Border'
//
// for Brush and Image only Filename, no Path
// WND_BRUSH( oDlg, nDStyle, lDGrad, nDColorF, nDColorB, nDPos, cDBrush, cDImage )
//
// ACTIVATE DIALOG oDlg CENTERED NOWAIT ;
FUNCTION WND_BRUSH( cControl, nStyle, lDirect, nVColor, nBColor, nMove, cBrush, cImage )
LOCAL hDC, oBrush, oTmp
LOCAL aRect := GETCLIENTRECT( cControl )
LOCAL aGrad := { { nMove, nVColor, nBColor }, { nMove, nBColor, nVColor } }
IF nStyle = 1 // Color
  DEFINE BRUSH oBrush COLOR nVColor
  SET BRUSH OF cControl TO oBrush
  RELEASE BRUSH oBrush
ENDIF
IF nStyle = 2 // Gradient
  hDC = CreateCompatibleDC( cControl:GetDC() )
  hBmp = CreateCompatibleBitMap( cControl:hDC, cControl:nWidth, cControl:nHeight )
  hBmpOld = SelectObject( hDC, hBmp )
  GradientFill( hDC, 0, 0, cControl:nHeight, cControl:nWidth, aGrad, lDirect )
  DeleteObject( cControl:oBrush:hBrush )
  oBrush := TBrush():New( ,,,, hBmp )
  oBrush:Cargo  := aGrad
  SelectObject( hDC, hBmpOld )
  cControl:ReleaseDC()
  cControl:SetBrush( oBrush )
  RELEASE BRUSH oBrush
ENDIF
IF nStyle = 3 // BMP-Brush
  IF File( c_path + "\bitmaps\" + cBrush )
    DEFINE BRUSH oBrush FILE c_path + "\Bitmaps\" + cBrush
    SET BRUSH OF cControl TO oBrush
    RELEASE BRUSH oBrush
  ELSE
    MsgAlert( "Cannot load : " + CRLF + ;
         c_path + "\bitmaps\" + cDBrush, "Error" ) Â
  ENDIF
ENDIF
IF nStyle = 4 // Image
  IF File( c_path + "\bitmaps\" + cImage )
    DEFINE BRUSH oBrush FILE c_path + "\Bitmaps\" + cImage
    SET BRUSH OF cControl TO oBrush
    RELEASE BRUSH oBrush
  ELSE
    MsgAlert( "Cannot load : " + CRLF + ;
         c_path + "\bitmaps\" + cDImage, "Error" ) Â
  ENDIF
ENDIF
IF nStyle = 5 Â // Style 1
  DEFINE BRUSH oBrush STYLE BORLAND
  SET BRUSH OF cControl TO oBrush
    RELEASE BRUSH oBrush
ENDIF
IF nStyle = 6 Â // Style 2
  DEFINE BRUSH oBrush STYLE BRICKS
  SET BRUSH OF cControl TO oBrush
    RELEASE BRUSH oBrush
ENDIF
IF nStyle = 7 Â // Style 3
  DEFINE BRUSH oBrush STYLE TILED
  SET BRUSH OF cControl TO oBrush
    RELEASE BRUSH oBrush
ENDIF
RETURN NILukoenig wrote:Enrico,
I'm using VISTA.
I changed my Background-function and it works on Windows and Dialogs without Problem.
Enrico,
Please post the screenshot if possible, thanks ![]()

Mr. EMG
Can we also know the FWH version used to build the application?
I expect that the brush was created in the ON INIT clause using the logic that was popular till gradient brushes were introduced.
I have a feeling that the way the gradient brushes were created in the init clause and the way the TBrush class compares a new brush with earlier brushes sometimes could result in destruction of the previous gradient brush.
Can we also see a sample that shows your usual way of creating the gradient brush in the init clause?
I think the present implementation of gradient/image brushes would not have such a problem.
No, I'm using the present implementation as available in latest FWH release.
EMG
Enrico Maria Giordano wrote:No, I'm using the present implementation as available in latest FWH release.
EMG
Ok, no problems.
EMG
I do not know if you need to help
I use a gradient (first attempts), and sometimes I was going ...
Then I removed the "IF" and now all ok
STATIC FUNCTION GradBrush( oDlgK,difc,colfinA,colfinB,tgr )
local hDC, hBmp, hBmpOld,obrush
Gradient( hDC, {0, 0, oDlgK:nHeight, oDlgK:nWidth }, rgb(250, 255, 255),colfinB ,.T. )
DeleteObject( oDlgK:oBrush:hBrush )
oDlgK:oBrush:hBitmap = hBmp
oDlgK:oBrush:hBrush = CreatePatternBrush( hBmp )
SelectObject( hDC, hBmpOld )
oDlgK:ReleaseDC()
endif
RETURN NIL
Saluti
Stefano
Any news?
EMG