What happened to the Messenger Plus! forums on msghelp.net?
Shoutbox » MsgHelp Archive » Messenger Plus! for Live Messenger » Scripting » [Ask]RichEdit Control and Syntax Color

[Ask]RichEdit Control and Syntax Color
Author: Message:
Lén
Junior Member
**

Avatar

Posts: 16
34 / Male / Flag
Joined: Feb 2008
O.P. RE: [Ask]RichEdit Control and Syntax Color
oh yeah i finnaly understand ^^

but, how can search in the text my keyword ?
for exemple def:

code:
function OnWndScriptEnvEvent_EditTextChanged( pPlusWnd, sControlId ) {
    if ( sControlId === 'txtMessage' ) {
            sMessage = EnvWindow.GetControlText("txtMessage")       
             var hObjWnd = pPlusWnd.GetControlHandle (sControlId);
            for (i = 0; i < sMessage.length+1; i++){
            if(sMessage.charAt(i)=="d"){
                for (j = i+1; j < sMessage.length+1; j++){
                    if(sMessage.charAt(j)=="e"){
                        for (h = j+1; h < sMessage.length+1;h++){
                            if(sMessage.charAt(h)=="f"){
                                Interop.Call('user32', 'SendMessageW', hObjWnd, EM_SETSEL, i, h);
                                MyWindow.RichEdit_SetCharFormat("txtMessage",true,-1,-1,-1,-1,-1,0x00ff0000,"");

                            }
                        }
                    }
                }
            }
        }
    }
}

Have I to do that for every keyword :o ???

EDIT: How to Unselect my text after it has been replaced ?
EDIT: I found that and it work pretty good, but i still ask how can i unselect the texte after it has been colored ^^
code:
function OnWndScriptEnvEvent_EditTextChanged( pPlusWnd, sControlId ) {
    if ( sControlId === 'txtMessage' ) {
            sMessage = EnvWindow.GetControlText("txtMessage")       
        var hObjWnd = pPlusWnd.GetControlHandle (sControlId);
        i = sMessage.indexOf("def",0)
        if(sMessage.charAt(i+1)=="e" && sMessage.charAt(i+2)=="f"){
            Interop.Call('user32', 'SendMessageW', hObjWnd, EM_SETSEL, i,i+3);
            EnvWindow.RichEdit_SetCharFormat("txtMessage",true,-1,-1,-1,-1,-1,0x00ff0000,"");
            }
    }
}

EDIT: i've found it tu unselect:
code:
Interop.Call('user32', 'SendMessageW', hObjWnd, EM_SETSEL, -1,-1);

but i'm scared of how mani "loop for" i will use to do a global... 'cause this method juste replace the first "def" entry.

This post was edited on 08-11-2009 at 06:31 PM by Lén.
08-11-2009 05:52 PM
Profile PM Find Quote Report
« Next Oldest Return to Top Next Newest »

Messages In This Thread
[Ask]RichEdit Control and Syntax Color - by Lén on 08-09-2009 at 04:44 PM
RE: [Ask]RichEdit Control and Syntax Color - by matty on 08-10-2009 at 08:10 PM
RE: [Ask]RichEdit Control and Syntax Color - by Lén on 08-10-2009 at 08:24 PM
RE: [Ask]RichEdit Control and Syntax Color - by matty on 08-10-2009 at 08:27 PM
RE: [Ask]RichEdit Control and Syntax Color - by Lén on 08-10-2009 at 08:33 PM
RE: [Ask]RichEdit Control and Syntax Color - by matty on 08-11-2009 at 12:47 PM
[no subject] - by Lén on 08-11-2009 at 03:20 PM
RE: [Ask]RichEdit Control and Syntax Color - by matty on 08-11-2009 at 04:59 PM
RE: [Ask]RichEdit Control and Syntax Color - by Lén on 08-11-2009 at 05:52 PM
RE: [Ask]RichEdit Control and Syntax Color - by matty on 08-11-2009 at 06:37 PM
RE: [Ask]RichEdit Control and Syntax Color - by Lén on 08-11-2009 at 07:17 PM


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