Dialogo con sombras

Dialogo con sombras

Postby softruz » Wed May 12, 2010 6:00 pm

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.
softruz
 
Posts: 485
Joined: Fri Feb 09, 2007 10:34 am

Re: Dialogo con sombras

Postby toninhofwi » Thu May 13, 2010 4:33 pm

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  Expand view  RUN
#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.
toninhofwi
 
Posts: 172
Joined: Tue Oct 18, 2005 10:01 am

Re: Dialogo con sombras

Postby softruz » Thu May 13, 2010 5:13 pm

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.
softruz
 
Posts: 485
Joined: Fri Feb 09, 2007 10:34 am

Re: Dialogo con sombras

Postby Antonio Linares » Thu May 13, 2010 5:36 pm

Juan,

Revisa este ejemplo:
Code: Select all  Expand view  RUN

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

Re: Dialogo con sombras

Postby softruz » Thu May 13, 2010 6:13 pm

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

Postby softruz » Wed May 19, 2010 10:30 am

¿alguien sabría responderme de como hacer esto?

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

Re: Dialogo con sombras

Postby Bayron » Wed May 19, 2010 12:37 pm

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
Bayron
 
Posts: 815
Joined: Thu Dec 24, 2009 12:46 am
Location: Philadelphia, PA

Re: Dialogo con sombras

Postby Antonio Linares » Wed May 19, 2010 12:52 pm

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

Re: Dialogo con sombras

Postby Bayron » Wed May 19, 2010 1:07 pm

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
Bayron
 
Posts: 815
Joined: Thu Dec 24, 2009 12:46 am
Location: Philadelphia, PA

Re: Dialogo con sombras

Postby Antonio Linares » Sat May 22, 2010 8:17 am

Si, asi es :-)
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42107
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: Dialogo con sombras

Postby Carles » Sun May 23, 2010 1:52 pm

Hola,

Prueba con esto...

Code: Select all  Expand view  RUN
#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..."

UT Page -> https://carles9000.github.io/
Forum UT -> https://discord.gg/bq8a9yGMWh
Skype -> https://join.skype.com/cnzQg3Kr1dnk
User avatar
Carles
 
Posts: 1137
Joined: Fri Feb 10, 2006 2:34 pm
Location: Barcelona

Re: Dialogo con sombras

Postby Patricio Avalos Aguirre » Mon May 24, 2010 1:38 pm

Hola carles

revisando tu codigo me sale el siguente error
Code: Select all  Expand view  RUN
Error E0030  Syntax error: "syntax error at 'FUNCTION'"


en esta linea de código
Code: Select all  Expand view  RUN
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  Expand view  RUN
RETU SetClassLong( o:hWnd, GCL_STYLE, nOr( GetClassLong( o:hWnd, GCL_STYLE ),


lo he dejado de esta manera
Code: Select all  Expand view  RUN
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
Patricio Avalos Aguirre
 
Posts: 1060
Joined: Fri Oct 07, 2005 1:56 pm
Location: La Serena, Chile

Re: Dialogo con sombras

Postby Carles » Mon May 24, 2010 2:23 pm

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

Code: Select all  Expand view  RUN
#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..."

UT Page -> https://carles9000.github.io/
Forum UT -> https://discord.gg/bq8a9yGMWh
Skype -> https://join.skype.com/cnzQg3Kr1dnk
User avatar
Carles
 
Posts: 1137
Joined: Fri Feb 10, 2006 2:34 pm
Location: Barcelona

Re: Dialogo con sombras

Postby Patricio Avalos Aguirre » Mon May 24, 2010 3:28 pm

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
User avatar
Patricio Avalos Aguirre
 
Posts: 1060
Joined: Fri Oct 07, 2005 1:56 pm
Location: La Serena, Chile


Return to FiveWin para Harbour/xHarbour

Who is online

Users browsing this forum: Google [Bot] and 34 guests