Burbujas Flotantes

Re: Burbujas Flotantes

Postby TOTOVIOTTI » Fri Sep 13, 2024 1:10 pm

Karinha... cólocale el código a Claude IA y pídele que te lo haga para Dialog MDI

y lo hace.... es muy obediente... jajaja
Univ@c I.S.I.
Desarrolladores de Software
http://www.elcolegioencasa.edu.ar
User avatar
TOTOVIOTTI
 
Posts: 408
Joined: Fri Feb 05, 2010 11:30 am
Location: San Francisco - Córdoba - Argentina

Re: Burbujas Flotantes

Postby Antonio Linares » Fri Sep 13, 2024 1:59 pm

Aún falla el pintado de la sombra, solo lo hace bien al redimensionar la ventana principal. Seguimos...
Code: Select all  Expand view
#include "FiveWin.ch"

function Main()

    local oWnd, oCircle

    DEFINE WINDOW oWnd TITLE "Testing Class TCircle" COLOR "W/BG" SIZE 1200, 800

    @ 5, 5 BUTTON "Test" SIZE 80, 20

    oCircle = TCircle():New( 50, 80, 120, CLR_BLUE, oWnd )

    ACTIVATE WINDOW oWnd CENTER

return nil    

#define WHITE_BRUSH          0
#define DKGRAY_BRUSH         3
#define SRCCOPY       13369376
#define WS_EX_LAYERED   0x00080000

CLASS TCircle FROM TControl

   CLASSDATA lRegistered AS LOGICAL

   DATA   nRadius, hRgn
   DATA   lDragging INIT .F.
   DATA   nDragOffsetX INIT 0
   DATA   nDragOffsetY INIT 0

   METHOD New( nTop, nLeft, nRadius, nRGBColor, oWnd ) CONSTRUCTOR

   METHOD EraseBkGnd() INLINE 1

   METHOD Paint()

   METHOD Display() INLINE ::BeginPaint(), ::Paint(), ::EndPaint(), 0

   METHOD LButtonDown( nX, nY, nFlags )  

   METHOD LButtonUp( nX, nY, nFlags ) INLINE ::lDragging := .F., nil

   METHOD MouseMove( nX, nY, nFlags )

   METHOD Destroy()

ENDCLASS    

METHOD New( nTop, nLeft, nRadius, nRGBColor, oWnd ) CLASS TCircle

   DEFAULT nTop := 0, nLeft := 0, nRadius := 100,;
           oWnd := GetWndDefault()

   ::nTop    = nTop
   ::nLeft   = nLeft
   ::nBottom = nTop + nRadius
   ::nRight  = nLeft + nRadius
   ::nRadius = nRadius
   ::oWnd    = oWnd  
   ::nStyle  = nOr( WS_CHILD, WS_VISIBLE, WS_TABSTOP )

   ::Register()

   if ! Empty( ::oWnd:hWnd )
      ::Create()
      ::SetBrush( TBrush():New( , nRGBColor ) )
      ::hRgn = CreateEllipticRgn( 0, 0, ::nRadius, ::nRadius )
      SetWindowRgn( ::hWnd, ::hRgn, .T. )
      ::oWnd:AddControl( Self )
   else
      ::oWnd:DefControl( Self )
   endif
 
return Self  

METHOD Paint() CLASS TCircle

   local hdcMem, hdcDest, hBmp, hOldBmp, hdcScreen, hBmpScreen, hOldBmpScreen, i, nStep, nAlpha := 100
   local hBrush := GetStockObject( DKGRAY_BRUSH )

   hdcDest := ::hDC  // HDC del destino (control)
   hdcScreen := ::oWnd:GetDC()

   // Crear un contexto de memoria compatible con la ventana
   hdcMem := CreateCompatibleDC( hdcScreen )
   hBmp := CreateCompatibleBitmap( hdcScreen, ::nRadius * 2 + 30, ::nRadius * 2 + 30 )  // Incluir el área de la sombra
   hOldBmp := SelectObject( hdcMem, hBmp )

   // Copiar la parte de la ventana contenedora donde se va a dibujar la sombra y el círculo
   BitBlt( hdcMem, 0, 0, ::nRadius, ::nRadius, hdcScreen, ::nLeft, ::nTop, SRCCOPY )

   SelectObject( hdcMem, hBrush )
   Ellipse( hdcMem, -1, -1, ::nRadius, ::nRadius )
   AlphaBlend( hdcDest, 0, 0, ::nRadius, ::nRadius, hdcMem, 0, 0, ::nRadius, ::nRadius, nAlpha, 0 )

   // Dibujar sombras concéntricas degradadas
   // nStep := 5  // Tamaño de cada paso en el degradado
   // for i := 30 to 1 step -1
   //    nAlpha := i * 8  // Nivel de transparencia de la sombra (ajustable entre 0 y 255)
   //    AlphaBlend( hdcDest, 15 - i, 15 - i, ::nRadius * 2 + i * 2 - 30, ::nRadius * 2 + i * 2 - 30, hdcMem, 0, 0, ::nRadius * 2, ::nRadius * 2, nAlpha, 0 )
   // next

   SelectObject( ::hDC, ::oBrush:hBrush )
   Ellipse( ::hDC, 15, 15, ::nRadius - 15, ::nRadius - 15 )

   SelectObject( hdcMem, hOldBmp )
   DeleteObject( hBmp )
   DeleteDC( hdcMem )
   ::oWnd:ReleaseDC()

return 0

METHOD LButtonDown( nX, nY, nFlags ) CLASS TCircle

   if ! ::lDragging
      SetFocus( ::hWnd )
      ::lDragging = .T.
      ::nDragOffsetX = nX
      ::nDragOffsetY = nY
   endif
   
return nil  

METHOD MouseMove( nX, nY, nFlags ) CLASS TCircle

   if ::lDragging
      ::Move( ::nTop + nX - ::nDragOffsetX, ::nLeft + nY - ::nDragOffsetY,,, .T. )
   endif
   
return nil  

METHOD Destroy() CLASS TCircle

   if ! Empty( ::hRgn )
      DeleteObject( ::hRgn )
   endif
 
 return ::Super:Destroy()

#pragma BEGINDUMP

#include <windows.h>
#include <hbapi.h>

HB_FUNC( ALPHABLEND )
{
    HDC hdcDest      = (HDC) hb_parnl( 1 );  // Primer parámetro: HDC destino
    int xDest        = hb_parni( 2 );        // Segundo parámetro: posición x de destino
    int yDest        = hb_parni( 3 );        // Tercer parámetro: posición y de destino
    int wDest        = hb_parni( 4 );        // Cuarto parámetro: ancho del área de destino
    int hDest        = hb_parni( 5 );        // Quinto parámetro: alto del área de destino
    HDC hdcSrc       = (HDC) hb_parnl( 6 );  // _ parámetro: HDC fuente
    int xSrc         = hb_parni( 7 );        // Séptimo parámetro: posición x en la fuente
    int ySrc         = hb_parni( 8 );        // Octavo parámetro: posición y en la fuente
    int wSrc         = hb_parni( 9 );        // Noveno parámetro: ancho del área en la fuente
    int hSrc         = hb_parni( 10 );       // Décimo parámetro: alto del área en la fuente
    BLENDFUNCTION bf;

    bf.BlendOp             = AC_SRC_OVER;    // La operación de mezcla estándar
    bf.BlendFlags          = 0;              // No usar banderas adicionales
    bf.SourceConstantAlpha = (BYTE) hb_parni( 11 ); // El nivel de transparencia (0-255)
    bf.AlphaFormat         = (BYTE) hb_parni( 12 ); // El formato del alfa (0 o AC_SRC_ALPHA)

    // Llamar a la función AlphaBlend de la GDI32
    hb_retl( AlphaBlend(
        hdcDest, xDest, yDest, wDest, hDest,
        hdcSrc, xSrc, ySrc, wSrc, hSrc,
        bf ) );  // Retornar el resultado de la operación (TRUE o FALSE)
}

#pragma ENDDUMP
 
regards, saludos

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

Re: Burbujas Flotantes

Postby Antonio Linares » Fri Sep 13, 2024 2:05 pm

Para MDI sólo hay que cambiar estas dos líneas:

DEFINE WINDOW oWnd TITLE "Testing Class TCircle" COLOR "W/BG" SIZE 1200, 800 MDI

oCircle = TCircle():New( 50, 80, 120, CLR_BLUE, oWnd:oWndClient )
regards, saludos

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

Re: Burbujas Flotantes

Postby TOTOVIOTTI » Fri Sep 13, 2024 2:05 pm

Buenísimo Antonio!!

No pude insertarle una imagen, pero seguiremos probando!

Muchas gracias!
Univ@c I.S.I.
Desarrolladores de Software
http://www.elcolegioencasa.edu.ar
User avatar
TOTOVIOTTI
 
Posts: 408
Joined: Fri Feb 05, 2010 11:30 am
Location: San Francisco - Córdoba - Argentina

Re: Burbujas Flotantes

Postby Antonio Linares » Fri Sep 13, 2024 2:06 pm

Estamos intentando arreglar la sombra :-)
regards, saludos

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

Re: Burbujas Flotantes

Postby karinha » Fri Sep 13, 2024 2:40 pm

Gracias Maestro. Es posible poner un TEXTO y IMAGEN en el CIRCLE?

Code: Select all  Expand view

// CIRCLE.PRG

#Include "FiveWin.ch"

FUNCTION Main()

   LOCAL oWnd, oCircle, cTitle := "Testing Class TCircle"

   // Window normal
   // DEFINE WINDOW oWnd TITLE "Testing Class TCircle" COLOR "W/BG" SIZE 1200, 800

   // MDI
   DEFINE WINDOW oWnd TITLE "Testing Class TCircle" COLOR "W/BG" SIZE 1200, 800 MDI

   // MDI
   oCircle = TCircle():New( 50, 80, 120, CLR_BLUE, oWnd:oWndClient, {|| MsgInfo( "¡Círculo presionado!", "Acción" ) } )

   // Window Normal
   // oCircle = TCircle():New( 50, 80, 120, CLR_BLUE, oWnd, {|| MsgInfo( "¡Círculo presionado!", "Acción" ) } )

   // MDI
   ACTIVATE WINDOW oWnd CENTERED ON INIT( oWnd:oMenu:End() )

RETURN NIL

CLASS TCircle FROM TControl

   CLASSDATA lRegistered AS LOGICAL

   DATA   nRadius, hRgn
   DATA   lDragging INIT .F.
   DATA   nDragOffsetX INIT 0
   DATA   nDragOffsetY INIT 0
   DATA   bAction

   METHOD New( nTop, nLeft, nRadius, nRGBColor, oWnd, bAction ) CONSTRUCTOR
   METHOD Paint()
   METHOD Display() INLINE ::BeginPaint(), ::Paint(), ::EndPaint(), 0
   METHOD LButtonDown( nX, nY, nFlags )
   METHOD LButtonUp( nX, nY, nFlags )
   METHOD MouseMove( nX, nY, nFlags )
   METHOD Destroy()
   METHOD PerformAction()

ENDCLASS

METHOD New( nTop, nLeft, nRadius, nRGBColor, oWnd, bAction ) CLASS TCircle

   DEFAULT nTop := 0, nLeft := 0, nRadius := 100, ;
      oWnd := GetWndDefault(), bAction := {|| NIL }

   ::nTop    = nTop
   ::nLeft   = nLeft
   ::nBottom = nTop + ( nRadius * 2 )
   ::nRight  = nLeft + ( nRadius * 2 )
   ::nRadius = nRadius
   ::oWnd    = oWnd
   ::nStyle  = nOr( WS_CHILD, WS_VISIBLE, WS_CLIPCHILDREN )
   ::bAction = bAction

   ::Register()

   IF .NOT. Empty( ::oWnd:hWnd )

      ::Create()
      ::SetBrush( TBrush():New( , nRGBColor ) )
      ::hRgn = CreateEllipticRgn( 0, 0, ::nRadius, ::nRadius )

      SetWindowRgn( ::hWnd, ::hRgn, .T. )

      ::oWnd:AddControl( Self )

   ELSE

      ::oWnd:DefControl( Self )

   ENDIF

RETURN Self

METHOD Paint() CLASS TCircle

   SelectObject( ::hDC, ::oBrush:hBrush )

   Ellipse( ::hDC, 0, 0, ::nRadius, ::nRadius )

RETURN 0

METHOD LButtonDown( nX, nY, nFlags ) CLASS TCircle

   IF .NOT. ::lDragging

      ::lDragging = .T.
      ::nDragOffsetX = nX
      ::nDragOffsetY = nY
      ::PerformAction()

   ENDIF

RETURN NIL

METHOD LButtonUp( nX, nY, nFlags ) CLASS TCircle

   ::lDragging := .F.

RETURN NIL

METHOD MouseMove( nX, nY, nFlags ) CLASS TCircle

   IF ::lDragging
      ::Move( ::nTop + nX - ::nDragOffsetX, ::nLeft + nY - ::nDragOffsetY,,, .T. )
   ENDIF

RETURN NIL

METHOD Destroy() CLASS TCircle

   IF .NOT. Empty( ::hRgn )
      DeleteObject( ::hRgn )
   ENDIF

   RETURN ::Super:Destroy()

METHOD PerformAction() CLASS TCircle

   Eval( ::bAction )

RETURN NIL

// FIN / END
 


Regards, saludos.
João Santos - São Paulo - Brasil - Phone: +55(11)95150-7341
User avatar
karinha
 
Posts: 7613
Joined: Tue Dec 20, 2005 7:36 pm
Location: São Paulo - Brasil

Re: Burbujas Flotantes

Postby paquitohm » Fri Sep 13, 2024 2:59 pm

Una pregunta de novato todo el tiempo.

¿ No sería mejor decirle a Claude que haga una clase en C++/ Python con todas las caracteristicas necesarias y luego wrapearla a fwh ?

¿ Qué es mejor, no tener una cosa nativamente o tenerla no nativa ?
paquitohm
 
Posts: 209
Joined: Fri Jan 14, 2022 8:37 am

Re: Burbujas Flotantes

Postby Antonio Linares » Fri Sep 13, 2024 3:46 pm

Paco,

FWH tiene su propia arquitectura y la clase tiene que seguir las reglas de FWH :-)
regards, saludos

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

Re: Burbujas Flotantes

Postby paquitohm » Fri Sep 13, 2024 4:41 pm

Gracias Antonio
paquitohm
 
Posts: 209
Joined: Fri Jan 14, 2022 8:37 am

Re: Burbujas Flotantes

Postby Antonio Linares » Tue Sep 17, 2024 6:15 am

Nuestro querido Maestro Rao lo ha bordado:

Image
regards, saludos

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

Re: Burbujas Flotantes

Postby paquitohm » Tue Sep 17, 2024 8:08 am

Nivelón !!
Impressive !!
Congrats !!
paquitohm
 
Posts: 209
Joined: Fri Jan 14, 2022 8:37 am

Re: Burbujas Flotantes

Postby leandro » Wed Sep 18, 2024 3:55 pm

Excelente Antonio,

esto lo vas a incluir en el nuevo build de fw?
Saludos
LEANDRO AREVALO
Bogotá (Colombia)
https://hymlyma.com
https://hymplus.com/
leandroalfonso111@gmail.com
leandroalfonso111@hotmail.com

[ Embarcadero C++ 7.60 for Win32 ] [ FiveWin 23.07 ] [ xHarbour 1.3.0 Intl. (SimpLex) (Build 20230914) ]
User avatar
leandro
 
Posts: 1620
Joined: Wed Oct 26, 2005 2:49 pm
Location: Colombia

Re: Burbujas Flotantes

Postby Antonio Linares » Wed Sep 18, 2024 4:25 pm

Si, vamos a incluirlo y publicarlo lo antes posible
regards, saludos

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

Re: Burbujas Flotantes

Postby TOTOVIOTTI » Wed Sep 18, 2024 7:50 pm

Genial Maestro Antonioooooooooooooo & Mr. Rao!!!!

MUCHAS MUCHAS GRACIAS POR HACER CASO A NUESTRAS LOCURAS!!
GRACIAS A TODO EL EQUIPO!!


Great, Maestro Antoniooooooooooooo and Mr. Rao!!!!

THANK YOU VERY MUCH FOR LISTENING TO OUR CRAZIES!!
THANKS TO THE ENTIRE TEAM!!
Univ@c I.S.I.
Desarrolladores de Software
http://www.elcolegioencasa.edu.ar
User avatar
TOTOVIOTTI
 
Posts: 408
Joined: Fri Feb 05, 2010 11:30 am
Location: San Francisco - Córdoba - Argentina

Previous

Return to FiveWin para Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 45 guests