Shoutbox

RichEdit: Formatting Text using SendMessage from the Windows' APIs - Printable Version

-Shoutbox (https://shoutbox.menthix.net)
+-- Forum: MsgHelp Archive (/forumdisplay.php?fid=58)
+--- Forum: Messenger Plus! for Live Messenger (/forumdisplay.php?fid=4)
+---- Forum: Scripting (/forumdisplay.php?fid=39)
+----- Thread: RichEdit: Formatting Text using SendMessage from the Windows' APIs (/showthread.php?tid=65363)

RichEdit: Formatting Text using SendMessage from the Windows' APIs by whiles on 08-25-2006 at 09:55 AM

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.


RE: RichEdit looks like... not rich by RaceProUK on 08-25-2006 at 10:25 AM

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.


RE: RichEdit looks like... not rich by Dempsey on 08-25-2006 at 10:31 AM

Looked like someone else had a similar problem:   Rich Edit Control


RE: RichEdit looks like... not rich by Eljay on 08-25-2006 at 11:12 AM

inside the rich control <Attributes> tag add the following:

code:
<TextMode>Rich Text</TextMode>

RE: RichEdit looks like... not rich by whiles on 08-25-2006 at 04:17 PM

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! :'(


RichEdit: Formatting Text using SendMessage from the Windows' APIs by whiles on 08-26-2006 at 08:34 AM

can somebody help me please? :(


RichEdit: Formatting Text using SendMessage from the Windows' APIs by whiles on 08-27-2006 at 08:50 PM

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.
RE: RichEdit: Formatting Text using SendMessage from the Windows' APIs by matty on 08-27-2006 at 09:03 PM

If you want to zip up the entire project and post it here I will take a look at it for ya.


RE: RE: RichEdit: Formatting Text using SendMessage from the Windows' APIs by whiles on 08-28-2006 at 07:08 AM

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.