Solved

Richedit 2.0 and CFM_LINK

Posted on 1998-09-12
3
1,287 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

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
XSLT 5 47
Magento Indexing 1 98
MVC and Angular 2 105
How to write an English digest paper 6 50
It's sometimes a bit tricky to use date functions in Oracle BPEL. I'll explain quickly how you can add N days to the current date. In a BPEL process this can be useful, and you can adapt it to fit your needs. First of all, let's see how to add 1 …
Introduction Since I wrote the original article about Handling Date and Time in PHP and MySQL (http://www.experts-exchange.com/articles/201/Handling-Date-and-Time-in-PHP-and-MySQL.html) several years ago, it seemed like now was a good time to updat…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

810 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