91
EZGUI 5 support forum / Re: test posts
« Last post by Chris Boss on January 11, 2022, 03:45:04 pm »Here is an include file which has a library of routines that makes working with tooltips easy.
ezttip.inc
ezttip.inc
Code: [Select]
&' Note: You define the following function in your main apps code:
DECLARE FUNCTION DefineToolTipText(BYVAL hDlg&, BYVAL IDNum&) AS STRING
&' *************************************************************
&' EZGUI Freeware ToolTip Library !!!
&' -------------------------------------------------------------
&' Copyright 2005, Christopher R. Boss, All Rights Reserved !
&' This source code is offered as freeware. You may use it
&' Royalty free, but you must maintain this copyright notice
&' with the code. No warranty made !
&' Provided by Computer Workshop.
&' http://ezgui.com , also http://cwsof.com
&' *************************************************************
GLOBAL g_ToolTipText AS ASCIIZ*1024
&'
FUNCTION CreateDlgToolTip(BYVAL hDlg&, BYVAL MaxWidth&, BYVAL TextColor&, BYVAL BGColor&) AS LONG
LOCAL WS&, EWS&, CName AS ASCIIZ*32, hCtrl&
WS&=%WS_POPUP OR %TTS_ALWAYSTIP OR %TTS_BALLOON
EWS&=%WS_EX_TOOLWINDOW
CName=$TOOLTIPS_CLASS
hCtrl&=CreateWindowEx(EWS&, CName,"", WS&,0,0,32,32,hDlg&,0,GetModuleHandle(BYVAL %NULL), BYVAL %NULL)
SendMessage hCtrl&, %TTM_SETMAXTIPWIDTH, 0, MaxWidth&
SendMessage hCtrl&, %TTM_SETTIPTEXTCOLOR,TextColor&,0
SendMessage hCtrl&, %TTM_SETTIPBKCOLOR, BGColor&,0
FUNCTION=hCtrl&
END FUNCTION
&'
SUB AddTool(BYVAL hToolTip&, BYVAL hDlg&, BYVAL IDNum&)
LOCAL TT AS TOOLINFO, hCtrl&, RV&
CONTROL HANDLE hDlg&, IDNum& TO hCtrl&
IF hCtrl&<>0 THEN
TT.cbSize=SIZEOF(TT)
TT.uFlags=%TTF_IDISHWND OR %TTF_SUBCLASS
TT.hwnd=hDlg&
TT.uId=hCtrl&
&' TT.rec=
TT.hinst=GetModuleHandle(BYVAL %NULL)
TT.lpszText=%LPSTR_TEXTCALLBACK
TT.lParam=0
RV&=SendMessage(hToolTip&, %TTM_ADDTOOL,0, VARPTR(TT))
END IF
END SUB
&'
FUNCTION GetClassType(BYVAL hCtrl&) AS STRING
LOCAL zC AS ASCIIZ*33, X&
X&=GetClassName(hCtrl&, zC,32)
FUNCTION=zC
END FUNCTION
&'
FUNCTION MKCRLF(BYVAL T$) AS STRING
REPLACE "|" WITH CHR$(13)+CHR$(10) IN T$
FUNCTION=T$
END FUNCTION
&'
FUNCTION TestForToolTip(BYVAL hDlg&, BYVAL Msg&, BYVAL wParam&, BYVAL lParam&) AS LONG
LOCAL RV&, pNM AS NMHDR PTR, pTT AS NMTTDISPINFO PTR
LOCAL hCtrl&, hTipTool&, IDNum&
RV&=0
IF Msg&=%WM_NOTIFY THEN
pNM=lParam&
hCtrl&=@pNM.hwndFrom
hTipTool&=@pNM.idfrom
IF GetClassType(hCtrl&)=$TOOLTIPS_CLASS THEN
IF @pNM.code=%TTN_NEEDTEXT THEN
pTT=lParam&
IDNum&=GetDlgCtrlID(hTipTool&)
&' this method is limited to 80 characters
&' @pTT.szText=left$(DefineToolTipText(hDlg&, IDNum&),79)
&' this method is limited to size of my global variable !
g_ToolTipText=MKCRLF(DefineToolTipText(hDlg&, IDNum&))
@pTT.lpszText=VARPTR(g_ToolTipText)
RV&=1
END IF
END IF
END IF
END FUNCTION
&' *************************************************************
&' End ToolTip Library
&' *************************************************************
&'