ToolTip with Title and Icones

Topic Specific Tutorials and Tips.

Moderator: Rathinagiri

User avatar
Pablo César
Posts: 4059
Joined: Wed Sep 08, 2010 1:18 pm
Location: Curitiba - Brasil
Has thanked: 100 times
Been thanked: 182 times

ToolTip with Title and Icones

Post by Pablo César » Fri Aug 29, 2014 3:59 pm

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 :)
Attachments
Screen_01.PNG
Screen_01.PNG (11.19 KiB) Viewed 3022 times
HMGing a better world
"Matter tells space how to curve, space tells matter how to move."
Albert Einstein

User avatar
andyglezl
Posts: 1161
Joined: Fri Oct 26, 2012 7:58 pm
Location: Guadalajara Jalisco, MX
Has thanked: 35 times
Been thanked: 73 times
Contact:

Post by andyglezl » Fri Aug 29, 2014 5:12 pm

Gracias por compartir Pablo César, lo probaremos...
Andrés González López
Desde Guadalajara, Jalisco. México.

User avatar
danielmaximiliano
Posts: 2150
Joined: Fri Apr 09, 2010 4:53 pm
Location: Argentina
Has thanked: 162 times
Been thanked: 26 times
Contact:

Post by danielmaximiliano » Fri Aug 29, 2014 5:26 pm

Muy bueno la adaptacion Pablo , gracias por compartir
*´¨)
¸.·´¸.·*´¨) ¸.·*¨)
(¸.·´. (¸.·` *
.·`.HMG : It's magic !
(¸.·``··*

Saludos / Regards
DaNiElMaXiMiLiAnO

Whatsapp. : +54901169026142
Telegram Name : DaNiElMaXiMiLiAnO

Javier Tovar
Posts: 1275
Joined: Tue Sep 03, 2013 4:22 am
Location: Tecámac, México
Has thanked: 1 time
Been thanked: 2 times

Post by Javier Tovar » Fri Aug 29, 2014 5:37 pm

Gracias Pablo César por compartir!

Saludos

User avatar
Pablo César
Posts: 4059
Joined: Wed Sep 08, 2010 1:18 pm
Location: Curitiba - Brasil
Has thanked: 100 times
Been thanked: 182 times

Post by Pablo César » Fri Aug 29, 2014 8:45 pm

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 2977 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 2976 times
HMGing a better world
"Matter tells space how to curve, space tells matter how to move."
Albert Einstein

Javier Tovar
Posts: 1275
Joined: Tue Sep 03, 2013 4:22 am
Location: Tecámac, México
Has thanked: 1 time
Been thanked: 2 times

Post by Javier Tovar » Fri Aug 29, 2014 8:52 pm

Excelente Pablo César!, en cuanto formatie mi PC pruebo los demos!

Gracias por compartir :)

User avatar
esgici
Posts: 4515
Joined: Wed Jul 30, 2008 9:17 pm
DBs Used: DBF
Location: iskenderun / Turkiye
Has thanked: 389 times
Been thanked: 111 times
Contact:

Post by esgici » Fri Aug 29, 2014 9:15 pm

Good participation, thanks :)
Viva INTERNATIONAL HMG :D

User avatar
bpd2000
Posts: 1078
Joined: Sat Sep 10, 2011 4:07 am
Location: India
Has thanked: 197 times
Been thanked: 96 times

Post by bpd2000 » Sat Aug 30, 2014 4:54 am

Thank you Pablo César for sharing
BPD
Convert Dream into Reality through HMG

User avatar
Rathinagiri
Posts: 5263
Joined: Tue Jul 29, 2008 6:30 pm
DBs Used: MariaDB, SQLite, SQLCipher and MySQL
Location: Sivakasi, India
Has thanked: 169 times
Been thanked: 172 times
Contact:

Post by Rathinagiri » Sat Aug 30, 2014 5:08 am

Very good Pablo.
East or West HMG is the Best.
South or North HMG is worth.
...the possibilities are endless.

User avatar
mustafa
Posts: 839
Joined: Fri Mar 20, 2009 11:38 am
DBs Used: DBF
Location: Alicante - Spain
Been thanked: 120 times
Contact:

Post by mustafa » Sat Aug 30, 2014 12:24 pm

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 :)

Post Reply