hi,
comercial wrote:Can you post the prg sample of "OD_Menu.JPG"
This menu have a nice gradient style.
the Gradient is made this Way
use c:\ALASKA\XPPW32\Source\samples\basics\OWNERDRW\MENUS.PRG
locate in METHOD XbpImageMenu:DrawItem( oPS, aInfo )
Code: Select all
line 392
aItem := ::getItem( aInfo[1] )
write before line 392
Code: Select all
IF nFill = GRA_FILL
aAttrs := ARRAY( GRA_AA_COUNT )
aAttrs[ GRA_AA_COLOR ] := SPBG_MENU()
aAttrs[ GRA_AA_BACKCOLOR ] := IF( EMPTY( nRGB ), SPBG_MENU(), nRGB )
aPrev := GraSetAttrArea( oPS, aAttrs )
IF IsThemeActive( .F. ) == .T.
GraGradientBox( oPS, { nGraWide, aItemBG[ 2 ] },;
{ aItemBG[ 3 ], aItemBG[ 4 ] + 1 }, 0, NIL )
ELSE
GraGradientBox( oPS, { aItemBG[ 1 ], aItemBG[ 2 ] },;
{ aItemBG[ 3 ], aItemBG[ 4 ] }, 0, NIL )
ENDIF
GraSetColor( oPS, aPrev[ 1 ], aPrev[ 2 ] )
ENDIF
my GraGradientBox() is different to Alaska v1.9.355 Version, it work also with v1.9.331 and on "WIN9X" OS()
see #IF XPPVER > 01900331
Code: Select all
FUNCTION GraGradientBox( oPS, aStart, aEnd, nMode, xSpec, nDirection )
#define GRADIENT_FILL_RECT_H 0
#define MENU_BARTEXT GRA_CLR_BLACK
LOCAL cOS := OS( OS_PRODUCT )
LOCAL nHDC := 0
LOCAL nCookie
LOCAL aPos1, aPos2
LOCAL aVertex
LOCAL aGRect
LOCAL aRGBStart
LOCAL aRGBEnd
LOCAL aAttrs
LOCAL nVertLen
LOCAL nGRectLen
STATIC cTemplate
DEFAULT nDirection TO 0 // 0=horiz, 1=vert, 2=triangle
UNUSED( nMode )
UNUSED( xSpec )
aAttrs := GraSetAttrArea( oPS )
IF GraIsRGBColor( aAttrs[ GRA_AA_COLOR ] ) == .F. .OR. ;
GraIsRGBColor( aAttrs[ GRA_AA_BACKCOLOR ] ) == .F.
RETURN .F.
ENDIF
#IF XPPVER > 01900331
// use Alaska GraGradient() since 1.9.355
DO CASE
CASE nDirection == 0
GraGradient( oPS, aStart, { aEnd }, { SPBG_MENU(), SPBG_WHITE(), MENU_BARTEXT }, nDirection )
CASE nDirection == 1
GraGradient( oPS, aStart, { aEnd }, { SPBG_WHITE(), SPBG_MENU(), MENU_BARTEXT }, nDirection )
CASE nDirection == 2
GraGradient( oPS, aStart, { aEnd }, { SPBG_MENU(), MENU_BARTEXT, SPBG_WHITE() }, nDirection )
ENDCASE
#ELSE
aRGBStart := GraGetRGBIntensity( aAttrs[ GRA_AA_COLOR ] )
aRGBEnd := GraGetRGBIntensity( aAttrs[ GRA_AA_BACKCOLOR ] )
AEVAL( aRGBStart, { | x | INT( x := 65280 * x / 255 ) },,, .T. )
AEVAL( aRGBEnd , { | x | INT( x := 65280 * x / 255 ) },,, .T. )
aPos1 := oPS:MapPoint( aStart, .T., .T. )
aPos2 := oPS:MapPoint( aEnd, .T., .T. )
aVertex := L2BIN( aPos1[ 1 ] + 1 ) + ;
L2BIN( aPos1[ 2 ] + 1 ) + ;
W2Bin( aRGBStart[ 1 ] ) + ;
W2Bin( aRGBStart[ 2 ] ) + ;
W2Bin( aRGBStart[ 3 ] ) + ;
W2Bin( 0 ) + ;
L2BIN( aPos2[ 1 ] + 1 ) + ;
L2BIN( aPos2[ 2 ] + 1 ) + ;
W2Bin( aRGBEnd[ 1 ] ) + ;
W2Bin( aRGBEnd[ 2 ] ) + ;
W2Bin( aRGBEnd[ 3 ] ) + ;
W2Bin( 0 )
aGRect := L2BIN( 0 ) + ;
L2BIN( 1 )
nCookie := oPS:LockHDC( 2, @nHDC )
IF nCookie == 0
RETURN .F.
ENDIF
IF OS( OS_FAMILY ) == "WIN9X"
//
// only horizontal
//
DLLCall( "MSIMG32.DLL", DLL_STDCALL, "GradientFill", nHDC, ;
@ aVertex, 2, @aGRect, 1, GRADIENT_FILL_RECT_H )
ELSE
IF cTemplate == NIL
cTemplate := DLLPrepareCall( "gdi32.dll", DLL_OSAPI, "GdiGradientFill" )
ENDIF
nVertLen := LEN( aVertex ) / 16
nGRectLen := LEN( aGRect ) / ( 4 * IIF( nDirection > 1, 3, 2 ) )
DLLExecuteCall( cTemplate , ;
nHdc , ;
@aVertex , ;
nVertLen , ;
@aGRect , ;
nGRectLen , ;
nDirection )
ENDIF
oPS:UnlockHDC( nCookie, nHDC )
#ENDIF
RETURN .T.
***Note : SPBG_*() Function (and nRGB) hold Color which can be change "on-fly"