Solved

Richedit 2.0 and CFM_LINK

Posted on 1998-09-12
3
1,291 Views
Last Modified: 2013-12-26
I have a function AddText that adds text to a rich edit control . The function is supposed to catch messages starting with http:// or ftp:// or any other internet prefix , and apply the CFM_LINK to the string until a space is found . This is part of it : ( ttt contains the string to add  , and w[k]->p->rEdit and ccw[k]->p->rEdit are TRichEdit objects  )


for( unsigned int p = 0 ; p < strlen(ttt) ; )
      {
      /* FIRST of ALL : Test for EM_LINK */
      if (REC_LINKS)
            {
            if (!IsLinkingActive)
                  {
                  // Enable if next is a link string
                  if (strlen(ttt + p) < 10)
                        goto AfterLinking;
                        if (
                        (strncmpi(ttt + p,"http://",7) == 0) ||
                        (strncmpi(ttt + p,"www.",4) == 0) ||
                        (strncmpi(ttt + p,"telnet://",9) == 0) ||
                        (strncmpi(ttt + p,"ftp://",6) == 0) ||
                        (strncmpi(ttt + p,"mailto:",7) == 0))
                        {
                        w[k]->p->rEdit->ToggleCharAttribute(CFM_LINK, CFE_LINK);
                        }
                  IsLinkingActive = true;
                  }
            else // active linking
                  {
                  if ((unsigned char)ttt[p] == 0x20 )
                        {
                        w[k]->p->rEdit->ToggleCharAttribute(CFM_LINK, CFE_LINK);
                        IsLinkingActive = false;
                        }
                  }

            AfterLinking:


The problem is that the CFE_LINK is applied to the WHOLE line ! . That means,  if I have a line
" please go to http://www.com" , the CFM_LINK is applied to the whole string .
Please help
0
Comment
Question by:WxW
  • 2
3 Comments
 
LVL 2

Accepted Solution

by:
duneram earned 20 total points
ID: 1299785
first look:  It appears as though you are not specifying an ending position for the end of the link.

You probably need to add logic to turn off the toggle in the 'after linking section' to get it to terminate correctly.

In the stuff before the http:// key you need to make sure you don't start the 'link until you are supposed to:

Instead of 'p'  use

w[k]->p->rEdit->ToggleCharAttribute(CFM_LINK, CFE_LINK);

w[k]->(ttt+p)->rEdit->ToggleCharAttribute(CFM_LINK, CFE_LINK);

Use the same when turning it off.

You should also increase the points here... but this should work a bit better

0
 
LVL 6

Author Comment

by:WxW
ID: 1299786
Nope . Tje w[k]->p is NOT the same as the ttt[p] . ttt[p] is an index to the string ttt , and w[k]->p is a TWindow . AND , I check for a space character after a string to terminate the link  as you saw in
if ((unsigned char)ttt[p] == 0x20 )

0
 
LVL 2

Expert Comment

by:duneram
ID: 1299787
I was refering to how you do your strncmps...

"strncmpi(ttt + p,"mailto:",7) == 0)) "

You are taking the base ttt and adding the offset p

When you do that and eventially find a keyword, like 'ttt+p' --> "m" in "mailto:"

then you will want to start the link process at ttt+p, not 'p'  .

if your index 'p' is different from the 'p' in the pointer string, you should consider changing the names of one of them to avoid the confusion.  I assumed (since I didn't have the definition of p to be the same index you were using as the index of the loop.
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Preface In the first article: A Better Website Login System (http://www.experts-exchange.com/A_2902.html) I introduced the EE Collaborative Login System and its intended purpose. In this article I will discuss some of the design consideratio…
SASS allows you to treat your CSS code in a more OOP way. Let's have a look on how you can structure your code in order for it to be easily maintained and reused.
Viewers will learn about basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.

765 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question