After spending some hours with testing,
I think, it might be useful, to show a overview of the functions,
to show the different backgrounds with combinations
( Gradient, Brushes, Images and combinations with Alpha-BMP's )
from inside a MDI or MODAL-window and Dialog.
I'm still busy with testing and it is not finished yet.
There will be a Browser-selection with all 30 combinations.
For users with older FWH-versions and no Gradient-support,
the use of a extra Gradient-function is included.
For the moment, I just want to show the functions and how it works.
This post will be updated after all tests are done.
Source-Version : 13.01.2009
- Code: Select all Expand view
// ------- WINDOW - TEST ( MDI ) --------------------------
FUNCTION NEW_WIN()
LOCAL oWnd1, oBtn1, oImage1, oBmp1, oBar1, oBtn2, oBtn3
// ( 6 ) Alpha-Blended-BMP
// -----------------------------
cALPHA := ALLTRIM( W_C_ALPHA )
IF !EMPTY ( cALPHA )
DEFINE BITMAP oBmp1 FILENAME "&c_pfad\IMAGE\" + cALPHA
ENDIF
// MDI-Window
// ---------------
DEFINE WINDOW oWnd1 TITLE "Background for Windows" MDI MENU TMenu():New()
DEFINE BUTTONBAR oBar1 OF oWnd1 SIZE 60, 60 2007 RIGHT
oBar1:bClrGrad := { | lInvert | If( ! lInvert, ;
{ { 0.90,11892819,16777215 },{ 0.90,16777215,11892819 } },;
{ { 0.50,128,16777215 }, { 0.50,16777215,128 } } ) }
oBar1:nClrText := 0
DEFINE BUTTON oBtn2 OF oBar1 ACTION NIL;
RESOURCE "floppy"
DEFINE BUTTON oBtn3 OF oBar1 ACTION oWnd1:End() ;
RESOURCE "quit" PROMPT "Exit" TOOLTIP "Close Window-Test"
oBtn2:Hide()
// ----- Table of Color- Brush and Image - Selection -------------
// -----------------------------------------------------------------------
// 1", "Black" }
// 2", "White" }
// 3", "Blue" }
// 4", "Blue+" }
// 5", "Green" }
// 6", "Green+" }
// 7", "Red" }
// 8", "Red+" }
// 9", "Yellow" }
// 10", "Select" }
// -------------------
// 11", "Borld." }
// 12", "Tiled" }
// 13", "Bricks" }
// -------------------
// 14", "BACKGRD." }
// -------------------
// -------------------
// Colors
// ---------
IF W_POS1 < 11 .and. W_STYLE = 2 // Color
W_GRAD( hDC, oWnd1 )
ENDIF
// Picture Background
// --------------------------
*IF W_POS1 = 14
* W_IMAGE( oWnd1 )
*ENDIF
// Brush
// --------
*IF W_POS1 > 10 .and. W_POS1 < 14
* W_BRUSH( oWnd1 )
*ENDIF
// W_POS1 < 11 ( GRADIENT and COLORS )
// W_POS1 > 10 .and. W_POS1 < 14 ( BRUSH )
// W_POS1 = 14 .and. W_LOGOTYP = "I" ( IMAGE )
// !EMPTY( W_C_ALPHA ) ( ALPHA-BLENDED BMP )
ACTIVATE WINDOW oWnd1 MAXIMIZED ;
ON INIT ( NEW_COLOR1a(oWnd1), IIF( lPREVIEW = .T., D_PREVIEW(oWnd1), NIL ) ) ;
ON PAINT ( IIF( W_POS1 < 11.and. W_STYLE = 1, W_GRAD( hDC, oWnd1 ), NIL ), ;
IIF( W_POS1 = 14, W_IMAGE( oWnd1 ), NIL ), ;
IIF( W_POS1 > 10 .and. W_POS1 < 14, W_BRUSH( oWnd1 ), NIL ), ;
IIF( !EMPTY( W_C_ALPHA ), ;
ABPaint( hDC, W_L_ALPHA, W_T_ALPHA, oBmp1:hBitmap, 220 ), NIL ) )
RETURN NIL
// --------- ( 1 + 3 ) GRADIENT and COLORS --------------------------------------
// W_MOVE = Color-Gradient-Position
// W_COLOR1 = 1. Gradient-Color or Mono-Color
// W_COLOR2 = 2. Gradient-Color
// W_STYLE = Horizontal or Vertical
STATIC FUNCTION W_GRAD( hDC, oWnd1 )
local oNewbrush
local aGrad := { { W_MOVE, W_COLOR1, W_COLOR2 }, ;
{ W_MOVE, W_COLOR2, W_COLOR1 } }
IF W_STYLE = 1
IF W_DIRECT = 1
IF S_FWHVERS < 7.09
DegradeW ( hDC, oWnd1 )
ENDIF
IF S_FWHVERS >= 7.09 .and. S_FWHVERS < 8.07
Gradient( hDC, { 0, 0, oWnd1:nHeight, oWnd1:nWidth }, W_COLOR1, W_COLOR2, .T. )
ENDIF
IF S_FWHVERS >= 8.07
GradientFill( hDC, 0, 0, oWnd1:nHeight, oWnd1:nWidth, aGrad, .T. )
ENDIF
ELSE
IF S_FWHVERS < 7.09
DegradeW ( hDC, oWnd1 )
ENDIF
IF S_FWHVERS >= 7.09 .and. S_FWHVERS < 8.07
Gradient( hDC, { 0, 0, oWnd1:nHeight, oWnd1:nWidth }, W_COLOR1, W_COLOR2, .F. )
ENDIF
IF S_FWHVERS >= 8.07
GradientFill( hDC, 0, 0, oWnd1:nHeight, oWnd1:nWidth, aGrad, .F. )
ENDIF
ENDIF
ELSE
DEFINE BRUSH oNewBrush COLOR W_COLOR1
SET BRUSH OF oWnd1 TO oNewBrush
*FillRect( oWnd1:hDC, 0, 0, oWnd1:nHeight, oWnd1:nWidth, oNewbrush:hBrush )
RELEASE BRUSH oNewbrush
ENDIF
RETURN NIL
//--------- ( 4 + 5 ) IMAGES and BMP-Brush ------------------------
STATIC FUNCTION W_IMAGE( oWnd1 )
LOCAL oImage1
// Selected Image
// --------------------
cNEWLOGO := "&c_pfad\IMAGE\" + ALLTRIM(W_LOGO)
// Brush
// --------
IF W_LOGOTYP = "B" // Brush
IF ! Empty( cNEWLOGO ) .and. File( "&cNEWLOGO" )
DEFINE BRUSH oImage1 FILE "&cNEWLOGO"
SET BRUSH OF oWnd1 TO oImage1
ELSE
MsgAlert("No file selected !","Attention" )
ENDIF
ENDIF
// Image
// --------
IF W_LOGOTYP = "I"
IF ! Empty( cNEWLOGO ) .and. File( "&cNEWLOGO" )
ScreenWidth := GetSysMetrics(0)
ScreenHeight := GetSysMetrics(1) - 20
@ 0, 0 IMAGE oImage1 SIZE ScreenWidth,ScreenHeight OF oWnd1 ADJUST
oImage1:Progress( .f. )
oImage1:LoadBmp( "&cNEWLOGO" )
ELSE
MsgAlert("No file selected !","Attention" )
ENDIF
ENDIF
RETURN NIL
//-------- ( 2 ) BRUSHES -------------------------
STATIC FUNCTION W_BRUSH( oWnd1 )
LOCAL oNewbrush
IF W_POS1 = 11
DEFINE BRUSH oNewBrush STYLE ("BORLAND")
ENDIF
IF W_POS1 = 12
DEFINE BRUSH oNewBrush STYLE ("TILED")
ENDIF
IF W_POS1 = 13
DEFINE BRUSH oNewBrush STYLE ("BRICKS")
ENDIF
SET BRUSH OF oWnd1 TO oNewBrush
RELEASE BRUSH oNewbrush
RETURN NIL
// ------ GRADIENT-Function for not supported FWH-Versions -------
STATIC FUNCTION DegradeD ( hDC, oDlg )
LOCAL nStep , nStepY
LOCAL oBrush
LOCAL i, r,g,b
LOCAL r0,g0,b0
LOCAL r1, g1, b1
LOCAL rD, gD, bD
LOCAL aRect := GETCLIENTRECT( oDlg:hWnd )
nStep := ( aRect[ 3 ] - aRect[ 1 ] )
nStepY := ( aRect[ 3 ] - aRect[ 1 ] ) / nStep
aRect[ 3 ] = aRect[ 1 ] + nStepY
r0 := nRGBRed (D_COLOR1)
g0 := nRGBGreen (D_COLOR1)
b0 := nRGBBlue (D_COLOR1)
r1 := nRGBRed (D_COLOR2)
g1 := nRGBGreen (D_COLOR2)
b1 := nRGBBlue (D_COLOR2)
rD := r1-r0
gD := g1-g0
bD := b1-b0
r := 256*rD/Max(nStep,1)
g := 256*gD/Max(nStep,1)
b := 256*bD/Max(nStep,1)
r0*=256
g0*=256
b0*=256
FOR i = 0 TO nStep-1 STEP nStepY
r0 += r
g0 += g
b0 += b
DEFINE BRUSH oBrush COLOR nRGB( r0/256, g0/256, b0/256 )
FILLRECT( hDC, aRect, oBrush:hBrush )
RELEASE BRUSH oBrush
aRect[ 1 ] += nStepY
aRect[ 3 ] += nStepY
NEXT
RETURN (nil)
Regards
Uwe