Page 1 of 1

Data-driven tooltips with Sub-Classing

Posted: Thu May 24, 2012 9:14 am
by rdonnay

Code: Select all

/*
This sample shows how to use data-driven techniques
to display SAY prompts and BUTTON captions via Sub-Classing.

Tooltips are displayed in another thread.
This solution works even though it accesses a database.
*/

#INCLUDE "dcdialog.CH"

FUNCTION Main()

LOCAL GetList[0], bToolTip := {|o|o:toolTipText}

DC_LoadRdds()

@ 0,0 DCSAY {|o|GetText(1,o)} TOOLTIP bToolTip SAYSIZE 20 SUBCLASS 'SayText()'
@ 1,0 DCSAY {|o|GetText(2,o)} TOOLTIP bToolTip SAYSIZE 20 SUBCLASS 'SayText()'
@ 2,0 DCSAY {|o|GetText(3,o)} TOOLTIP bToolTip SAYSIZE 20 SUBCLASS 'SayText()'
@ 3,0 DCSAY {|o|GetText(4,o)} TOOLTIP bToolTip SAYSIZE 20 SUBCLASS 'SayText()'
@ 4,0 DCSAY {|o|GetText(5,o)} TOOLTIP bToolTip SAYSIZE 20 SUBCLASS 'SayText()'

@ 6,0 DCPUSHBUTTONXP CAPTION {|o|GetText(5,o)} TOOLTIP bToolTip SIZE 20,2 FONT '10.Arial Bold' ;
      SUBCLASS 'ButtonText()'

DCREAD GUI FIT SETAPPWINDOW

RETURN nil

* ----------

PROC appsys ; RETURN

* ----------

FUNCTION GetText( nWhich, oXbp )

LOCAL nFound, cText := '?????', aText, nSaveArea := Select()

DEFAULT nWhich := 0

IF Select('TEXT') == 0
  USE text NEW INDEX text VIA 'FOXCDX'
ENDIF

TEXT->(OrdSetFocus('NUMBER'))

IF TEXT->(dbSeek(nWhich))
  cText := Trim(TEXT->text)
  oXbp:toolTipText := Trim(TEXT->tooltip)
ELSE
  oXbp:toolTipText := '?????'
ENDIF

SELECT (nSaveArea)

RETURN cText

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

CLASS SayText FROM DC_XbpStatic

EXPORTED:

VAR toolTipText

ENDCLASS


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

CLASS ButtonText FROM DC_XbpPushButtonXP

EXPORTED:

VAR toolTipText

ENDCLASS