gradient with bitmap transparent or text (urgent)

Post Reply
User avatar
Nop
Posts: 107
Joined: Tue Apr 11, 2006 4:36 pm
Location: Uberaba/Brazil

gradient with bitmap transparent or text (urgent)

Post 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
User avatar
Nop
Posts: 107
Joined: Tue Apr 11, 2006 4:36 pm
Location: Uberaba/Brazil

Post by Nop »

i need only an degrade in main windows...
User avatar
Enrico Maria Giordano
Posts: 7355
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia
Contact:

Re: gradient with bitmap transparent or text (urgent)

Post 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
User avatar
Enrico Maria Giordano
Posts: 7355
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia
Contact:

Re: gradient with bitmap transparent or text (urgent)

Post 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
User avatar
Nop
Posts: 107
Joined: Tue Apr 11, 2006 4:36 pm
Location: Uberaba/Brazil

Post by Nop »

works fine, very thanks Enrico.
User avatar
RAMESHBABU
Posts: 591
Joined: Fri Oct 21, 2005 5:54 am
Location: Secunderabad (T.S), India

Post 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
User avatar
Antonio Linares
Site Admin
Posts: 37481
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Contact:

Post 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.
regards, saludos

Antonio Linares
www.fivetechsoft.com
ShumingWang
Posts: 454
Joined: Sun Oct 30, 2005 6:37 am
Location: Guangzhou(Canton),China

Post 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
ShumingWang
Posts: 454
Joined: Sun Oct 30, 2005 6:37 am
Location: Guangzhou(Canton),China

Post 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
Post Reply