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

nsivatgAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

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

..B ekiM
0
nsivatgAuthor Commented:
Hi Mike,

  I am using Richedit 2.0 only.

Shiva

Shiva@indusaglobal.com
0
Cloud Class® Course: CompTIA Cloud+

The CompTIA Cloud+ Basic training course will teach you about cloud concepts and models, data storage, networking, and network infrastructure.

mikeblasCommented:
Of what datatype is richAttributes?

..B ekiM
0
nsivatgAuthor Commented:
Hi Mike,

 CHARFORMAT2

Shiva

Shiva@indusaglobal.com

0
mikeblasCommented:
What's in yOffset?

..B ekiM
0
WxWCommented:
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 -)

0
nsivatgAuthor Commented:
>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
0
nsivatgAuthor Commented:
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
0
WxWCommented:
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 ?
0
nsivatgAuthor Commented:

>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

            
0
mikeblasCommented:
> Am I using RichEdit 2.0?

No way to tell just from that.  What class name are you creating with the control?

If you're using "RICHEDIT", it's 1.0.  If you're using "RICHEDIT20A", or "RICHEDIT20W", you're using 2.0.

If you send the CHARFORMAT2 struct to the 1.0 control, it ignores the message. (Checking the return value of SendMessage() will let you know about that.)

..B ekiM
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
mikeblasCommented:
By the way, are you doing this instead of drawing the text manually, like I suggested you do in that other question?

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

0
mikeblasCommented:
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
 
0
WxWCommented:
Correct , RICHEDIT_CLASS is the RichEdit 2.0 class name .
0
nsivatgAuthor Commented:
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
0
WxWCommented:
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 .
0
mikeblasCommented:
> I have rich edit control on the  Dialog box.

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

..B ekiM
0
nsivatgAuthor Commented:
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
0
WxWCommented:
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 .
0
nsivatgAuthor Commented:
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
0
mikeblasCommented:
Then you're using RichEdit 1.0, and that's why using the 2.0 version of the structure failed.

..B ekiM
0
nsivatgAuthor Commented:
Am I supposed to use RICHEDIT20A in place of RichEdit?

Regards

Shiva

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

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

..B ekiM
0
WxWCommented:
I am not sure if RICHEDIT_CLASS will work on a resource script .
0
mikeblasCommented:
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
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Development

From novice to tech pro — start learning today.