Link to home
Start Free TrialLog in
Avatar of nsivatg
nsivatg

asked on

Superscript in RichEdit control?

Hi,

I am using a Rich Edit control in a dialog box and I need set the TM text as Superscript.

Even though I am using the following command, it doesn't give me the solution.

richAttributes.cbSize = sizeof(richAttributes);
richAttributes.dwMask = CFM_SUPERSCRIPT ;
richAttributes.dwEffects = CFE_SUPERSCRIPT ;

SendMessage(hrichEditWnd,
EM_SETCHARFORMAT ,
(WPARAM) SCF_SELECTION ,
(LPARAM) (CHARFORMAT FAR *) &richAttributes);


Any ideas please.

Thanks

Shiva

Avatar of nsivatg
nsivatg

ASKER

I have done the selection using EM_SETSEL before using EM_SETCHARFORMAT.
RichEdit 1.0 doesn't support superscript. Are you creating a 1.0 control, or a 2.0 (or newer) control?

..B ekiM
Avatar of nsivatg

ASKER

Hi Mike,

  I am using Richedit 2.0 only.

Shiva

Shiva@indusaglobal.com
Of what datatype is richAttributes?

..B ekiM
Avatar of nsivatg

ASKER

Hi Mike,

 CHARFORMAT2

Shiva

Shiva@indusaglobal.com

What's in yOffset?

..B ekiM
Are you trying to set the format at the whole text , or just in the text after the insertion point ?

Btw if the same code works for u with CFM_LINK tell me to ask a question -)

Avatar of nsivatg

ASKER

>What's in yOffset?

It is 20.

>Are you trying to set the format at the whole text , or just in the text after the insertion point

I am selecting 2 characters using EM_SETSEL

Note:

  I tried Bold for testing purposes. Even that doesn't work.
Any clues.

Shiva

Shiva@indusaglobal.com
Avatar of nsivatg

ASKER

I solved it using CHARFORMAT instead of CHARFORMAT2. But can some one let me know why it failed with CHARFORMAT2.

Thanks

Shiva

Shiva@indusaglobal.com
Maybe you are passing wrong size , OR you dont use RichEdit 2.0 .

For me , the CHARFORMAT2 works . How do you initialize the 2.0 control ?
Avatar of nsivatg

ASKER


>you dont use RichEdit 2.0
LoadLibrary("riched32.dll"); Am I using RichEdit 2.0?

>How do you initialize the 2.0 control ?
How do I do it?
After loading the library, then the RichEdit works for me because I have the control inside a dialog box. I simply activate the Dialog box.

>the CHARFORMAT2 works
I do the following.

CHARFORMAT2 richAttr;
richAttr.cbSize = sizeof(CHARFORMAT2);
richAttr.dwMask = CFM_OFFSET | CFM_SUPERSCRIPT;
ichAttributes.dwEffects = CFE_SUPERSCRIPT ;
richAttr.yOffset = OFFSETVALUE;

But if I change to CHARFORMAT, then it works.

Any solutions please.

Shiva

Shiva@indusaglobal.com

            
ASKER CERTIFIED SOLUTION
Avatar of mikeblas
mikeblas

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
By the way, are you doing this instead of drawing the text manually, like I suggested you do in that other question?

..B ekiM
No
LoadLibrary("RICHED20.DLL") loads the RIchEdit 2.0 , not RICHED32.DLL .

wfw> No.  LoadLibrary("RICHED20.DLL") loads
 wfw> the RIchEdit 2.0 , not RICHED32.DLL .

Right.  But how do we know other code in this app isn't loading RICHED20.DLL?  The class name used in the dialog template (or in CreateWindow()) answers the question beyond a shadow of a doubt.

..B ekiM
 
Correct , RICHEDIT_CLASS is the RichEdit 2.0 class name .
Avatar of nsivatg

ASKER

I use SDK programming without using any MFC code.

I have rich edit control on the  Dialog box. The rich edit contorl is not generated at run time.

Shiva

Shiva@indusaglobal.com
In that case , you may use the RichEdit20A or RichEdit20W ( unicode version ) class .

BTW I never used MFC or any other environement as well - prefer straight API .
> I have rich edit control on the  Dialog box.

Uhuh.  And what class name have you placed on the dialog resource?

..B ekiM
Avatar of nsivatg

ASKER

I am directory placing the rich edit control from the tools window.

The dialog box is a part of the property sheet.

Did I answer?


Shiva

Shiva@indusaglobal.com
Better check the RC file and tell us the class name used .

example :

 CONTROL "test", 117, "edit", ES_LEFT | ES_AUTOHSCROLL | WS_CHILD | WS_VISIBLE | WS_BORDER | WS_TABSTOP, 177, 194, 56, 12


"edit" is the class name .
Avatar of nsivatg

ASKER

Ok, now I understood.

The RC file has the following.

CONTROL "Test",IDC_RICH_MSG,"RICHEDIT",ES_MULTILINE |
 ES_READONLY | ES_WANTRETURN | WS_DISABLED | ES_BORDER, 15, 42,209,87,WS_EX_DLGMODALFRAME | WS_EX_CLIENTEDGE | WS_EX_STATICEDGE

Regards and Thanks for your interest.

Shiva

Shiva@indusaglobal.com
Then you're using RichEdit 1.0, and that's why using the 2.0 version of the structure failed.

..B ekiM
Avatar of nsivatg

ASKER

Am I supposed to use RICHEDIT20A in place of RichEdit?

Regards

Shiva

Shiva@indusaglobal.com
Yes .
> Am I supposed to use RICHEDIT20A in place of RichEdit?

No.  You should use RICHEDIT_CLASS in place of "RichEdit".

..B ekiM
I am not sure if RICHEDIT_CLASS will work on a resource script .
Resource scripts expand macros all over the place.  No problem.

The Resource Editor in VC++ 6.0 still doesn't know about the class, no matter how you spell it. So, the control will appear as a "Custom control" in the editor.

You'll need to make sure the resource header has the Richedit headers, so you'll want to use the "Resource Includes" command in the "View" menu to add an #include "richedit.h" directive _after_ the directive to include afxres.h.

But, the resource compiler has always been able to expand preprocessor symbols.

..B ekiM