What happened to the Messenger Plus! forums on msghelp.net?
Shoutbox » MsgHelp Archive » Messenger Plus! for Live Messenger » Scripting » RichEdit: Formatting Text using SendMessage from the Windows' APIs

RichEdit: Formatting Text using SendMessage from the Windows' APIs
Author: Message:
whiles
New Member
*


Posts: 6
33 / Male / –
Joined: Aug 2006
O.P. Huh?  RichEdit: Formatting Text using SendMessage from the Windows' APIs
Hi everyone,

i'm writing a script that use a RichEdit and i must make it like an rtf-text editor, wherein the user can color the selected text, change the background, make the selected text bold, italic, underlined, striked.... but i don't found any method that makes this.

In the irc channel support dt suggested me to use windows APIs and the SendMessage method, and he made me a script that i've adapted. The script is this: http://pastebin.com/775531.

The XML Form is this: http://pastebin.com/775537 .


The problem is that: the debugger reports no errors, but the RichEdit looks like... not rich. In fact if i paste a RTF text to the richEdit, the text appears plain and not RTF. There's a problem with the form, or with the script???

Thank you very much.

This post was edited on 08-25-2006 at 06:14 PM by whiles.
08-25-2006 09:55 AM
Profile E-Mail PM Find Quote Report
RaceProUK
Elite Member
*****

Avatar

Posts: 6073
Reputation: 57
39 / Male / Flag
Joined: Oct 2003
RE: RichEdit looks like... not rich
It sounds to me like the RichEdit is being replaced with a standard textbox, or somehow the RichEdit part is being turned off. Doible-check all the changes you made, make sure you haven't screwed anything up.
[Image: spartaafk.png]
08-25-2006 10:25 AM
Profile PM Web Find Quote Report
Dempsey
Scripting Contest Winner
*****

Avatar
http://AdamDempsey.net

Posts: 2395
Reputation: 53
38 / Male / Flag
Joined: Jul 2003
RE: RichEdit looks like... not rich
Looked like someone else had a similar problem:   Rich Edit Control
SoundPacks   -   Scripts   -   Skins

that's not a bug, thats an unexpected feature
08-25-2006 10:31 AM
Profile E-Mail PM Web Find Quote Report
Eljay
Elite Member
*****

Avatar
:O

Posts: 2949
Reputation: 77
– / Male / –
Joined: May 2004
RE: RichEdit looks like... not rich
inside the rich control <Attributes> tag add the following:
code:
<TextMode>Rich Text</TextMode>
08-25-2006 11:12 AM
Profile PM Find Quote Report
whiles
New Member
*


Posts: 6
33 / Male / –
Joined: Aug 2006
O.P. RE: RichEdit looks like... not rich
I've tried to simplify the function but it still doesn't work; the richedit is rich, but the message make nothing! : http://pastebin.com/775737 .

It don't make errors, the text don't became bold and the function return  0 always

Help! :'(

This post was edited on 08-26-2006 at 08:33 AM by whiles.
08-25-2006 04:17 PM
Profile E-Mail PM Find Quote Report
whiles
New Member
*


Posts: 6
33 / Male / –
Joined: Aug 2006
O.P. RichEdit: Formatting Text using SendMessage from the Windows' APIs
can somebody help me please? :(

This post was edited on 08-26-2006 at 03:05 PM by whiles.
08-26-2006 08:34 AM
Profile E-Mail PM Find Quote Report
whiles
New Member
*


Posts: 6
33 / Male / –
Joined: Aug 2006
O.P. RichEdit: Formatting Text using SendMessage from the Windows' APIs
I re-explane the problem, if anybody don't understood it:

i have an RichEdit whose ID is rchNick in a window and i must change the format of the selected text to "Bold". Dt on the MsgPlus' IRC Channel suggest me to use the SendControlMessage, but i'm not very expert in Js than him made the code for me. The code is this:

code:
// The definition of the required windows api constants
      var EM_SETCHARFORMAT = 1092;
      var SCF_ALL = 4;
      var SCF_SELECTION = 1;
      var CFM_BOLD = 1;
      var CFE_BOLD = 1;
      var CFM_CHARSET = 0x8000000;
// I alloc the required structure and assign it the values, the structure is descripted here
      var charFormat = Interop.Allocate(90);
      charFormat.WriteDWORD(0, charFormat.Size); //cbSize
      charFormat.WriteDWORD(4, CFM_BOLD); //dwMask
      charFormat.WriteDWORD(8, CFE_BOLD); //dwEffects
//I send the message to the richEdit called "RchNick", the message SETCHARFORMAT is descripted here.
//The function DataPtr return a pointer to the structure charFormat.
//The function return a not-zero value if success.
      var ret = Wnd.SendControlMessage("RchNick", EM_SETCHARFORMAT, SCF_SELECTION, charFormat.DataPtr);
      Debug.Trace("Ret: " + ret);





The problem is: the function return 0 (error), but i can't define what is this error. The richEdit is rich because I fixed the previus problem (thanks to Eljay). I think is an error on the definition of the structure because i tried to send a message simplier than this and it works (than the function send the message)! I hope you can help me. Thanks.

This post was edited on 08-27-2006 at 08:51 PM by whiles.
08-27-2006 08:50 PM
Profile E-Mail PM Find Quote Report
matty
Scripting Guru
*****


Posts: 8336
Reputation: 109
39 / Male / Flag
Joined: Dec 2002
Status: Away
RE: RichEdit: Formatting Text using SendMessage from the Windows' APIs
If you want to zip up the entire project and post it here I will take a look at it for ya.
08-27-2006 09:03 PM
Profile E-Mail PM Find Quote Report
whiles
New Member
*


Posts: 6
33 / Male / –
Joined: Aug 2006
O.P. RE: RE: RichEdit: Formatting Text using SendMessage from the Windows' APIs
quote:
Originally posted by Matty
If you want to zip up the entire project and post it here I will take a look at it for ya.


Yes,  i've attached it. I've arrange the script with comments and the MSDN documentation to render the script more readable.


Thanks.

.plsc File Attachment: RichEdit.plsc (1.69 KB)
This file has been downloaded 157 time(s).
08-28-2006 07:08 AM
Profile E-Mail PM Find Quote Report
« Next Oldest Return to Top Next Newest »


Threaded Mode | Linear Mode
View a Printable Version
Send this Thread to a Friend
Subscribe | Add to Favorites
Rate This Thread:

Forum Jump:

Forum Rules:
You cannot post new threads
You cannot post replies
You cannot post attachments
You can edit your posts
HTML is Off
myCode is On
Smilies are On
[img] Code is On