Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
How to show brief tooltip-like error message
Message
From
12/03/2014 16:34:12
Dragan Nedeljkovich (Online)
Now officially retired
Zrenjanin, Serbia
 
 
To
11/03/2014 16:40:24
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Environment versions
Visual FoxPro:
VFP 9 SP2
OS:
Windows Server 2012
Network:
Windows 2008 Server
Database:
MS SQL Server
Application:
Web
Miscellaneous
Thread ID:
01596160
Message ID:
01596370
Views:
89
Likes (1)
>I want to show a brief tool-tip like message when user types an incorrect value. Message would disappear as soon as user starts retyping data. Any suggestions?

Have a form like this (and I got nudged in the right direction here on UT, so this is payback)
DEFINE CLASS ToolBrowseForm AS FORM

	ADD OBJECT HideTimer AS TIMER WITH	;
		ENABLED=.F., ;
		INTERVAL=200

	ALWAYSONTOP=.T.
	BORDERSTYLE=1
	CLOSABLE=.F.
	COLORSOURCE=0
	FONTNAME="FoxFont"
	FONTSIZE=9
	MAXBUTTON=.F.
	MINBUTTON=.F.
	sizebox=.F.
	TITLEBAR=0
	timeActivated ={ :}
	SHOWWINDOW=1			&& in top-level window
	DisplayFont 	= ''	&& change this
	DisplayFontSize	= 0		&& and this, as you see fit

*******************************
	PROCEDURE SETUP()
	DODEFAULT()
	DECLARE LONG GetSysColor IN User32 INTEGER
*-- 24 - tooltips background
	THIS.BACKCOLOR=GetSysColor(24)


*---------------------------------------------------
	PROCEDURE INIT()
*-- dn 2009/10/05
	THIS.SETUP()

*---------------------------------------------------
	PROCEDURE RELEASE()
*-- dn 2009/10/06
	RELEASE THIS

*******************************
	PROCEDURE DEACTIVATE
	THIS.HIDE()

*******************************
	PROCEDURE MOUSELEAVE
	LPARAMETERS nButton, nShift, nXCoord, nYCoord
	THIS.HIDE()

*******************************
	PROCEDURE COLLECT(tcParam)
	* display something ... custom code goes here.
	RETURN lRet
*---------------------------------------------------
	PROCEDURE SHOW(tnStyle)
	LOCAL lcSetNull
	tnStyle=EVL(tnStyle, 2)
	lcSetNull=SET("Nulldisplay")
	SET NULLDISPLAY TO "--"
	DODEFAULT(tnStyle)
	THIS.timeActivated =DATETIME()
	THIS.HideTimer.ENABLED=.T.
	SET NULLDISPLAY TO lcSetNull


*******************************
	PROCEDURE MoveNear(toNear, toFrm AS FORM)
* calculate position where to show it... YMMV
	lnTop=toFrm.TOP+OBJTOCLIENT(toNear,1)+toNear.HEIGHT/4+SYSMETRIC(4)+SYSMETRIC(9) + 12	
	lnLeft=toFrm.LEFT+OBJTOCLIENT(toNear,2) + MIN(toNear.WIDTH, toNear.PARENT.WIDTH) + 6 	
	WITH THIS AS FORM
		lnTop=MIN(lnTop, toFrm.HEIGHT-.HEIGHT-10)
		lnLeft=MIN(lnLeft, toFrm.WIDTH-.WIDTH-16)
		.MOVE(lnLeft, lnTop)
	ENDWITH
*---------------------------------------------------
	PROCEDURE HideTimer.TIMER()
*-- dn 2009/10/05
	LOCAL oOBject, llMouseIsOnMe

	llMouseIsOnMe=.F.

	DO CASE
		CASE DATETIME()-THISFORM.timeActivated <_DBLCLICK*2
			llMouseIsOnMe=.T.		&& five seconds delay before trying to hide
		CASE THISFORM.VISIBLE AND THISFORM.DOCKPOSITION = -1
			oOBject = SYS(1270)

			IF VARTYPE(oOBject) = "O"
*-- this form has no parent, so the topmost parent of any object on it is the form.
				DO WHILE TYPE("oObject.Parent.Name") = "C"
					oOBject = oOBject.PARENT
				ENDDO
				llMouseIsOnMe= oOBject = THISFORM
			ENDIF
	ENDCASE

	IF NOT llMouseIsOnMe
		THIS.ENABLED = .F.
		THISFORM.HIDE()
	ENDIF

ENDDEFINE
The calling code would look like this:
	LOCAL loTooltipForm
*[2009/10/07 09:28:07] ndragan - make sure to set proc to where the class is defined
	loTooltipForm=CREATEOBJECT("ToolBrowseForm")
	WITH loTooltipForm
		.LEFT=THIS.LEFT+THIS.WIDTH/2
		.TOP=THIS.TOP+THIS.HEIGHT-4
		IF .COLLECT("bla bla")
			.MoveNear(THIS, THISFORM)
			.SHOW(1)
		ENDIF
	ENDWITH
Now this code may go into tooltip_access, but you want to display it in a different manner (willy nilly, not on hover), so I guess this would go after your validation code.
If there are traces of other objects in this code (apart from the timer), ignore them. I have purged this of any specific code about what would be on this form, that's entirely up to you, but there may be some leftover bits.

back to same old

the first online autobiography, unfinished by design
What, me reckless? I'm full of recks!
Balkans, eh? Count them.
Previous
Reply
Map
View

Click here to load this message in the networking platform