Tooltip sobre TSButton disabled no funciona

Tooltip sobre TSButton disabled no funciona

Postby VictorCasajuana » Tue Oct 15, 2024 9:33 am

Hola.

Tengo un TSButton con un tooltip y funciona correctamente, pero cuando lo pongo en :disabled() ya no se muestra el tooltip. He visto algún post al respecto con otros controles, pero no sobre un botón.
Alguna ayuda al respecto?

Gracias!
--------
¿ Y porque no ?
¿ And why not ?
User avatar
VictorCasajuana
 
Posts: 243
Joined: Wed Mar 28, 2018 4:38 pm
Location: Vinaròs

Re: Tooltip sobre TSButton disabled no funciona

Postby paquitohm » Tue Oct 15, 2024 10:26 am

Hola Víctor,

Hace muchos años, lo menos 15, pregunté por esta característica: tooltip sobre elementos disabled.
Me respondieron que no la había y entonces me monté una a base de una clase de tooltip (ajtip, creo que se llama) y a base de modificar control.prg

Bastante heterodoxo, pero si efectivo porque aunque muestra unos tooltip que no son los estandar de windows, estos que saca son rectangulos con texto con fondo y letra configurables, pero si funcionan.

Image

Quiza fwh ya tenga esa caracteristica o el equipo fwh la pueda desarrollar de una manera más ortodoxa

Salu2

BTW. Esos botones que se muestran en la imagen son botones SButton. El efecto apagado también lo saqué de algún sitio a base de hacer pruebas.
paquitohm
 
Posts: 233
Joined: Fri Jan 14, 2022 8:37 am

Re: Tooltip sobre TSButton disabled no funciona

Postby VictorCasajuana » Tue Oct 15, 2024 11:40 am

paquitohm wrote:Hola Víctor,

Hace muchos años, lo menos 15, pregunté por esta característica: tooltip sobre elementos disabled.
Me respondieron que no la había y entonces me monté una a base de una clase de tooltip (ajtip, creo que se llama) y a base de modificar control.prg

Bastante heterodoxo, pero si efectivo porque aunque muestra unos tooltip que no son los estandar de windows, estos que saca son rectangulos con texto con fondo y letra configurables, pero si funcionan.

Image

Quiza fwh ya tenga esa caracteristica o el equipo fwh la pueda desarrollar de una manera más ortodoxa

Salu2

BTW. Esos botones que se muestran en la imagen son botones SButton. El efecto apagado también lo saqué de algún sitio a base de hacer pruebas.


Gracias paquitohm, estuve viendo esos posts a los que te refieres, pero prefiero utilizar algo más nativo de fwh, si nadie comenta nada, ya miro como lo puedo solucionar.

Salud!
--------
¿ Y porque no ?
¿ And why not ?
User avatar
VictorCasajuana
 
Posts: 243
Joined: Wed Mar 28, 2018 4:38 pm
Location: Vinaròs

Re: Tooltip sobre TSButton disabled no funciona

Postby Antonio Linares » Wed Oct 16, 2024 8:54 am

He probado asi pero no parece funcionar:

Code: Select all  Expand view
#include "FiveWin.ch"

function Main()

   local oWnd, oBtn

   DEFINE WINDOW oWnd

   @ 2, 4 BTNBMP oBtn PROMPT "Ok" SIZE 80, 20
   oBtn:Disable()
   oBtn:cTooltip = "hola"

   oWnd:bMMoved = { || oBtn:ShowTooltip( 30, 30, oBtn:cTooltip ) }

   ACTIVATE WINDOW oWnd CENTERED

return nil
regards, saludos

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

Re: Tooltip sobre TSButton disabled no funciona

Postby VictorCasajuana » Thu Oct 17, 2024 8:00 am

He modificado esto para comprobar si realmente se ejecutaba el codeblock aún estando el botón desactivado:

Code: Select all  Expand view
  oWnd:bMMoved = { || oBtn:ShowTooltip( 30, 30, oBtn:cTooltip ), hb_MemoWrit( 'test.log',Time()) }


y sí que se ejecuta, pero el tooltip no aparece, es algo nativo de Windows? me refiero a si hay un control desactivado, no muestra los tooltip?

He encontrado esta documentación al respecto: https://learn.microsoft.com/es-es/dotnet/api/system.windows.forms.tooltip?view=windowsdesktop-8.0 pero creo que la funcionalidad ShowAlways no la tenemos en el tooltip de fivewin
--------
¿ Y porque no ?
¿ And why not ?
User avatar
VictorCasajuana
 
Posts: 243
Joined: Wed Mar 28, 2018 4:38 pm
Location: Vinaròs

Re: Tooltip sobre TSButton disabled no funciona

Postby Antonio Linares » Thu Oct 17, 2024 9:13 am

Victor,

Este es el código que usa FWH para los tooltips:
Code: Select all  Expand view
#define FKG_FORCED_USAGE

#include <Windows.h>
#include <CommCtrl.h>
#include <hbapi.h>

#ifndef TTS_BALLOON
   #define TTS_BALLOON             0x40
#endif

#ifndef TTF_TRANSPARENT
   #define TTF_TRANSPARENT 0x0100
#endif  

#ifndef TTM_SETMAXTIPWIDTH
   #define TTM_SETMAXTIPWIDTH    (WM_USER+24)
#endif  

HMODULE GetResources( void );

#define CS_DROPSHADOW  0x00020000

HB_FUNC( CREATETOOLTIP ) // hWndParent, cText, lBallon --> hWndTooltip
{
   TOOLINFO ti;
   RECT rct;
   HWND hWndParent = ( HWND ) ( LONG_PTR ) hb_parnll( 1 );
   HWND hWnd = CreateWindowEx( 0, TOOLTIPS_CLASS, NULL,
                               WS_POPUP | TTS_ALWAYSTIP | TTS_NOPREFIX |
                               ( hb_parl( 3 ) ? TTS_BALLOON: 0 ),
                               CW_USEDEFAULT, CW_USEDEFAULT,
                               CW_USEDEFAULT, CW_USEDEFAULT,
                               hWndParent, NULL, GetModuleHandle( NULL ),
                               NULL );
   DWORD dwVersion = GetVersion();
   DWORD dwWindowsMajorVersion = ( DWORD )( LOBYTE( LOWORD( dwVersion ) ) );
   DWORD dwWindowsMinorVersion = ( DWORD )( HIBYTE( LOWORD( dwVersion ) ) );

   if( ( dwWindowsMajorVersion >= 5 && dwWindowsMinorVersion >= 1 ) || ( dwWindowsMajorVersion >= 6 ) )
      SetClassLong( hWnd, GCL_STYLE, GetClassLong( hWnd, GCL_STYLE ) | CS_DROPSHADOW );

   GetClientRect ( hWndParent, &rct );

   ti.cbSize      = sizeof( TOOLINFO );
   ti.uFlags      = TTF_SUBCLASS | TTF_TRANSPARENT;
   ti.hwnd        = hWndParent;
   ti.hinst       = GetModuleHandle( NULL );
   ti.uId         = 0;
   ti.lpszText    = ( LPSTR ) hb_parc( 2 );
   ti.rect.left   = rct.left;
   ti.rect.top    = rct.top;
   ti.rect.right  = rct.right;
   ti.rect.bottom = rct.bottom;

   SendMessage( hWnd, TTM_ADDTOOL, 0, ( LPARAM ) ( LPTOOLINFO ) &ti );
   SendMessage( hWnd, TTM_ACTIVATE, TRUE, 0 );
   SendMessage( hWnd, TTM_SETMAXTIPWIDTH, 0, 120 );

   #ifndef _WIN64
      hb_retnl( ( LONG ) hWnd );
   #else  
      hb_retnll( ( LONGLONG ) hWnd );
   #endif  
}
 
regards, saludos

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

Re: Tooltip sobre TSButton disabled no funciona

Postby Antonio Linares » Thu Oct 17, 2024 9:16 am

Este es el código modificado para que se muestre siempre. Puedes probarlo Victor ? :-)
Code: Select all  Expand view
#define FKG_FORCED_USAGE

#include <Windows.h>
#include <CommCtrl.h>
#include <hbapi.h>

#ifndef TTS_BALLOON
   #define TTS_BALLOON             0x40
#endif

#ifndef TTF_TRANSPARENT
   #define TTF_TRANSPARENT 0x0100
#endif  

#ifndef TTF_IDISHWND
   #define TTF_IDISHWND            0x0001
#endif

#ifndef TTM_SETMAXTIPWIDTH
   #define TTM_SETMAXTIPWIDTH    (WM_USER+24)
#endif  

HMODULE GetResources( void );

#define CS_DROPSHADOW  0x00020000

HB_FUNC( CREATETOOLTIP ) // hWndParent, cText, lBallon --> hWndTooltip
{
   TOOLINFO ti;
   RECT rct;
   HWND hWndParent = ( HWND ) ( LONG_PTR ) hb_parnll( 1 );
   HWND hWnd = CreateWindowEx( 0, TOOLTIPS_CLASS, NULL,
                               WS_POPUP | TTS_ALWAYSTIP | TTS_NOPREFIX |
                               ( hb_parl( 3 ) ? TTS_BALLOON: 0 ),
                               CW_USEDEFAULT, CW_USEDEFAULT,
                               CW_USEDEFAULT, CW_USEDEFAULT,
                               hWndParent, NULL, GetModuleHandle( NULL ),
                               NULL );
   DWORD dwVersion = GetVersion();
   DWORD dwWindowsMajorVersion = ( DWORD )( LOBYTE( LOWORD( dwVersion ) ) );
   DWORD dwWindowsMinorVersion = ( DWORD )( HIBYTE( LOWORD( dwVersion ) ) );

   if( ( dwWindowsMajorVersion >= 5 && dwWindowsMinorVersion >= 1 ) || ( dwWindowsMajorVersion >= 6 ) )
      SetClassLong( hWnd, GCL_STYLE, GetClassLong( hWnd, GCL_STYLE ) | CS_DROPSHADOW );

   GetClientRect ( hWndParent, &rct );

   ti.cbSize      = sizeof( TOOLINFO );
   ti.uFlags      = TTF_SUBCLASS | TTF_TRANSPARENT | TTF_IDISHWND;
   ti.hwnd        = hWndParent;
   ti.hinst       = GetModuleHandle( NULL );
   ti.uId         = (UINT_PTR) hWndParent; // Usamos el handle de la ventana como ID
   ti.lpszText    = ( LPSTR ) hb_parc( 2 );
   ti.rect.left   = rct.left;
   ti.rect.top    = rct.top;
   ti.rect.right  = rct.right;
   ti.rect.bottom = rct.bottom;

   SendMessage( hWnd, TTM_ADDTOOL, 0, ( LPARAM ) ( LPTOOLINFO ) &ti );
   SendMessage( hWnd, TTM_ACTIVATE, TRUE, 0 );
   SendMessage( hWnd, TTM_SETMAXTIPWIDTH, 0, 120 );

   #ifndef _WIN64
      hb_retnl( ( LONG ) hWnd );
   #else  
      hb_retnll( ( LONGLONG ) hWnd );
   #endif  
}
 
regards, saludos

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

Re: Tooltip sobre TSButton disabled no funciona

Postby Enrico Maria Giordano » Thu Oct 17, 2024 1:38 pm

It doesn't work. The problem is that a disable control does not generate the WM_MOUSEMOVE event.
User avatar
Enrico Maria Giordano
 
Posts: 8655
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Re: Tooltip sobre TSButton disabled no funciona

Postby Antonio Linares » Thu Oct 17, 2024 5:58 pm

Dear Enrico,

> oWnd:bMMoved = { || oBtn:ShowTooltip( 30, 30, oBtn:cTooltip ), hb_MemoWrit( 'test.log',Time()) }

We are trying to use the bMMoved of the parent
regards, saludos

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


Return to FiveWin para Harbour/xHarbour

Who is online

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