Data-driven tooltips with Sub-Classing

This forum is for posting of useful information
Post Reply
Message
Author
User avatar
rdonnay
Site Admin
Posts: 4266
Joined: Wed Jan 27, 2010 6:58 pm
Location: Boise, Idaho USA
Contact:

Data-driven tooltips with Sub-Classing

#1 Post 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
Attachments
tooltip.zip
(1.6 KiB) Downloaded 633 times
The eXpress train is coming - and it has more cars.

Post Reply