Dialogo con sombras

Post Reply
softruz
Posts: 485
Joined: Fri Feb 09, 2007 10:34 am

Dialogo con sombras

Post by softruz »

Muy buenas foro, he diseñado un dialogo en una imagen PNG con sombras y me gustaria usar este fondo en un dialgo y asi tener las sombras que tiene dicha imagen ,¿como podríamos incrustar la imagen con sombras en un dialgo , pasa así tener un dialgo con sombras.

Un Saludo.
toninhofwi
Posts: 161
Joined: Tue Oct 18, 2005 10:01 am

Re: Dialogo con sombras

Post by toninhofwi »

Hi.

This code works, but need be cleared and optimized. Sorry but I start it and don't have time to finish.

Use it in ON INIT clause of an dialog like:

ACTIVATE DIALOG...ON INIT INITSHADOW( oDlg:hWnd ) )

Code: Select all

#pragma BEGINDUMP

#include "windows.h"
#include "hbapi.h"

#define S_SHADE 5

HB_FUNC( INITSHADOW )
{
        RECT rc;
        HWND hWnd = ( HWND ) hb_parnl( 1 );
        HDC dc = GetDC( NULL );

        HDC tdc = CreateCompatibleDC( dc );
        HBITMAP map1 = CreateCompatibleBitmap( dc,1600,1200);
        HGDIOBJ hOldBmp;
        int w,e;
        float f,g;
         GetWindowRect( hWnd, &rc );

        hOldBmp = SelectObject( tdc, map1 );
        BitBlt( tdc, rc.left,rc.top,rc.right+S_SHADE, rc.bottom+S_SHADE,dc,rc.left,rc.top,SRCCOPY);

        for( w=rc.right;w<=rc.right+S_SHADE;w++)
        {
            f=((float)w-rc.right)/S_SHADE;
            for(e=rc.top+S_SHADE;e< rc.bottom;e++)
            {
                SetPixel(tdc, w,e,RGB(
                    GetRValue(GetPixel(tdc,w,e))/(2-f),
                    GetGValue(GetPixel(tdc,w,e))/(2-f),
                    GetBValue(GetPixel(tdc,w,e))/(2-f)));
            }
        }

        for(e=rc.bottom;e<=rc.bottom+S_SHADE;e++)
        {
            f=((float)e-rc.bottom)/S_SHADE;
            for(w=rc.left+S_SHADE;w<=rc.right+1;w++)
            {
                SetPixel(tdc,w,e,RGB(
                GetRValue(GetPixel(tdc,w,e))/(2-f),
                GetGValue(GetPixel(tdc,w,e))/(2-f),
                GetBValue(GetPixel(tdc,w,e))/(2-f)));
            }
        }

        for(e=rc.bottom;e<=rc.bottom+S_SHADE-2;e++)
        {
            f=((float)e-rc.bottom)/S_SHADE;
            for(w=rc.right+2;w<=rc.right+S_SHADE-2;w++)
            {
                g=((float)w-rc.right+2)/(S_SHADE);
                SetPixel(tdc,w,e,RGB(
                    GetRValue(GetPixel(tdc,w,e))/(2-(f+g)/2),
                    GetGValue(GetPixel(tdc,w,e))/(2-(f+g)/2),
                    GetBValue(GetPixel(tdc,w,e))/(2-(f+g)/2)));
            }
        }

        BitBlt(dc, rc.left,rc.top,rc.right+S_SHADE,rc.bottom+S_SHADE,tdc,rc.left,rc.top,SRCCOPY);

        SelectObject( tdc, hOldBmp );

        hb_retnl( ( LONG ) map1 );
}

#pragma ENDDUMP

Regards,

Toninho.
softruz
Posts: 485
Joined: Fri Feb 09, 2007 10:34 am

Re: Dialogo con sombras

Post by softruz »

Ante todo gracias, pero lo que necesito no solo es poner sombra a un dialogo sino, yo tengo una imagen con ESQUINAS redondeadas y con sombra y utilizarla de fondo del dialogo.

¿Como lo podemos hacer?

Un Saludo.
User avatar
Antonio Linares
Site Admin
Posts: 37481
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Contact:

Re: Dialogo con sombras

Post by Antonio Linares »

Juan,

Revisa este ejemplo:

Code: Select all

#include "FiveWin.ch"

function Main()

   local oWnd
   
   DEFINE WINDOW oWnd COLOR 0, CLR_WHITE
      
   ACTIVATE WINDOW oWnd MAXIMIZED ;
      ON INIT Test( oWnd )

return nil

function Test( oWnd )

   local oDlg, oBrush
   local oBmp, hDC, hBmpBack
   local nTop, nLeft, nBottom, nRight, nWidth, nHeight   
   local cTest := Space( 10 )

   DEFINE BITMAP oBmp FILENAME "dialog4.bmp"

   nWidth   = nBmpWidth( oBmp:hBitmap )
   nHeight  = nBmpHeight( oBmp:hBitmap )
   nLeft    = ( GetSysMetrics( 0 ) / 2 ) - nWidth / 2
   nTop     = ( GetSysMetrics( 1 ) / 2 ) - nHeight / 2
   nRight   = nLeft + nWidth - 1
   nBottom  = nTop + nHeight - 1

   hBmpBack = FWSaveScreen( oWnd:hWnd, nTop, nLeft, nBottom, nRight )

   DEFINE BRUSH oBrush COLOR CLR_RED // STYLE NULL             // Transparent painting !

   DEFINE DIALOG oDlg ;
      FROM 2, 2 TO 23, 45 ;
      STYLE WS_POPUP ;
      BRUSH oBrush ;

   @ 3.5, 7.5 GET cTest

   ACTIVATE DIALOG oDlg CENTERED ;
      ON PAINT ( ABPaint( hDC := GetWindowDC( oWnd:hWnd ), nLeft, nTop, oBmp:hBitmap, 150 ), ReleaseDC( oWnd:hWnd, hDC ) ) ;
      ON INIT SetTransparent( oDlg ) ;
      VALID ( FWRestScreen( oWnd:hWnd, hBmpBack, nTop, nLeft, nBottom, nRight ), DeleteObject( hBmpBack ), .T. ) ;
      ON CLICK oDlg:End()

   oBmp:End()
      
return nil

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

#define LWA_COLORKEY  1 
#define GWL_EXSTYLE   -20 
#define WS_EX_LAYERED 524288 


STATIC FUNCTION SETTRANSPARENT( oDlg ) 

   SETWINDOWLONG( oDlg:hWnd, GWL_EXSTYLE, NOR( GETWINDOWLONG( oDlg:hWnd, GWL_EXSTYLE ), WS_EX_LAYERED ) ) 

   SETLAYEREDWINDOWATTRIBUTES( oDlg:hWnd, CLR_RED,, LWA_COLORKEY ) 

RETURN NIL
 
http://www.mediafire.com/?y42ztyiwfnn

Image
regards, saludos

Antonio Linares
www.fivetechsoft.com
softruz
Posts: 485
Joined: Fri Feb 09, 2007 10:34 am

Re: Dialogo con sombras

Post by softruz »

Muchas gracias Antonio, Como podriamos hacer sin ventana Padre, es decir, es la primera ventana de la aplicación .

Un Saludo.
softruz
Posts: 485
Joined: Fri Feb 09, 2007 10:34 am

Re: Dialogo con sombras

Post by softruz »

¿alguien sabría responderme de como hacer esto?

Un Saludo.
User avatar
Bayron
Posts: 815
Joined: Thu Dec 24, 2009 12:46 am
Location: Philadelphia, PA

Re: Dialogo con sombras

Post by Bayron »

softruz wrote:¿alguien sabría responderme de como hacer esto?

Un Saludo.
Chequea en

FWH\source\function\msglogo.prg

Talvez te ayude
=====>

Bayron Landaverry
(215)2226600 Philadelphia,PA, USA
+(502)46727275 Guatemala
MayaBuilders@gMail.com

FWH12.04||Harbour 3.2.0 (18754)||BCC6.5||UEstudio 10.10||
Windows 7 Ultimate

FiveWin, One line of code and it's done...
User avatar
Antonio Linares
Site Admin
Posts: 37481
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Contact:

Re: Dialogo con sombras

Post by Antonio Linares »

Juan,

En el PRG que te dice Bayron, revisa la función MsgSplash() que no precisa de una ventana posterior.
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Bayron
Posts: 815
Joined: Thu Dec 24, 2009 12:46 am
Location: Philadelphia, PA

Re: Dialogo con sombras

Post by Bayron »

Antonio,

Si no estoy equivocado, de esta manera, podriamos presentar aplicaciones que respetan el area del modelo rectangular, pero que se presente en pantalla de manera irregular, cierto???

Ejemplo, de manera circular, triangular, etc...
Image
=====>

Bayron Landaverry
(215)2226600 Philadelphia,PA, USA
+(502)46727275 Guatemala
MayaBuilders@gMail.com

FWH12.04||Harbour 3.2.0 (18754)||BCC6.5||UEstudio 10.10||
Windows 7 Ultimate

FiveWin, One line of code and it's done...
User avatar
Antonio Linares
Site Admin
Posts: 37481
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Contact:

Re: Dialogo con sombras

Post by Antonio Linares »

Si, asi es :-)
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Carles
Posts: 937
Joined: Fri Feb 10, 2006 2:34 pm
Location: Barcelona
Contact:

Re: Dialogo con sombras

Post by Carles »

Hola,

Prueba con esto...

Code: Select all

#include "fivewin.ch"

#define LWA_ALPHA 2
#define GWL_EXSTYLE -20
#define WS_EX_LAYERED 524288
#define CS_DROPSHADOW 131072
#define GCL_STYLE -26

*--------------
FUNCTION Main()
*--------------
    LOCAL oDlg, oDlg2

    DEFINE DIALOG oDlg2 TITLE "Classic Dialog" FROM 10, 10 TO 30, 60 ;
       COLOR CLR_BLACK, CLR_YELLOW
    ACTIVATE DIALOG oDlg2 NOMODAL

    DEFINE DIALOG oDlg TITLE "Shadow" FROM 15, 5 TO 25, 50 ;
       COLOR CLR_RED, CLR_GREEN
    ACTIVATE DIALOG oDlg ON INIT Shadow( oDlg )

RETU NIL

*--------------------------
STATIC FUNCTION Shadow( o )
*--------------------------
RETU SetClassLong( o:hWnd, GCL_STYLE, nOr( GetClassLong( o:hWnd, GCL_STYLE ),

DLL32 FUNCTION GetClassLong( hWnd As LONG, crKey As LONG) AS LONG PASCAL ;
FROM "GetClassLongA" lib "user32.DLL"

DLL32 FUNCTION SetClassLong( hWnd As LONG, nValue As LONG, nNewValue As LONG)
FROM "SetClassLongA" lib "user32.DLL"
Salutacions, saludos, regards

"...programar es fácil, hacer programas es difícil..."

https://modharbour.app
https://modharbour.app/compass
https://forum.modharbour.app
User avatar
Patricio Avalos Aguirre
Posts: 1028
Joined: Fri Oct 07, 2005 1:56 pm
Location: La Serena, Chile
Contact:

Re: Dialogo con sombras

Post by Patricio Avalos Aguirre »

Hola carles

revisando tu codigo me sale el siguente error

Code: Select all

Error E0030  Syntax error: "syntax error at 'FUNCTION'"
en esta linea de código

Code: Select all

DLL32 FUNCTION SetClassLong( hWnd As LONG, nValue As LONG, nNewValue As LONG) FROM "SetClassLongA" lib "user32.DLL"
en esta otra lines le falta algun parametro?

Code: Select all

RETU SetClassLong( o:hWnd, GCL_STYLE, nOr( GetClassLong( o:hWnd, GCL_STYLE ),
lo he dejado de esta manera

Code: Select all

return(SetClassLong( o:hWnd, GCL_STYLE, nOr( GetClassLong( o:hWnd, GCL_STYLE ) ) ) )
Saludos
Patricio

__________________________________________________________________
Version: Harbour 3.2.0dev (r1307082134),Compiler: Borland C++ 5.8.2 (32-bit)
PCode version: 0.3, FWH 13.2
http://www.sialm.cl
User avatar
Carles
Posts: 937
Joined: Fri Feb 10, 2006 2:34 pm
Location: Barcelona
Contact:

Re: Dialogo con sombras

Post by Carles »

Las prisas con el copy/paste :D (lo siento)

Code: Select all

#include "fivewin.ch"

#define LWA_ALPHA 2
#define GWL_EXSTYLE -20
#define WS_EX_LAYERED 524288
#define CS_DROPSHADOW 131072
#define GCL_STYLE -26

*--------------
FUNCTION Main()
*--------------
    LOCAL oDlg, oDlg2

    DEFINE DIALOG oDlg2 TITLE "Classic Dialog" FROM 10, 10 TO 30, 60 ;
       COLOR CLR_BLACK, CLR_YELLOW
    ACTIVATE DIALOG oDlg2 NOMODAL

    DEFINE DIALOG oDlg TITLE "Shadow" FROM 15, 5 TO 25, 50 ;
       COLOR CLR_RED, CLR_GREEN
    ACTIVATE DIALOG oDlg ON INIT Shadow( oDlg )

RETU NIL

*--------------------------
STATIC FUNCTION Shadow( o )
*--------------------------
RETU SetClassLong( o:hWnd, GCL_STYLE, nOr( GetClassLong( o:hWnd, GCL_STYLE ),
CS_DROPSHADOW ))

DLL32 FUNCTION GetClassLong( hWnd As LONG, crKey As LONG) AS LONG PASCAL ;
FROM "GetClassLongA" lib "user32.DLL"

DLL32 FUNCTION SetClassLong( hWnd As LONG, nValue As LONG, nNewValue As LONG)
AS LONG PASCAL ;
FROM "SetClassLongA" lib "user32.DLL"
Salutacions, saludos, regards

"...programar es fácil, hacer programas es difícil..."

https://modharbour.app
https://modharbour.app/compass
https://forum.modharbour.app
User avatar
Patricio Avalos Aguirre
Posts: 1028
Joined: Fri Oct 07, 2005 1:56 pm
Location: La Serena, Chile
Contact:

Re: Dialogo con sombras

Post by Patricio Avalos Aguirre »

Gracias Carles

funciona perfecto
Saludos
Patricio

__________________________________________________________________
Version: Harbour 3.2.0dev (r1307082134),Compiler: Borland C++ 5.8.2 (32-bit)
PCode version: 0.3, FWH 13.2
http://www.sialm.cl
Post Reply