Page 1 of 1

TEdit Control and Font

Posted: Fri Jan 11, 2008 7:21 am
by BernhardRoos
Hello,
what is the best way to set the Font property of a TEdit control each time if the TEdit is selected (perhaps there is some text selected and one or more TEdit controls at one time) in all selected TEdit controls. Is there an example to do this?

Best wishes
Bernhard

Posted: Sat Jan 12, 2008 11:09 am
by Sergey Tkachenko
You can use TRichViewEdit.OnSelect event. In this event, call GetSelectionBounds, enumerate all selected items and check if they contain TEdit.
As for other your questions, I need some time to answer them. I'll try to answer in

Posted: Tue Jan 22, 2008 7:54 am
by BernhardRoos
Sorry. It was a missunderstanding. I will try to explain my problem.

The user changes the font style, the font size, the font color or the font name of the selected items. Perhaps with the toolbar or with the menu Character.

Is there a way to react to such actions in one event. So I can use GetSelectionBounds for determing if there are controls selected.

OnSelect is not the right event.

Best wishes and thanks for your support
Bernhard

Posted: Tue Jan 22, 2008 9:18 am
by BernhardRoos
I've found a way. In RVAControlPanel there is a event OnStyleNeeded. This is exactly what I'm looking for.

Posted: Tue Jan 22, 2008 12:53 pm
by Sergey Tkachenko
This event occurs every time when some action needs a style with certain properties. This even may occurs when applying some change to the selection, or when inserting hyperlink.
If this event is not processed, the default procedure provides this style (creates a new style or returns the existing style with these properties).

This event rarely needs to be used (for example it can be used to prevent reusing of some styles, or to disallow some formatting)

Posted: Tue Jan 22, 2008 1:04 pm
by BernhardRoos
But seems the only way to set the font in controls. So far I've tested I can't see any problems with it.

Posted: Tue Jan 22, 2008 2:46 pm
by Sergey Tkachenko
For example, if the user selects large document fragment and applies font, this event occurs for each item in the selection. Which one you will use for TEdits?

It's possible to apply fonts to inserted controls, but it requires creating a special item type for them.