FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour SAY-color on folders
Posts: 1048
Joined: Mon Oct 24, 2005 09:54 AM
SAY-color on folders
Posted: Thu Mar 18, 2010 03:55 PM

REDEFINE SAY PROMPT "Test" ID 110 OF oDlg COLOR CLR_WHITE,CLR_BLUE is not functioning on standard folder-pages. Only the text-color is accepted. On normal dialogs, all is ok.

Regards,
Günther
---------------------------------
office@byte-one.com
Posts: 1048
Joined: Mon Oct 24, 2005 09:54 AM
Re: SAY-color on folders
Posted: Tue Mar 23, 2010 08:35 PM

Nobody have an answer?

Regards,
Günther
---------------------------------
office@byte-one.com
Posts: 2365
Joined: Wed Nov 02, 2005 11:46 PM
Re: SAY-color on folders
Posted: Tue Mar 23, 2010 11:32 PM

Hello

please post a image or test

thanks

Posts: 4043
Joined: Wed Dec 19, 2007 06:40 PM
Re: SAY-color on folders
Posted: Thu Mar 25, 2010 09:15 AM
Hello Günther,

I noticed the same Problem as well, to display a colored SAY-Background in Folders.
Before I used a SAY to display the Font ( Transparent for Background was OK )
But now I have to show a Font with a defined Style and Color on a colored Background
for my Excel-Headlines and Cells.
I found a better Solution to display a Text, changing at Runtime : Text, Font, Textcolor and Background.
Using : REDEFINE BITMAP, I can center the Text or show it on any needed Position.
I think it is a good Solution, to solve the Problem. For me it works better, than using a SAY.
You can define any Background, like Image, Brush, Gradient or Color. Not possible, using a SAY.
To display different ( changed ) Values => oBMP:Refresh()



Code (fw): Select all Collapse
...
// ------  Font - Preview ----------------------
// "Blanc" = any small BMP from Resources.
REDEFINE BITMAP oBMP  ID 350  ADJUST  RESOURCE "Blanc"  OF oFld:aDialogs[1] 

oBMP:bPainted := { |hDC| ;
DRAW_TITLE( oBMP, ;     // BMP
   hDC, ;           // hDC
   .T., ;           // Horiz. or Vert.
   B_COLOR, ;       // 1. Grad-Color 
   B_COLOR, ;       // 2. Grad-Color ( same like 1. Color for non Gradient )
   0.50, ;          // Gradient-Color-Pos.
   0, ;         // Text-Pos from left ( 0 = centered )
   oTextfont, ;     // defined Font
   T_COLOR, ;       // Font-Color
   "Fonttest" ) }     // can be a Var 
...
...

//------------- Title ( the Function uses Gradient or Color ) -----------
//--- for Color : nVcolor and nBcolor are the same -------------------

FUNCTION DRAW_TITLE( oBitmap, hDC, lDirect,nVColor, ;
   nBColor, nMove, nLeft, oFont, nTColor, cTitle ) 
LOCAL aGrad := { { nMove, nVColor, nBColor }, { nMove, nBColor, nVColor } }
LOCAL aRect := GETCLIENTRECT( oBitmap:hWnd )
LOCAL oNewBrush

DEFINE BRUSH oNewBrush ;
COLOR GradientFill( hDC,  0, 0, aRect[3], aRect[4], aGrad, lDirect )
hOldFont := SelectObject( hDC, oFont:hFont ) 
nTXTLG :=  GettextWidth( hDC, cTitle ) 
nBMPLONG  := oBitmap:Super:nWidth() 
nBMPHIGHT := oBitmap:Super:nHeight() 
nFONTHIGHT := oFont:nInpHeight * -1 
IF nLEFT = 0
   nLEFT := (nBMPLONG - nTXTLG) / 2  
ENDIF
nNEWHIGHT := nFONTHIGHT 
nTOP := (nBMPHIGHT - nNEWHIGHT) / 2 
SetTextColor( hDC,nTColor) 
SetBkMode( oBitmap:hDC, 0 ) 
TextOut( hDC, nTOP, nLEFT, cTitle ) 
RELEASE BRUSH oNewbrush

RETURN NIL


Using Brushes.
We don't want the Brush adjusted to Size < Tiled > must be calculated.
I tested with :
DEFINE BRUSH oImage FILENAME cBitmap
SET BRUSH OF oBitmap TO oImage
but it doesn't work like expected.



Code (fw): Select all Collapse
...
...
REDEFINE BITMAP oBMP  ID 350  ADJUST  RESOURCE "Blanc"  OF oFld:aDialogs[1] 
oBMP:bPainted := { |hDC|DRAW_TILED( ;
oBMP, ; // Bitmap
hDC, ; // hDC
oTextfont, ; // Font
c_path + "\System\blustone.bmp", ; // BMP-file
"Fonttest", ; // Text
0, ; // Orientation from Left, 0 = Centered
128 ) } // Textcolor
...
...

// ----------  TILED --------------

FUNCTION DRAW_TILED( oBitmap, hDC, oTextfont, cBitmap, cTitle, nLeft, nTColor )
LOCAL oImage, nRow := 0, nCol := 0, n

IF FILE( cBitmap )
   DEFINE BITMAP oImage FILENAME cBitmap
   aRect := GETCLIENTRECT( oBitmap:hWnd )
   nHeight := oImage:nHeight
   nWidth := oImage:nWidth
   IF aRect[3] > 0 
      DO WHILE nRow < aRect[3]
         nCol = 0
         DO WHILE nCol < aRect[4]
            PalBmpDraw( hDC, nRow, nCol, oImage:hBitmap )
            nCol += nHeight
         ENDDO
         nRow += nWidth
      ENDDO
   ELSE
      MsgAlert( "Not possible to use Picture " + CRLF + ;
      cBitmap + CRLF + ; 
      "for TILED-selection !", "ATTENTION" ) 
   ENDIF

   hOldFont := SelectObject( hDC, oTextFont:hFont ) 
   nTXTLG :=  GettextWidth( hDC, cTitle ) 
   nBMPLONG  := oBitmap:Super:nWidth() 
   nBMPHIGHT := oBitmap:Super:nHeight() 
   nFONTHIGHT := oTextFont:nInpHeight * -1 
   IF nLEFT = 0
      nLEFT := (nBMPLONG - nTXTLG) / 2  
   ENDIF
   nNEWHIGHT := nFONTHIGHT 
   nTOP := (nBMPHIGHT - nNEWHIGHT) / 2 
   SetTextColor( hDC,nTColor) 
   SetBkMode( oBitmap:hDC, 0 ) 
   TextOut( hDC, nTOP, nLEFT, cTitle ) 
   oBitmap:ReleaseDC()
ELSE
   IF !EMPTY(cBitmap)
       MsgAlert( "File : " + cBitmap + CRLF + ;
       "does not exist" + CRLF + ; 
       "to create Background !", "ATTENTION" ) 
   ENDIF
ENDIF

RETURN( NIL )


A adjusted JPG-Image with centered Text.



Code (fw): Select all Collapse
...
...
REDEFINE BITMAP oBMP  ID 350  ADJUST  RESOURCE "Blanc"  OF oFld:aDialogs[1] 
oBMP:bPainted := { |hDC|DRAW_IMG( ;
oBMP, ; // Bitmap
hDC, ; // hDC
oTextfont, ; // Font
c_path + "\System\fantasy5.jpg", ; // BMP-file
"Fonttest", ; // Text
0, ; // Orientation from Left, 0 = Centered
16777215 ) } // Textcolor
...
...

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

FUNCTION DRAW_IMG( oBitmap, hDC, oTextfont, cBitmap, cTitle, nLeft, nTColor )
LOCAL oImage

IF FILE( cBitmap )
   DEFINE IMAGE oImage FILENAME cBitmap
   aRect := GETCLIENTRECT( oBitmap:hWnd )
   PalBmpDraw( hDC, 0, 0, oImage:hBitmap, , aRect[4], aRect[3] ) 
    
   hOldFont := SelectObject( hDC, oTextFont:hFont ) 
   nTXTLG :=  GettextWidth( hDC, cTitle ) 
   nBMPLONG  := oBitmap:Super:nWidth() 
   nBMPHIGHT := oBitmap:Super:nHeight() 
   nFONTHIGHT := oTextFont:nInpHeight * -1 
   IF nLEFT = 0
      nLEFT := (nBMPLONG - nTXTLG) / 2  
   ENDIF
   nNEWHIGHT := nFONTHIGHT 
   nTOP := (nBMPHIGHT - nNEWHIGHT) / 2 
   SetTextColor( hDC,nTColor) 
   SetBkMode( oBitmap:hDC, 0 ) 
   TextOut( hDC, nTOP, nLEFT, cTitle ) 

   oBitmap:ReleaseDC()
ELSE
   IF !EMPTY(cBitmap)
      MsgAlert( "File : " + cBitmap + CRLF + ;
         "does not exist" + CRLF + ; 
         "to create Background !", "ATTENTION" ) 
   ENDIF
ENDIF

RETURN( NIL )


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.

Continue the discussion