Re: getFontDialog

new topic     » goto parent     » topic index » view thread      » older message » newer message

Tom Irwin wrote:
> 
> I use w32Lib's getFontDialog  to change selected text in richedit controls.
> 
> However, endusers often want to change only one item of fontname, style, size,
> 
> or color and report finding it awkward to have to set all four each time the
> dialog 
> is called.  In fact they make mistakes by changing just what they want
> changed,
> 
> not realizing that they just reset the other attributes to default.   It works
> differently 
> for them than their other common Windows programs.
> 
> It would be extremely useful if the dialog could be made to show the font of
> the 
> original selected text (as in text editors like Wordpad).  
> 
> Can anyone help as to how this might be accomplished?

It can be done by copying the text of the getFontDialog() function and deriving
a variant from it. It initialises a structure for the font chooser to display its
initial values; the variant needs to set these values to those relevant to the
selection, while the original uses values relevant for the control as a whole.

To get these values, send the RichEdit control an EM_GETCHARFORMAT message with
wParam = SCF_SELECTION (which is 1), and lParam being the address of a valid
CHARFORMAT structure. This structure must be initialised so that, on return from
sendMessage(), the fields which you need initialised are indeed set up. Use
w32fetch() to retrieve the values to w32store() in the font chooser init
structure.

The newer win32lib can create the structure and get its address by calling
w32to_memory(ID_CHARFORMAT,{field values}). The field values will be as needed by
the needs of the clone of getFontDialog(). With older versions, there is a
struct_CHARFORMAT() function to do this - not sure it was documented -.

CChris

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu