Page 1 of 1

gradient with bitmap transparent or text (urgent)

Posted: Fri Jun 22, 2007 3:19 pm
by Nop
HI, i need an sample to put an gradient (degrade) gray in main window (mdi) and an transparente bitmap or with an text raised, someone has an sample??
very thanks

Posted: Fri Jun 22, 2007 8:31 pm
by Nop
i need only an degrade in main windows...

Re: gradient with bitmap transparent or text (urgent)

Posted: Sat Jun 23, 2007 9:41 am
by Enrico Maria Giordano

Code: Select all

#include "Fivewin.ch"


FUNCTION MAIN()

    LOCAL oWnd

    DEFINE WINDOW oWnd MDI

    ACTIVATE WINDOW oWnd;
             ON PAINT GRADIENT( oWnd, hDC )

    RETURN NIL


STATIC FUNCTION GRADIENT( oWnd, hDC )

    LOCAL aRect := GETCLIENTRECT( oWnd:hWnd )
    LOCAL nStep := ( aRect[ 3 ] - aRect[ 1 ] ) / 256

    LOCAL oBrush

    LOCAL i

    aRect[ 3 ] = nStep

    FOR i = 255 TO 0 STEP -1
       DEFINE BRUSH oBrush;
              COLOR RGB( i, i, i )

       FILLRECT( hDC, aRect, oBrush:hBrush )

       RELEASE BRUSH oBrush

       aRect[ 1 ] += nStep
       aRect[ 3 ] += nStep
    NEXT

    RETURN NIL
EMG

Re: gradient with bitmap transparent or text (urgent)

Posted: Sat Jun 23, 2007 11:34 am
by Enrico Maria Giordano

Code: Select all

#include "Fivewin.ch"


FUNCTION MAIN()

    LOCAL oWnd, hBmp, oFnt

    DEFINE WINDOW oWnd MDI

    hBmp = READBITMAP( 0, "\FWH\BITMAPS\INSTALL.BMP" )

    DEFINE FONT oFnt NAME "Arial" SIZE 0, -20

    ACTIVATE WINDOW oWnd;
             ON PAINT ( GRADIENT( oWnd, hDC ),;
                        IF( hBmp != 0, DRAWMASKED( hDC, hBmp, 200, 200 ), ),;
                        oWnd:oWndClient:Say( 20, 10, "This is a test", CLR_HRED, , oFnt, , .T. ) )

    IF hBmp != 0; DELETEOBJECT( hBmp ); ENDIF

    RELEASE FONT oFnt

    RETURN NIL


STATIC FUNCTION GRADIENT( oWnd, hDC )

    LOCAL aRect := GETCLIENTRECT( oWnd:hWnd )
    LOCAL nStep := ( aRect[ 3 ] - aRect[ 1 ] ) / 256

    LOCAL oBrush

    LOCAL i

    aRect[ 3 ] = nStep

    FOR i = 255 TO 0 STEP -1
       DEFINE BRUSH oBrush;
              COLOR RGB( i, i, i )

       FILLRECT( hDC, aRect, oBrush:hBrush )

       RELEASE BRUSH oBrush

       aRect[ 1 ] += nStep
       aRect[ 3 ] += nStep
    NEXT

    RETURN NIL
EMG

Posted: Sat Jun 23, 2007 1:25 pm
by Nop
works fine, very thanks Enrico.

Posted: Mon Jun 25, 2007 5:41 pm
by RAMESHBABU
Hi Enrico

Some more stress on you :(

It was an long pending un-resolved problem :?

On the Gradient Dialogs, the Checkboxes or Radiobuttons are not painted
transparent in both themed and non-themed.

Can you please find out a solution for this.

I am enclosing the modified program here for your solution.

Code: Select all

#include "Fivewin.ch" 

FUNCTION MAIN() 

    LOCAL oDlg, hBmp, oFnt, oRadio, oCheck, nValue := 1, lCheck := .F., oCheck1, lCheck1 := .F., oGet, cGet := SPACE(50)

    DEFINE DIALOG oDlg SIZE 250, 250 TRANSPARENT

    hBmp = READBITMAP( 0, "\FWH\BITMAPS\INSTALL.BMP" ) 
    DEFINE FONT oFnt NAME "Arial" SIZE 0, -20 

    @ 1.75,0 RADIO oRadio VAR nValue ITEMS "Radio&1 not OK", "&Rado&2 not OK" OF oDlg SIZE 60, 12

    @ 1.65,09 CHECKBOX oCheck  VAR lCheck  PROMPT "CheckBox&1 not OK"  OF oDlg SIZE 80,12
    @ 2.50,09 CHECKBOX oCheck1 VAR lCheck1 PROMPT "CheckBox&2 not OK"  OF oDlg SIZE 80,12

    ACTIVATE DIALOG oDlg CENTERED ; 
             ON PAINT ( GRADIENT( oDlg, hDC ),; 
                        IF( hBmp != 0, DRAWMASKED( hDC, hBmp, 65, 65 ), ),;  //,; 
                        oDlg:Say( 1, 1, "This Say is OK", CLR_HRED, , oFnt, , .T. ), SysRefresh() ) 

    IF hBmp != 0; DELETEOBJECT( hBmp ); ENDIF 

    RELEASE FONT oFnt 

    RETURN NIL 


STATIC FUNCTION GRADIENT( oDlg, hDC ) 

    LOCAL aRect := GETCLIENTRECT( oDlg:hWnd ) 
    LOCAL nStep := ( aRect[ 3 ] - aRect[ 1 ] ) / 256 

    LOCAL oBrush 

    LOCAL i 

    aRect[ 3 ] = nStep 

    FOR i = 255 TO 0 STEP -1 
       DEFINE BRUSH oBrush; 
              COLOR RGB( i, i, i ) 

       FILLRECT( hDC, aRect, oBrush:hBrush ) 

       RELEASE BRUSH oBrush 

       aRect[ 1 ] += nStep 
       aRect[ 3 ] += nStep 
    NEXT 

    RETURN NIL 
Regards to you

- Ramesh Babu P

Posted: Mon Jun 25, 2007 6:30 pm
by Enrico Maria Giordano
Sorry, you have to ask Antonio for this.

EMG

Posted: Mon Jun 25, 2007 7:56 pm
by Antonio Linares
Ramesh,

Its not easy to implement it. The controls paint themselves, but when using themes we use a themes API function to copy the parent background image, so they look fine.

The problem is that such API function does not work with the gradient, as it is not a themed gradient.

Probably there may be a solution, but we have not found it yet.

Posted: Wed Jun 27, 2007 1:22 am
by ShumingWang
Fernando Sanchez,
noway button support paint disabled button as the dialog background color?
for example:
redefine viaopenbutton obtton id 101 of dialog when .f.

this hide the obutton .

Regards
Shuming Wang

Posted: Fri Jun 29, 2007 2:10 am
by ShumingWang
adlgclr:={255,255,255}

bTColor := { |oBtn| If( ! oBtn:lActive, CLR_HGRAY, ;
If( oBtn:lMouseOver, CLR_HBLUE, ;
If( oBtn:lPressed, CLR_HGREEN, CLR_BLACK ) ) ) }

bBColor := { |oBtn| If( oBtn:lActive, rgb(adlgclr[1],adlgclr[2],adlgclr[3]), CLR_WHITE) }



REDEFINE SBUTTON ;
ID 101 ;
PROMPT "basic set" ;
OF oxerpdlg1 ;
RESOURCE "plan08" ;
COLORS bTColor,bBColor ;
TEXT ON_BOTTOM ;
NOBOX ;
ACTION plan11();
WHEN ASCAN(afunctions,"plan11")>0

now tsbutton when .f., it paint color gray ,not as the dialog background color, I want the dialog background color to 'hide' the defined tsbutton include text and bitmap.


Shuming Wang