Page 1 of 2

ToolTip with Title and Icones

Posted: Fri Aug 29, 2014 3:59 pm
by Pablo César
I came here to share with you this ressource given by Alexandre Simões posted at PCToledo forum and I adapted to HMG:

Code: Select all

#include <hmg.ch>

#define WM_USER                 0x0400
#define TTM_SETTITLEA           (WM_USER + 32)
#define TTM_SETTITLEW           (WM_USER + 33)
#define TTI_NONE                0
#define TTI_INFO                1
#define TTI_WARNING             2
#define TTI_ERROR               3

// Large icons only on Vista or higher
#define TTI_INFO_LARGE          4
#define TTI_WARNING_LARGE       5
#define TTI_ERROR_LARGE         6


Function Main()
SET TOOLTIPSTYLE BALLOON 
// SET TOOLTIPSTYLE STANDARD

DEFINE WINDOW Form_1 AT 219 , 253 WIDTH 478 HEIGHT 186 ;
	TITLE "ToolTip with Title and Icone" Main
	
	DEFINE BUTTON Button_1
	    ROW    40
	    COL    20
	    WIDTH  100
	    HEIGHT 28
	    ACTION Nil
	    CAPTION "Print option"
	    FONTNAME "Arial"
	    FONTSIZE 9
	    TOOLTIP "Click here to start printing"
	END BUTTON
	
	DEFINE BUTTON Button_2
	    ROW    80
	    COL    20
	    WIDTH  100
	    HEIGHT 28
	    ACTION Nil
	    CAPTION "Cancel option"
	    FONTNAME "Arial"
	    FONTSIZE 9
	    TOOLTIP "Click here to cancel"
	END BUTTON

END WINDOW
CENTER WINDOW Form_1
ToolTipChng("Form_1", "Preview of report", TTI_INFO)
ACTIVATE WINDOW Form_1
Return Nil

Function ToolTipChng(cForm, cTitle, nIconIndex)
hb_Default(@cTitle,"")
SendMessageString(GetFormToolTipHandle(cForm),TTM_SETTITLEW, nIconIndex, cTitle)
Return Nil

#pragma BEGINDUMP

#define COMPILE_HMG_UNICODE
#include <HMG_UNICODE.h>   

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

HB_FUNC( SENDMESSAGESTRING )
{
   #ifdef UNICODE
      LPWSTR lpWCStr = HMG_parc(4) ;
   #else
      LPWSTR lpWCStr = (LPCWSTR) ( hb_parc(4) == NULL ) ? NULL : hb_mbtowc( (const char *) hb_parc(4) ) ;
   #endif
   hb_retnl( ( LONG ) SendMessage( ( HWND ) hb_parnl( 1 ), ( UINT ) hb_parni( 2 ), ( WPARAM ) hb_parnl( 3 ), ( LPARAM ) ( LPCWSTR ) lpWCStr ) );
}

#pragma ENDDUMP
This code could be adapted also to work in ANSI mode for replacing TTM_SETTITLEW by TTM_SETTITLEA.

You can also change TOOLTIPSTYLE BALLOON with STANDARD and icon style by choosing TTI_NONE, TTI_INFO, TTI_WARNING, TTI_ERROR, TTI_INFO_LARGE, TTI_WARNING_LARGE and TTI_ERROR_LARGE :!:

I hope you enjoy it :)

Re: ToolTip with Title and Icones

Posted: Fri Aug 29, 2014 5:12 pm
by andyglezl
Gracias por compartir Pablo César, lo probaremos...

Re: ToolTip with Title and Icones

Posted: Fri Aug 29, 2014 5:26 pm
by danielmaximiliano
Muy bueno la adaptacion Pablo , gracias por compartir

Re: ToolTip with Title and Icones

Posted: Fri Aug 29, 2014 5:37 pm
by Javier Tovar
Gracias Pablo César por compartir!

Saludos

ToolTip with Title and Icones

Posted: Fri Aug 29, 2014 8:45 pm
by Pablo César
Qué bueno que les hayan gustado. :D

Si olvidar que tambien se puede cambiar los colores del ToolTip, como por ejemplo:

SET TOOLTIPBACKCOLOR {255,255,0}
Screen_02.PNG
Screen_02.PNG (11.11 KiB) Viewed 6563 times
Y se podria cambiar el color de las fuentes con:

Code: Select all

#define TTM_SETTIPTEXTCOLOR     (WM_USER + 20)

Function ToolTipChng(cForm, cTitle, nIconIndex)
Local nHndTT := GetFormToolTipHandle(cForm)

hb_Default(@cTitle,"")

SendMessage( nHndTT, TTM_SETTIPTEXTCOLOR, RGB(0,92,233), 0 )                    // Só funciona sem o windows.manifest

SendMessageString(nHndTT,TTM_SETTITLEW, nIconIndex, cTitle)
Return Nil
Screen_03.PNG
Screen_03.PNG (11.09 KiB) Viewed 6562 times

Re: ToolTip with Title and Icones

Posted: Fri Aug 29, 2014 8:52 pm
by Javier Tovar
Excelente Pablo César!, en cuanto formatie mi PC pruebo los demos!

Gracias por compartir :)

Re: ToolTip with Title and Icones

Posted: Fri Aug 29, 2014 9:15 pm
by esgici
Good participation, thanks :)

Re: ToolTip with Title and Icones

Posted: Sat Aug 30, 2014 4:54 am
by bpd2000
Thank you Pablo César for sharing

Re: ToolTip with Title and Icones

Posted: Sat Aug 30, 2014 5:08 am
by Rathinagiri
Very good Pablo.

Re: ToolTip with Title and Icones

Posted: Sat Aug 30, 2014 12:24 pm
by mustafa
Hola Pablo César
He encontrado esta rutina de Marcos Antonio Gambeta
es muy parecida.

Code: Select all

#include <hmg.ch>

*--------------------------- TOOLTIP ----------------------------*
*--------- Rutina cedida  Por Marcos Antonio Gambeta ------------*
#define WM_USER             0x400
#define TTM_SETTITLE       (WM_USER + 32)
#define TTI_NONE                0
#define TTI_INFO                1
#define TTI_WARNING             2
#define TTI_ERROR               3
*----------------------------------------------------------------*

Function Main()


  SET TOOLTIPSTYLE BALLOON


DEFINE WINDOW Form_1 AT 219 , 253 WIDTH 478 HEIGHT 186 ;
   TITLE "ToolTip with Title and Icone" Main
   
   DEFINE BUTTON Button_1
       ROW    40
       COL    20
       WIDTH  100
       HEIGHT 28
       ACTION Nil
       CAPTION "Print option"
       FONTNAME "Arial"
       FONTSIZE 9
       TOOLTIP "Click here to start printing"
   END BUTTON
   
   DEFINE BUTTON Button_2
       ROW    80
       COL    20
       WIDTH  100
       HEIGHT 28
       ACTION Nil
       CAPTION "Cancel option"
       FONTNAME "Arial"
       FONTSIZE 9
       TOOLTIP "Click here to cancel"
   END BUTTON

END WINDOW


*---------------------------------------------   TOOLTIP   --------------------------------------------*

       SendMessageString( GetFormToolTipHandle ("Form_1"), TTM_SETTITLE, TTI_INFO, "Preview of report" )  

*------------------------------------------------------------------------------------------------------*


CENTER WINDOW Form_1
ACTIVATE WINDOW Form_1
Return Nil


*---------------------------------------*
#pragma BEGINDUMP

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

HB_FUNC ( SENDMESSAGESTRING )
{
  hb_retnl( (LONG) SendMessage( (HWND) hb_parnl(1), (UINT) hb_parni(2), (WPARAM) hb_parnl(3), (LPARAM) (LPSTR) hb_parc(4) ) );
}

#pragma ENDDUMP
*---------------------------------------*


Saludos
Mustafa :)