Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to change fonts from within a report at run-time

Status
Not open for further replies.

markftwain

Technical User
Jul 12, 2006
108
Hi

I have a standard visual foxpro 9 report printing a memo field that contains something like: "See the fox run."

I would like to have "fox" print differently then the rest of the line. i.e., say the actual line is: "See the +fox run." The "+" should cause "fox" to be all capital, or bold, or italic, etc. The "+" would not be seen (or extracted) and "run" returns to the same font as "See the"

Any suggestions on how to do this?

Thank You
 
Let me get this right. You'll set the string up as "See the +fox run" in the report designer. But when the report runs, the user will see "See the fox run" or something similar. Is that right?

I have to say I can't see the point. Presumably, you've got to go into the report designer anyway to edit the label so as to include or exclude the "+". At that point, why not edit the label to show the bold substring? It's not as if you are giving the user any control over the presence of the "+" at run time?

If you want to know how to make just one element of a label bold (one word, in this case), the answer is to split it into three separate labels, and apply the bold formatting to the middle one (in this example).

If I've misunderstood exactly what you are trying to achieve, perhaps you could clarify your goal.

Mike



__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro tips, advice, training, consultancy
Custom software for your business
 
I would like the report .frx to be an entirely seperate unit from the strings being displayed. The report form itself does not know if there will be a bold display or not, nor does the report form know ahead of time which if any of the words are to be in a different font. The report form knows only that it is to display an arbitrary string at a given starting position on the page. That is the string itself is taken as one object.

Example:
"See the fox run."-->displayed as "See the fox run."
"See +the fox run."--> " " "See bold-the fox run."
"See the +fox run."--> " " "See the bold-fox run."

Are there non-visible control-codes that can be embedded in the string to change the display of just the chosen words? (or should the report listener be invoked?)

Mark

 
Mark,

Oh, I see. The string containg the + is an expression, not a label. Sorry, I didn't realise that.

In that case, you can't do it with native VFP report controls, but there are probably ActiveX controls that can do it for you. You might try the rich-text control that comes with VFP. Failing that, search for a third-party control -- one that can render, say, HTML as rich text.

If you use the rich-text control, you would need to insert the appropriate tags into the string being displayed. You'd need to pick up the string containing the +, and convert that to a string containing whatever tag the control uses to indicate bold. That should be quite simple, given that you are dealing in plain character strings.

Perhaps someone else can suggest a suitable control?

Mike


__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro tips, advice, training, consultancy
Custom software for your business
 
Mike,

For lack of time, I took this approach. Within the fox code that generates the memo fields, put delimiters arround the phrases within the expressions that need highlighting. Process the report with the reportlistener to HTML. A very simple strtran() procedure then replaces the appropriate HTML flags and the delimters with the correct HTML flags. Lastly, do a shell execute of the file calling IE for display and print.

I wish VFP could atomize the parts of a report expression directly, and not just the entire report object.

Mark
 
Mark,

That sounds like a good solution.

Unfortunately, VFP reports have always treated the entire expression as a single entity for the purposes of formatting and styles, but using a report listener with HTML does at least enable a workaround.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro tips, advice, training, consultancy
Custom software for your business
 
I suspect you can do what you want with a custom report listener.
 
Yes, build a custom ReportListener class based on the ReportListener class provided with VFP. Then you can add code to trigger alomst any behaviors you need.

The standard objects available in the report form editor are rather basic, only one font, size, format, etc. ReportListener allows extensive flexibility, though it may be difficult to figure out all the permutations.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top