ejemplo c5Tooltip
- Antonio Linares
- Site Admin
- Posts: 42521
- Joined: Thu Oct 06, 2005 5:47 pm
- Location: Spain
- Has thanked: 31 times
- Been thanked: 76 times
- Contact:
Re: ejemplo c5Tooltip
Del código inicial de c5cnew.c de Paco, quitamos una serie de funciones que correspondian estar en otro fichero, ó que ya estaban duplicadas. Algunas funciones se modificaron para usar todos los parámetros disponibles. Aqui podeis ver las diferencias entre el código original de Paco y el modificado por nosotros:
https://bitbucket.org/fivetech/c5controls/commits/5ed469b2bb164a9381f3896d4872c5bc130528cd
En siguientes mensajes comentamos esas diferencias.
https://bitbucket.org/fivetech/c5controls/commits/5ed469b2bb164a9381f3896d4872c5bc130528cd
En siguientes mensajes comentamos esas diferencias.
- Antonio Linares
- Site Admin
- Posts: 42521
- Joined: Thu Oct 06, 2005 5:47 pm
- Location: Spain
- Has thanked: 31 times
- Been thanked: 76 times
- Contact:
Re: ejemplo c5Tooltip
* La función AnsiToWide() ya existe en FWH, asi que la quitamos de la librería de Paco. La sintaxis es la misma entre la de Paco y la nuestra.
* la función CreateCompatibleBitmap() pasa a las funciones de bitmaps de FWH. la sintaxis se mantiene.
* Igual para la función CreateCompatibleDC()
* La función DeleteFile() de Paco se renombró a FWDeleteFile().
* La función DrawState() se llevó al fichero drawing.c de FWH, pero cambiamos sus parámetros, puesto que la de Paco ignoraba dos parámetros que la función puede recibir. Estos cambios requieren cambios en el código PRG de Paco. Hay que revisarlos.
* la función RoundRect() ya existía en FWH, asi que se eliminó de la librería de Paco. Ojo que la función de FWH admite un octavo parámetro como hPen y además los parámetros de coordenadas estan cambiados. Hay que revisar los PRGs de Paco en donde se use.
* la función StretchBlt() estaba ya en FWH en bmpdraw.c. Los parámetros son los mismos.
* Se elimina la función WideToAnsi() pues ya existía en FWH.
* Se elimina la función DriveType() pues ya existía en FWH la función GetDriveType() que es un wrapper a la del API de Windows.
* Una serie de arrays publicos de bytes, los hacemos static para evitar tenerlos como públicos.
* la función ChildWindowFromPoint() estaba en FWH y con los mismos parámetros. Se elimina la de Paco.
* Se aplicó la macro HB_SYMBOL_UNUSED() en aquellos parámetros que Paco no estaba usando para eliminar los warnings al compilar.
* la función CreateCompatibleBitmap() pasa a las funciones de bitmaps de FWH. la sintaxis se mantiene.
* Igual para la función CreateCompatibleDC()
* La función DeleteFile() de Paco se renombró a FWDeleteFile().
* La función DrawState() se llevó al fichero drawing.c de FWH, pero cambiamos sus parámetros, puesto que la de Paco ignoraba dos parámetros que la función puede recibir. Estos cambios requieren cambios en el código PRG de Paco. Hay que revisarlos.
* la función RoundRect() ya existía en FWH, asi que se eliminó de la librería de Paco. Ojo que la función de FWH admite un octavo parámetro como hPen y además los parámetros de coordenadas estan cambiados. Hay que revisar los PRGs de Paco en donde se use.
* la función StretchBlt() estaba ya en FWH en bmpdraw.c. Los parámetros son los mismos.
* Se elimina la función WideToAnsi() pues ya existía en FWH.
* Se elimina la función DriveType() pues ya existía en FWH la función GetDriveType() que es un wrapper a la del API de Windows.
* Una serie de arrays publicos de bytes, los hacemos static para evitar tenerlos como públicos.
* la función ChildWindowFromPoint() estaba en FWH y con los mismos parámetros. Se elimina la de Paco.
* Se aplicó la macro HB_SYMBOL_UNUSED() en aquellos parámetros que Paco no estaba usando para eliminar los warnings al compilar.
- Antonio Linares
- Site Admin
- Posts: 42521
- Joined: Thu Oct 06, 2005 5:47 pm
- Location: Spain
- Has thanked: 31 times
- Been thanked: 76 times
- Contact:
Re: ejemplo c5Tooltip
Revisando c5tooltip.prg se observa:
* que no usa la función DrawState().
* Tampoco usa la función RoundRect()
* que no usa la función DrawState().
* Tampoco usa la función RoundRect()
- Antonio Linares
- Site Admin
- Posts: 42521
- Joined: Thu Oct 06, 2005 5:47 pm
- Location: Spain
- Has thanked: 31 times
- Been thanked: 76 times
- Contact:
Re: ejemplo c5Tooltip
Construyamos un ejemplo sencillo con los C5tooltips y veamos lo que ocurre:
El handle de ventana del tooltip aparece correctamente.
Code: Select all | Expand
#include "FiveWin.ch"
function Main()
local oWnd, oTT
DEFINE WINDOW oWnd
oTT = TC5Tooltip():New( 10, 10, 100, 100, oWnd )
MsgInfo( oTT:hWnd )
ACTIVATE WINDOW oWnd
return nil
El handle de ventana del tooltip aparece correctamente.
- Antonio Linares
- Site Admin
- Posts: 42521
- Joined: Thu Oct 06, 2005 5:47 pm
- Location: Spain
- Has thanked: 31 times
- Been thanked: 76 times
- Contact:
Re: ejemplo c5Tooltip
Bueno, ya he conseguido que se vean
Hay que modificar una serie de cosas:


Code: Select all | Expand
#include "FiveWin.ch"
function Main()
local oWnd, oTT
DEFINE WINDOW oWnd
oTT = TC5Tooltip():New( 100, 100, 250, 150, oWnd, .T., CLR_CYAN, CLR_WHITE )
oTT:cHeader = "header"
oTT:cBody = "this is the body of the tooltip" + CRLF + "It looks nice"
oTT:cFoot = "this is the footer"
ACTIVATE WINDOW oWnd
return nil

- Antonio Linares
- Site Admin
- Posts: 42521
- Joined: Thu Oct 06, 2005 5:47 pm
- Location: Spain
- Has thanked: 31 times
- Been thanked: 76 times
- Contact:
Re: ejemplo c5Tooltip
Para que el ejemplo anterior se muestre, hay que eliminar el método Create() de la Clase TC5ToolTip de Paco.
El usa una clase predefinida "#32768" que corresponde a la clase de creación de menues de Windows:
http://msdn.microsoft.com/en-us/library/windows/desktop/ms633574(v=vs.85).aspx
Tambien hay que comentar la llamada a ::Default() que hace desde el método New(). Ahí trabaja con regiones, pero algo falla.
El usa una clase predefinida "#32768" que corresponde a la clase de creación de menues de Windows:
http://msdn.microsoft.com/en-us/library/windows/desktop/ms633574(v=vs.85).aspx
Tambien hay que comentar la llamada a ::Default() que hace desde el método New(). Ahí trabaja con regiones, pero algo falla.
- Antonio Linares
- Site Admin
- Posts: 42521
- Joined: Thu Oct 06, 2005 5:47 pm
- Location: Spain
- Has thanked: 31 times
- Been thanked: 76 times
- Contact:
Re: ejemplo c5Tooltip
Los métodos Show() y Hide() llaman a sus respectivos de Super, por lo que pueden eliminarse.
- Antonio Linares
- Site Admin
- Posts: 42521
- Joined: Thu Oct 06, 2005 5:47 pm
- Location: Spain
- Has thanked: 31 times
- Been thanked: 76 times
- Contact:
Re: ejemplo c5Tooltip
Aqui teneis nuestros cambios, con los que el ejemplo mostrado funciona:
https://bitbucket.org/fivetech/c5controls/commits/c092900bc18432058f949f83980466c2ade39631
https://bitbucket.org/fivetech/c5controls/commits/c092900bc18432058f949f83980466c2ade39631
Re: ejemplo c5Tooltip
Antonio,
Felicitaciones, muy buena aportación...
sería interesante ver un ejemplo práctico de como relacionar el c5ttip con cualquier control fwh, ej. menus, botones de buttonbar o rbar, etc.
Gracias!
Salu2, Ariel.
Felicitaciones, muy buena aportación...
sería interesante ver un ejemplo práctico de como relacionar el c5ttip con cualquier control fwh, ej. menus, botones de buttonbar o rbar, etc.
Gracias!
Salu2, Ariel.
- Antonio Linares
- Site Admin
- Posts: 42521
- Joined: Thu Oct 06, 2005 5:47 pm
- Location: Spain
- Has thanked: 31 times
- Been thanked: 76 times
- Contact:
Re: ejemplo c5Tooltip
Ariel,
Aun falta mucho más para poder usarlos. Paco me comentó que sus tooltips usan la técnica inicial que usaba FiveWin (nosotros creábamos los tooltips, de hecho los tooltips de C5 estan basados en la misma técnica que nosotros usábamos, pero con muchas mejoras estéticas), antes de que usásemos los tooltips estandard de Windows.
Eso quiere decir que hay que volver a modificar la Clase TWindow para que soporte ambos tipos de tooltips, y eso no es algo rápido de hacer. Hay que buscar
cuidadosamente los sitios en donde volver a hacer esa implementación y probar que todo funcione bien.
Aun falta mucho más para poder usarlos. Paco me comentó que sus tooltips usan la técnica inicial que usaba FiveWin (nosotros creábamos los tooltips, de hecho los tooltips de C5 estan basados en la misma técnica que nosotros usábamos, pero con muchas mejoras estéticas), antes de que usásemos los tooltips estandard de Windows.
Eso quiere decir que hay que volver a modificar la Clase TWindow para que soporte ambos tipos de tooltips, y eso no es algo rápido de hacer. Hay que buscar
cuidadosamente los sitios en donde volver a hacer esa implementación y probar que todo funcione bien.
- cuatecatl82
- Posts: 625
- Joined: Wed Mar 14, 2007 6:49 pm
- Location: San Cristobal de las Casas, Chiapas México
- Contact:
Re: ejemplo c5Tooltip
Maestro Antonio:
Mis respetos, no hay duda que el que sabe, sabe, ayer me puse a revisar el código original y me quede liado.
Excelente trabajo, empezaremos a probar y a comentar.
Gracias Maestro por tomarse la molestia de hecharle un vistazo a este tema.

Mis respetos, no hay duda que el que sabe, sabe, ayer me puse a revisar el código original y me quede liado.
Excelente trabajo, empezaremos a probar y a comentar.
Gracias Maestro por tomarse la molestia de hecharle un vistazo a este tema.



Soluciones y Diseño de Software
Damos Soluciones...
I.S.C. Victor Daniel Cuatecatl Leon
Director y Diseñador de Proyectos
http://www.soldisoft.unlugar.com
http://www.sisa.unlugar.com
danyleon82@hotmail.com
www.facebook.com/victordaniel.cuatecatlleon
Damos Soluciones...
I.S.C. Victor Daniel Cuatecatl Leon
Director y Diseñador de Proyectos
http://www.soldisoft.unlugar.com
http://www.sisa.unlugar.com
danyleon82@hotmail.com
www.facebook.com/victordaniel.cuatecatlleon
Re: ejemplo c5Tooltip
y porque no usar solo los toltips de paco?
se ven mas chulos,
sin de meritar los nativos jeje.
saludos.
se ven mas chulos,
sin de meritar los nativos jeje.
saludos.
Cesar Cortes Cruz
SysCtrl Software
Mexico
' Sin +- FWH es mejor "
SysCtrl Software
Mexico
' Sin +- FWH es mejor "
- cuatecatl82
- Posts: 625
- Joined: Wed Mar 14, 2007 6:49 pm
- Location: San Cristobal de las Casas, Chiapas México
- Contact:
Re: ejemplo c5Tooltip
Estoy tratando de compilar con Harbour 3.0 TC5Tooltip.prg y tengo algunos warnings y errores:
Aqui el código:
Obj\TC5Tooltip.c:
Warning W8065 TC5Tooltip.prg 574: Call to function 'IF' with no prototype in function HB_FUN_SETLAYEREDWINDOWATTRIBUTES
Error E2379 TC5Tooltip.prg 575: Statement missing ; in function HB_FUN_SETLAYEREDWINDOWATTRIBUTES
Warning W8065 TC5Tooltip.prg 644: Call to function 'IF' with no prototype in function Array2Point
Error E2379 TC5Tooltip.prg 644: Statement missing ; in function Array2Point
Warning W8070 TC5Tooltip.prg 650: Function should return a value in function Array2Point
Warning W8057 TC5Tooltip.prg 650: Parameter 'pt' is never used in function Array2Point
Warning W8065 TC5Tooltip.prg 661: Call to function 'IF' with no prototype in function HB_FUN_CREATEPOLYGONRGN
Error E2379 TC5Tooltip.prg 662: Statement missing ; in function HB_FUN_CREATEPOLYGONRGN
Aqui el código:
Code: Select all | Expand
#include "fivewin.ch"
#define CW_USEDEFAULT 32768
#define SRCCOPY 13369376
#define DT_TOP 0x00000000
#define DT_LEFT 0x00000000
#define DT_CENTER 0x00000001
#define DT_RIGHT 0x00000002
#define DT_VCENTER 0x00000004
#define DT_BOTTOM 0x00000008
#define DT_WORDBREAK 0x00000010
#define DT_SINGLELINE 0x00000020
#define DT_EXPANDTABS 0x00000040
#define DT_TABSTOP 0x00000080
#define DT_NOCLIP 0x00000100
#define DT_EXTERNALLEADING 0x00000200
#define DT_CALCRECT 0x00000400
#define DT_NOPREFIX 0x00000800
#define DT_INTERNAL 0x00001000
CLASS TC5Tooltip FROM TWindow
CLASSDATA lRegistered AS LOGICAL
DATA lSplitHdr AS LOGICAL INIT .f.
DATA lLeft AS LOGICAL INIT .f.
DATA lLineHeader AS LOGICAL INIT .f.
DATA lLineFoot AS LOGICAL INIT .F.
DATA lBorder AS LOGICAL INIT .t.
DATA lBtnClose AS LOGICAL INIT .f.
DATA cHeader AS CHARACTER INIT ""
DATA cBmpLeft AS CHARACTER INIT ""
DATA cBody AS CHARACTER INIT ""
DATA cBmpFoot AS CHARACTER INIT ""
DATA cFoot AS CHARACTER INIT ""
DATA lRightAlignBody AS LOGICAL INIT .F.
DATA cLibHeader
DATA cBmpHeader
DATA cLibLeft
DATA cLibFoot
DATA cTumbNail AS CHARACTER INIT ""
DATA cHeader2 AS CHARACTER INIT SPACE(255)
DATA nClrPane2
DATA nClrBorder AS NUMERIC INIT 0
DATA nClrSepara1 AS NUMERIC INIT RGB(157,188,219)
DATA nClrSepara2 AS NUMERIC INIT CLR_WHITE
DATA nClrTextHeader
DATA nClrTextBody
DATA nClrTextFoot
DATA oFontHdr
DATA oFontHdr2
DATA oFontBody
DATA oFontPie
DATA aHeader AS ARRAY INIT {0,0,0,0}
DATA aHeader2 AS ARRAY INIT {0,0,0,0}
DATA aBody AS ARRAY INIT {0,0,0,0}
DATA aLeft AS ARRAY INIT {0,0,0,0}
DATA aRight AS ARRAY INIT {0,0,0,0}
DATA aFoot AS ARRAY INIT {0,0,0,0}
DATA aBtnClose AS ARRAY INIT {0,0,0,0}
DATA nWRadio
DATA nHRadio
DATA nGetColor
DATA aOldPos, nOldRow, nOldCol
DATA hRgn
DATA nMResize
DATA bBmpLeft
DATA nFixWidth
DATA nFixHeight
DATA bOwnerDraw
METHOD New( nTop, nLeft, nWidth, nHeight, oWnd, lDisenio, nClrPane, nClrPane2, nClrText, nWRadio, nHRadio ) CONSTRUCTOR
METHOD DEFAULT ()
METHOD Destroy() INLINE ::oFontHdr :END(),;
::oFontHdr2:END(),;
::oFontBody:END(),;
::oFontPie :END(),;
DeleteObject( ::hRgn ),;
super:Destroy()
METHOD EndPaint() INLINE ::nPaintCount--,EndPaint( ::hWnd, ::cPS ), ::cPS := Nil, ::hDC := Nil, 0
METHOD DISPLAY() INLINE ::BeginPaint(),::PAINT(),::EndPaint(),0
METHOD PAINT ()
METHOD PaintHdr ( hDC, rc )
METHOD PaintHdr2( hDC, rc )
METHOD PaintBody( hDC, rc )
METHOD PaintFoot( hDC, rc )
METHOD HandleEvent( nMsg, nWParam, nLParam )
METHOD ReSize( nSizeType, nWidth, nHeight )
METHOD lHeader() INLINE !EMPTY( ::cHeader )
METHOD lFoot() INLINE !EMPTY( ::cFoot )
METHOD GetSize()
METHOD SetSize( nWidth, nHeight ) INLINE Super:SetSize( nWidth, nHeight, .t. )
METHOD CREATE( cClsName )
METHOD Show()
METHOD Hide()
ENDCLASS
*********************************************************************************************************************************
METHOD New( nTop, nLeft, nWidth, nHeight, oWnd, lDisenio, nClrPane, nClrPane2, nClrText, nWRadio, nHRadio ) CLASS TC5ToolTip
*********************************************************************************************************************************
DEFAULT nClrPane := CLR_WHITE
DEFAULT nClrPane2 := nClrPane
DEFAULT nClrText := 0
DEFAULT nWRadio := 2
DEFAULT nHRadio := 2
::oWnd := oWnd
::nStyle := nOR( WS_POPUP )
::nTop := nTop
::nLeft := nLeft
::nBottom := nTop + nHeight
::nRight := nLeft + nWidth
::nClrPane := nClrPane
::nClrPane2 := nClrPane2
::nClrText := nClrText
::nClrBorder := RGB( 118,118,118 )
::nWRadio := nWRadio
::nHRadio := nHRadio
DEFINE FONT ::oFontHdr NAME "Verdana" SIZE 0, -11 BOLD
DEFINE FONT ::oFontHdr2 NAME "Verdana" SIZE 0, -11
DEFINE FONT ::oFontBody NAME "Segoe UI" SIZE 0, -11
DEFINE FONT ::oFontPie NAME "Verdana" SIZE 0, -11 BOLD
::Register( nOR( CS_VREDRAW, CS_HREDRAW ) ) //, 131072
::CREATE()
::cTitle := "Undefined"
::hRgn := Nil
::DEFAULT(.t.)
RETURN Self
*********************************************************************************************************************************
METHOD CREATE( cClsName ) CLASS TC5ToolTip
*********************************************************************************************************************************
DEFAULT cClsName := ::ClassName(), ::cCaption := "",;
::nStyle := WS_OVERLAPPEDWINDOW,;
::nTop := 0, ::nLeft := 0, ::nBottom := 10, ::nRight := 10,;
::nId := 0
IF ::oWnd != Nil
::nStyle = nOR( ::nStyle, WS_CHILD )
ENDIF
IF ::nBottom != CW_USEDEFAULT
::hWnd = CreateWindow( "#32768", ::cCaption, WS_POPUP ,;
::nLeft, ::nTop, ::nRight - ::nLeft + 1, ;
::nBottom - ::nTop + 1, ;
IF( ::oWnd != Nil, ::oWnd:hWnd, 0 ), ;
::nId )
ELSE
::hWnd = CreateWindow( "#32768", ::cCaption, WS_POPUP, ;
::nLeft, ::nTop, ::nRight, ::nBottom, ;
IF( ::oWnd != Nil, ::oWnd:hWnd, 0 ), ;
::nId )
ENDIF
IF ::hWnd == 0
WndCreateError( Self )
ELSE
::Link()
ENDIF
RETURN Nil
************************************************************************************************************************
METHOD GetSize() CLASS TC5ToolTip
************************************************************************************************************************
LOCAL rc := 0
LOCAL ASIZE := { 0, 0 }
LOCAL hBmp := 0
LOCAL hDC := 0
LOCAL hOldFont := 0
LOCAL n := 0
LOCAL nHBmp := 0
LOCAL nHText := 0
LOCAL nHeight := 0
LOCAL nLen := 0
LOCAL nW := 0
LOCAL nW2 := 0
LOCAL nWB := 0
LOCAL nWBmp := 0
LOCAL nWBodyTxt := 227
LOCAL nWF := 0
LOCAL nWH := 0
LOCAL nWidth := 0
IF ::nFixWidth != Nil .AND. ::nFixHeight != Nil
RETURN {::nFixWidth, ::nFixHeight}
ENDIF
rc := GetClientRect(::hWnd)
nWidth := nWBodyTxt
// Cabecera
IF !EMPTY( ::cHeader )
nHeight += 31
nWH := GetTextWidth( 0, ::cHeader, ::oFontHdr:hFont )+ 16
ENDIF
// Imagen a la izquierda
IF !EMPTY( ::cBmpLeft )
hBmp := LoadImageEx( ::cBmpLeft )
ELSE
IF ::bBmpLeft != Nil
hBmp := EVAL( ::bBmpLeft, self )
ENDIF
ENDIF
IF hBmp != 0
nWBmp := BmpWidth ( hBmp )
nHBmp := BmpHeight( hBmp )
nWidth += ( 14 + nWBmp )
DeleteObject( hBmp )
ENDIF
IF EMPTY(::cHeader) .AND. EMPTY(::cFoot)
nWidth := 13 + IF( nWBmp != 0, (nWBmp+13),0) + GetTextWidth(0,::cBody,::oFontBody:hFont ) + 26
ENDIF
IF !EMPTY( ::cFoot )
nHeight += 30
nWF := GetTextWidth( 0, ::cFoot, ::oFontPie:hFont ) +22
ENDIF
nWidth := MAX( MAX( nWidth, nWH ), nWF )
IF EMPTY(::cHeader) .AND. EMPTY(::cFoot)
nWidth := MIN(nWidth,227)
ENDIF
// Si tenemos texto en el cuerpo del tooltip
IF !EMPTY( ::cBody )
hDC := CreateDC( "DISPLAY",0,0,0)
hOldFont := SelectObject( hDC, ::oFontBody:hFont )//
nHText := DrawText( hDC, ALLTRIM(::cBody), { 0, 12+nWBmp+12+10, 20, nWidth }, nOr(DT_WORDBREAK, 8192, DT_CALCRECT ) )
//nHText := DrawText( hDC, alltrim(::cBody), { 0, 6+nWBmp+12+6, 20, nWidth }, nOr(DT_WORDBREAK, 8192, DT_CALCRECT ) )
SelectObject( hDC, hOldFont )
DeleteDC( hDC )
nHeight += nHText
nHeight+=8
ENDIF
nHeight := MAX( nHeight, nHBmp )
ASIZE := { nWidth, nHeight }
RETURN ASIZE
************************************************************************************************************************
METHOD DEFAULT( lShowDlg ) CLASS TC5ToolTip
************************************************************************************************************************
LOCAL rc := {0, 0, ::nHeight, ::nWidth}
LOCAL hRgn
LOCAL hRgn2
LOCAL hRgn3
LOCAL o := self
DEFAULT lShowDlg := .F.
::hRgn := CreateRoundRectRgn( rc[2] ,rc[1], rc[4], rc[3] , ::nWRadio, ::nHRadio )
SetWindowRgn(::hWnd, ::hRgn, .t. )
DeleteObject( ::hRgn )
RETURN 0
#define GW_CHILD 5
#define GW_HWNDNEXT 2
************************************************************************************************************************
METHOD HandleEvent( nMsg, nWParam, nLParam ) CLASS TC5Tooltip
************************************************************************************************************************
IF nMsg == 20
RETURN 1
ENDIF
RETURN super:HandleEvent( nMsg, nWParam, nLParam )
************************************************************************************************************************
METHOD ReSize( nSizeType, nWidth, nHeight ) CLASS TC5Tooltip
************************************************************************************************************************
::DEFAULT()
::Refresh()
RETURN super:ReSize( nSizeType, nWidth, nHeight )
************************************************************************************************************************
METHOD PAINT() CLASS TC5ToolTip
************************************************************************************************************************
LOCAL hDCMem := CreateCompatibleDC ( ::hDC )
LOCAL rc := GetClientRect ( ::hWnd )
LOCAL hBmpMem := CreateCompatibleBitmap( ::hDC, rc[4]-rc[2], rc[3]-rc[1] )
LOCAL hOldBmp := SelectObject ( hDCMem, hBmpMem )
LOCAL nWRadio := ::nWRadio
LOCAL nHRadio := ::nHRadio
LOCAL nClrText := SetTextColor( hDCMem, ::nClrText )
LOCAL hBrush
LOCAL hRgn := CreateRoundRectRgn( rc[2] ,rc[1], rc[4], rc[3] , ::nWRadio, ::nHRadio )
rc[3]--; rc[4]--
nWRadio += 2
nHRadio += 2
VerticalGradient( hDCMem, {rc[1]-1,rc[2],rc[3],rc[4]}, ::nClrPane, ::nClrPane2 )
IF ::bOwnerDraw == Nil
::PaintHdr ( hDCMem, rc ) // ::PaintHdr2( hDCMem, rc )
::PaintFoot( hDCMem, rc )
::PaintBody( hDCMem, rc )
ELSE
EVAL( ::bOwnerDraw, hDCMem )
ENDIF
hBrush := CreateSolidBrush( ::nClrBorder )
FrameRgn( hDCMem, hRgn, hBrush, 1, 1 )
DeleteObject( hBrush )
DeleteObject( hRgn )
SetTextColor( hDCMem, nClrText )
BitBlt( ::hDC, 0, 0, rc[4]-rc[2], rc[3]-rc[1], hDCMem, 0, 0, SRCCOPY )
SelectObject( hDCMem, hOldBmp )
DeleteDC ( hDCMem )
DeleteObject( hBmpMem )
RETURN 0
************************************************************************************************************************
METHOD PaintHdr ( hDC, rc ) CLASS TC5ToolTip
************************************************************************************************************************
LOCAL hBmpHdr
LOCAL nWBmpHdr := 0
LOCAL hOldFont
LOCAL nClrText
LOCAL lIcon := .f.
LOCAL nTop
LOCAL nMode
// 25 pixels
IF ::lHeader
::aHeader := {rc[1],rc[2],rc[1]+25,rc[4]}
IF !EMPTY(::cBmpHeader)
hBmpHdr := LoadImageEx( ::cBmpHeader )
IF hBmpHdr != 0
nWBmpHdr := BmpWidth( hBmpHdr )
nTop := (::aHeader[1]+(::aHeader[3]-::aHeader[1])/2)-BmpHeight(hBmpHdr)/2
nTop := MAX( nTop, 5)
DrawMasked( hDC, hBmpHdr, nTop , 5 )
DeleteObject( hBmpHdr )
ENDIF
ENDIF
hOldFont := SelectObject( hDC, ::oFontHdr:hFont )
IF ::nClrTextHeader != Nil
nClrText := SetTextColor( hDC, ::nCLrTextHeader )
ENDIF
nMode := SetBkMode( hDC, 1 )
DrawText( hDC, ::cHeader, {::aHeader[1],::aHeader[2]+10+IF(hBmpHdr!=0,nWBmpHdr,0),::aHeader[3],::aHeader[4]-10},nOr( DT_VCENTER, DT_SINGLELINE, 8192 ) )
SetBkMode( hDC, nMode )
IF ::nClrTextHeader != Nil
SetTextColor( hDC, nClrText )
ENDIF
SelectObject( hDC, hOldFont )
ELSE
::aHeader := {rc[1],rc[2],rc[1],rc[4]}
ENDIF
RETURN 0
************************************************************************************************************************
METHOD PaintHdr2( hDC, rc ) CLASS TC5ToolTip
************************************************************************************************************************
LOCAL hOldFont
LOCAL nClrText
::aHeader2 := {::aHeader[3],rc[2],::aHeader[3],rc[4]}
IF ::lHeader
IF ::lSplitHdr
::aHeader2 := {::aHeader[3],rc[2],::aHeader[3]+25,rc[4]}
ENDIF
IF ::lLineHeader
Line( hDC, ::aHeader2[3] , ::aHeader2[2]+5, ::aHeader2[3] , ::aHeader2[4]-5, ::nClrSepara1 )
Line( hDC, ::aHeader2[3]+1, ::aHeader2[2]+5, ::aHeader2[3]+1, ::aHeader2[4]-5, ::nClrSepara2 )
ENDIF
hOldFont := SelectObject( hDC, ::oFontHdr2:hFont )
IF ::nClrTextHeader != Nil
nClrText := SetTextColor( hDC, ::nCLrTextHeader )
ENDIF
IF ::lSplitHdr .AND. !EMPTY( ::cHeader2 )
DrawText( hDC, ::cHeader2, {::aHeader2[1]+1,::aHeader2[2]+20,::aHeader2[3],::aHeader2[4]-2}, nOR(DT_WORDBREAK, 8192) )
ENDIF
IF ::nClrTextHeader != Nil
SetTextColor( hDC, nClrText )
ENDIF
SelectObject( hDC, hOldFont )
ENDIF
RETURN 0
************************************************************************************************************************
METHOD PaintBody( hDC, rc ) CLASS TC5ToolTip
************************************************************************************************************************
LOCAL hOldFont
LOCAL nWBmp := 0
LOCAL nClrText
LOCAL lIcon := .f.
LOCAL nMode
LOCAL hBmpLeft := 0
LOCAL n
LOCAL nLen
LOCAL nW
LOCAL nW2
LOCAL aLeft
::aLeft := {0,0,0,0}
::aBody := {::aHeader[3],rc[2],::aFoot[1],rc[4]}
IF EMPTY(::cBmpLeft)
::aLeft := {::aBody[1],rc[2],::aBody[3],IF(::lLeft,(rc[4]-rc[2])*0.33,rc[2])}
ELSE
hBmpLeft := LoadImageEx( ::cBmpLeft )
IF hBmpLeft != 0
nWBmp := BmpWidth( hBmpLeft )
::aLeft := { ::aBody[1],rc[2],::aBody[3],12+nWBmp+12}
ENDIF
ENDIF
IF ::bBmpLeft != Nil
hBmpLeft := EVAL( ::bBmpLeft, self )
IF hBmpLeft != 0
nWBmp := BmpWidth( hBmpLeft )
::aLeft := { ::aBody[1],rc[2],::aBody[3],12+nWBmp+12}
ENDIF
ENDIF
//
::aRight := {::aBody[1] +3,::aLeft[4]+20,::aBody[3]-3,rc[4]-10}
hOldFont := SelectObject( hDC, ::oFontBody:hFont )
nMode := SetBkMode( hDC, 1 )
DrawText( hDC,ALLTRIM(::cBody), ::aRight, nOr(IF( ::lRightAlignBody,DT_RIGHT,DT_LEFT), DT_WORDBREAK ) )
SetBkMode( hDC, nMode )
SelectObject( hDC, hOldFont )
IF hBmpLeft != 0
DrawMasked( hDC, hBmpLeft, ::aLeft[1]+5, ::aLeft[2]+12 )
DeleteObject( hBmpLeft )
ENDIF
RETURN 0
************************************************************************************************************************
METHOD PaintFoot( hDC, rc ) CLASS TC5ToolTip
************************************************************************************************************************
LOCAL hOldFont, hBmpFoot
LOCAL nWFoot := 0
LOCAL nClrText
LOCAL lIcon := .f.
LOCAL nMode
IF ::lFoot
::aFoot := {rc[3]-30,rc[2],rc[3],rc[4]}
IF !EMPTY(::cBmpFoot)
::aFoot := {rc[3]-30,rc[2],rc[3],rc[4]}
ENDIF
hBmpFoot := LoadImageEx( ::cBmpFoot )
IF hBmpFoot != 0
nWFoot := BmpWidth( hBmpFoot )
::aFoot := {rc[3]-30,rc[2],rc[3],rc[4]}
DrawMasked( hDC, hBmpFoot, (::aFoot[1]+(::aFoot[3]-::aFoot[1])/2)-BmpHeight(hBmpFoot)/2, 5 )
DeleteObject( hBmpFoot )
ENDIF
ELSE
::aFoot := {rc[3],rc[2],rc[3],rc[4]}
ENDIF
IF ::lFoot
hOldFont := SelectObject( hDC, ::oFontPie:hFont )
IF ::nClrTextFoot != Nil
nClrText := SetTextColor( hDC, ::nClrTextFoot )
ENDIF
nMode := SetBkMode( hDC, 1 )
DrawText( hDC, ::cFoot, {::aFoot[1],::aFoot[2]+ 10+nWFoot,::aFoot[3],::aFoot[4]},nOr( DT_VCENTER, DT_SINGLELINE, 8192 ) )
SetBkMode( hDC, nMode )
IF ::nClrTextFoot != Nil
SetTextColor( hDC, nClrText )
ENDIF
SelectObject( hDC, hOldFont )
ENDIF
Line( hDC, ::aFoot[1] , ::aFoot[2]+5, ::aFoot[1] , ::aFoot[4]-5, ::nClrSepara1 )
Line( hDC, ::aFoot[1]+1, ::aFoot[2]+5, ::aFoot[1]+1, ::aFoot[4]-5, ::nClrSepara2 )
RETURN 0
*********************************************************************************************
METHOD Hide() CLASS TC5Tooltip
*********************************************************************************************
RETURN super:Hide()
#define WS_EX_LAYERED 524288
#define GWL_EXSTYLE -20
#define LWA_ALPHA 2
*********************************************************************************************
METHOD Show() CLASS TC5Tooltip
*********************************************************************************************
RETURN super:Show()
/*
////////////////////////////////////////////////////////////////////
function LoadImageEx2( cImage, hBmp )
////////////////////////////////////////////////////////////////////
local lIcon := .f.
hBmp := LoadImageEx( cImage )
if hBmp == 0
hBmp := LoadIcon( GetResources(), cImage )
if hBmp == 0
hBmp := ExtractIcon( cImage )
lIcon := hBmp != 0
else
lIcon := .t.
endif
endif
return lIcon
*/
/***************************************************************************************************************************/
FUNCTION Line( hDC, nTop, nLeft, nBottom, nRight, nColor, nGrueso )
/***************************************************************************************************************************/
LOCAL hPen, hOldPen
DEFAULT nGrueso := 1
DEFAULT nColor := CLR_BLACK
hPen := CreatePen( PS_SOLID, nGrueso, nColor )
hOldPen := SelectObject( hDC, hPen )
MoveTo( hDC, nLeft, nTop )
LineTo( hDC, nRight, nTop )
SelectObject( hDC, hOldPen )
DeleteObject( hPen )
RETURN 0
#pragma BEGINDUMP
#include "windows.h"
#include "hbapi.h"
//lngUser32 = LoadLibrary("User32.dll")
//lngSetLayeredWindowAttributes = GetProcAddress(lngUser32, "SetLayeredWindowAttributes")
//If lngSetLayeredWindowAttributes <> 0 Then
//' Set window translucency, if supported
//lngOldStyle = GetWindowLong(hDlg, %GWL_EXSTYLE)
//SetWindowLong hDlg, %GWL_EXSTYLE, lngOldStyle Or %WS_EX_LAYERED
//Call DWord lngSetLayeredWindowAttributes Using SetLayeredWindowAttributes(hDlg, 0, %TRANSLEVEL, %LWA_ALPHA)
//End If
typedef BOOL ( FAR PASCAL *LPSETLAYEREDWINDOWATTRIBUTES) ( HWND hWnd, COLORREF crKey, BYTE bAlpha, DWORD dwFlags );
HB_FUNC( SETLAYEREDWINDOWATTRIBUTES )
{
HINSTANCE hLib;
LPSETLAYEREDWINDOWATTRIBUTES SetLayeredWindowAttributes;
hLib = LoadLibrary( "user32.dll" );
IF ( hLib )
{
SetLayeredWindowAttributes = (LPSETLAYEREDWINDOWATTRIBUTES) GetProcAddress( hLib, "SetLayeredWindowAttributes" );
IF( SetLayeredWindowAttributes )
{
SetLayeredWindowAttributes( ( HWND ) hb_parnl( 1 ),
( COLORREF ) hb_parnl( 2 ),
( BYTE ) hb_parni ( 3 ),
( DWORD ) hb_parnl( 4 ) );
}
FreeLibrary( hLib );
}
hb_ret();
}
/*
HB_FUNC( CREATERECTRGN )
{
hb_retnl( (long) CreateRectRgn( hb_parni( 1 ),hb_parni( 2 ),hb_parni( 3 ),hb_parni( 4 )));
}
*/
/*
HB_FUNC( CREATEROUNDRECTRGN )
{
hb_retnl( (long) CreateRoundRectRgn( hb_parni( 1 ),hb_parni( 2 ),hb_parni( 3 ),hb_parni( 4 ),hb_parni( 5 ),hb_parni( 6 )));
}
HB_FUNC( CREATEELLIPTICRGN )
{
hb_retnl( (long) CreateEllipticRgn( hb_parni( 1 ),hb_parni( 2 ),hb_parni( 3 ),hb_parni( 4 )));
}
HB_FUNC( COMBINERGN )
{
HRGN hrgn = CreateRectRgn(0,0,0,0);
HRGN hrgn1 = (HRGN) hb_parnl( 1 );
HRGN hrgn2 = (HRGN) hb_parnl( 2 );
int iRet;
iRet = CombineRgn( hrgn, // handle to destination region
hrgn1, // handle to source region
hrgn2, // handle to source region
hb_parni( 3 ) // region combining mode
);
hb_retni( (long)hrgn );
}
*/
/*
HB_FUNC( SETWINDOWRGN )
{
hb_retni( SetWindowRgn( (HWND) hb_parnl( 1 ),(HRGN) hb_parnl( 2 ), hb_parl( 3 ) ));
}
*/
HB_FUNC( FRAMERGN )
{
hb_retl( FrameRgn( (HDC) hb_parnl( 1 ), (HRGN) hb_parnl( 2 ), (HBRUSH) hb_parnl( 3 ), hb_parni( 4 ), hb_parni( 5 )));
}
BOOL Array2Point(PHB_ITEM aPoint, POINT *pt )
{
IF (HB_IS_ARRAY(aPoint) && hb_arrayLen(aPoint) == 2) {
pt->x = hb_arrayGetNL(aPoint,1);
pt->y = hb_arrayGetNL(aPoint,2);
RETURN TRUE ;
}
RETURN FALSE;
}
HB_FUNC( CREATEPOLYGONRGN )
{
POINT * Point ;
POINT pt ;
INT iCount ;
INT i ;
PHB_ITEM aParam ;
PHB_ITEM aSub ;
IF ( hb_param( 1, HB_IT_ARRAY ) != NULL )
{
iCount = (INT) hb_parinfa( 1, 0 ) ;
Point = (POINT *) hb_xgrab( iCount * sizeof (POINT) ) ;
aParam = hb_param(1,HB_IT_ARRAY);
FOR ( i = 0 ; i<iCount ; i++ )
{
aSub = ( PHB_ITEM ) hb_itemArrayGet( aParam, i+1 );
IF ( Array2Point(aSub, &pt ))
*(Point+i) = pt ;
ELSE {
hb_retnl(0);
hb_xfree(Point);
RETURN ;
}
}
hb_retnl( (LONG) CreatePolygonRgn( Point, iCount, hb_parni( 2 ) ) ) ;
hb_xfree(Point);
}
ELSE
hb_retnl( 0 );
}
HB_FUNC( GETDLGCTRLID )
{
hb_retni( GetDlgCtrlID( ( HWND ) hb_parnl( 1 ) ) );
}
#pragma ENDDUMP
Soluciones y Diseño de Software
Damos Soluciones...
I.S.C. Victor Daniel Cuatecatl Leon
Director y Diseñador de Proyectos
http://www.soldisoft.unlugar.com
http://www.sisa.unlugar.com
danyleon82@hotmail.com
www.facebook.com/victordaniel.cuatecatlleon
Damos Soluciones...
I.S.C. Victor Daniel Cuatecatl Leon
Director y Diseñador de Proyectos
http://www.soldisoft.unlugar.com
http://www.sisa.unlugar.com
danyleon82@hotmail.com
www.facebook.com/victordaniel.cuatecatlleon
- Antonio Linares
- Site Admin
- Posts: 42521
- Joined: Thu Oct 06, 2005 5:47 pm
- Location: Spain
- Has thanked: 31 times
- Been thanked: 76 times
- Contact:
Re: ejemplo c5Tooltip
Viktor,
Estos IF tienen que estar en minusculas:
IF ( hLib )
No pierdas tu tiempo en pelearte con esto, deja que nosotros lo solucionemos y luego los usaras comodamente
Estos IF tienen que estar en minusculas:
IF ( hLib )
No pierdas tu tiempo en pelearte con esto, deja que nosotros lo solucionemos y luego los usaras comodamente

- Silvio.Falconi
- Posts: 7136
- Joined: Thu Oct 18, 2012 7:17 pm
- Been thanked: 1 time
Re: ejemplo c5Tooltip
Antonio,
Perhaps I found the modify to show it for any seconds
ADD THESE DATA
DATA oTimer, nTimer
AND CHANGE THE PAINT METHOD
THEN TRY THIS TEST.PTH
nOW i SAW IT THERE WAS ON OLDEST VERSION C5TIP.PRG
Perhaps I found the modify to show it for any seconds
ADD THESE DATA
DATA oTimer, nTimer
AND CHANGE THE PAINT METHOD
Code: Select all | Expand
METHOD Paint() CLASS TC5ToolTip
************************************************************************************************************************
local hDCMem := CreateCompatibleDC ( ::hDC )
local rc := GetClientRect ( ::hWnd )
local hBmpMem := CreateCompatibleBitmap( ::hDC, rc[4]-rc[2], rc[3]-rc[1] )
local hOldBmp := SelectObject ( hDCMem, hBmpMem )
local nWRadio := ::nWRadio
local nHRadio := ::nHRadio
local nClrText := SetTextColor( hDCMem, ::nClrText )
local hBrush
local hRgn := CreateRoundRectRgn( rc[2] ,rc[1], rc[4], rc[3] , ::nWRadio, ::nHRadio )
Local oThis := self
rc[3]--; rc[4]--
nWRadio += 2
nHRadio += 2
IF ::oTimer != nil
::oTimer:Deactivate()
endif
DEFINE TIMER ::oTimer INTERVAL ::nTimer ACTION oThis:Hide() OF Self
ACTIVATE TIMER ::oTimer
VerticalGradient( hDCMem, {rc[1]-1,rc[2],rc[3],rc[4]}, ::nClrPane, ::nClrPane2 )
if ::bOwnerDraw == nil
::PaintHdr ( hDCMem, rc ) // ::PaintHdr2( hDCMem, rc )
::PaintFoot( hDCMem, rc )
::PaintBody( hDCMem, rc )
else
eval( ::bOwnerDraw, hDCMem )
endif
hBrush := CreateSolidBrush( ::nClrBorder )
FrameRgn( hDCMem, hRgn, hBrush, 1, 1 )
DeleteObject( hBrush )
DeleteObject( hRgn )
SetTextColor( hDCMem, nClrText )
BitBlt( ::hDC, 0, 0, rc[4]-rc[2], rc[3]-rc[1], hDCMem, 0, 0, SRCCOPY )
SelectObject( hDCMem, hOldBmp )
DeleteDC ( hDCMem )
DeleteObject( hBmpMem )
return 0
THEN TRY THIS TEST.PTH
Code: Select all | Expand
#include "FiveWin.ch"
function Main()
local oWnd, oTT
DEFINE WINDOW oWnd
oTT = TC5Tooltip():New( 100, 100, 450, 350, oWnd, .T., CLR_CYAN, CLR_WHITE,15,15 )
oTT:cHeader = "header"
oTT:cHeader2 = "header2"
oTT:cBody = "this is the body of the tooltip" + CRLF + "It looks nice"
oTT:cFoot = "this is the footer"
oTT:cBmpFoot :=".\bitmaps\help2.bmp"
oTT:cBmpLeft :=".\bitmaps\brush.bmp"
* oTT:lRightAlignBody:=.t.
oTT:lLineHeader :=.t. //not run
oTT:lBtnClose :=.t. //not run
oTT:lSplitHdr:=.t. //not run
oTT:lBorder :=.f.
oTT:nTimer:= 2000
ACTIVATE WINDOW oWnd
return nil
nOW i SAW IT THERE WAS ON OLDEST VERSION C5TIP.PRG
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)
I use : FiveWin for Harbour November 2023 - January 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
I use : FiveWin for Harbour November 2023 - January 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com