remove highlighting in a textarea

I have a multi-line, read-only text edit box.

When my dialog is initiallized, I place some text in the edit box, to display to the user.

The text always appears as marked highlighted - how can I un-highlight, or de-select the text inside the text area?

Thanks,

TimB
LVL 1
TimBAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

V_BapatCommented:
m_edit.SetSel(-1, -1);

where m_edit is the member variable of the edit box.
0
Vinayak KumbarSr Program ManagerCommented:
Hi,

Can u pls paste the code where u are inserting the text. But still try using SetSel(0,0,FALSE); for that edit control after inserting or after displaying.

Try it out.
0
TimBAuthor Commented:
Hi,

I've tried both setsel(-1,-1), and setsel(0,0,false) - neather seemed to do the trick....

Here's my code:

BOOL CLiciencePage::OnInitDialog()
{
 CPropertyPage::OnInitDialog();
      
 CString sLicience;
 sLicience = "COPYRIGHT/DISCLAIMER\r\clientname\r\n";
 
 sLicience += (about 300 words of text)

 m_LICIENCE_EDIT.SetWindowText(sLicience);
 m_LICIENCE_EDIT.SetSel(0,0,FALSE);



 return TRUE;  // return TRUE unless you set the focus to a control
 // EXCEPTION: OCX Property Pages should return FALSE
}

//////////////

looking at this - is this something to do with returning TRUE (as its a proberty page)?

TimB
0
Cloud Class® Course: Amazon Web Services - Basic

Are you thinking about creating an Amazon Web Services account for your business? Not sure where to start? In this course you’ll get an overview of the history of AWS and take a tour of their user interface.

V_BapatCommented:
Maybe that edit control has focus. Try to set focus to any other control.
0
TimBAuthor Commented:
the textarea is the only component I've placed in this propertypage....
0
V_BapatCommented:
Then I would suggest you to use CStatic control and set text the same you are doing.
0
TimBAuthor Commented:
Ok, I might do that....

If you don''t mind, I'll reject your initial answer - just in case someone else can help.

If I use a cstatic in the end can you resubmit...


Thanks,

TimB
0
V_BapatCommented:
You can also try to add a dummy control, make it invisible and set focus to that control.
0
pagladasuCommented:
It appears that SetSel() does not work when written in OnInitDialog() function. Move the code to OnShowWindow() (use classwizard to map WM_SHOWWINDOW) and you will find it working.

Here is what I did:
void CEditcDlg::OnShowWindow(BOOL bShow, UINT nStatus)
{
      CDialog::OnShowWindow(bShow, nStatus);
      m_edit.SetSel(-1,0);
      // TODO: Add your message handler code here
      
}
0
TimBAuthor Commented:
Nope,

That didn't work...

I'm using property pages instead of dialogs, but I don't see how that would make a difference.

0
V_BapatCommented:
I could simulate the problem.

Suppose you have 3 property pages. The 3rd page has the multiline edit control which is the only control on that page.

Case 1:
When the propertysheet opens, page is not the active page. Instead page 1 or 2 is active and another edit control(in my case) has the focus. Now if you click on page 3, all the text is highlighted.

Case 2:
When the propertysheet opens and page 3 is the active page.

Solution: Add a handler to EN_SETFOCUS and add m_edit.SetSel(-1,-1).

Sample Code:
BOOL CDummy::OnInitDialog()
{
      CPropertyPage::OnInitDialog();

      CString sLicence;
      sLicence = "COPYRIGHT/DISCLAIMER\r\nclientname\r\n";

      sLicence += "sdfl kfdlvk dfv dflkvjhfldkjv hfdlkjv\r\n hsfdlkjv slfdkjv hsfdlkvhvdalkjvh sdfkjvd\r\n";
      sLicence += "sdfl kfdlvk dfv dflkvjhfldkjv hfdlkjv\r\n hsfdlkjv slfdkjv hsfdlkvhvdalkjvh sdfkjvd\r\n";
      sLicence += "sdfl kfdlvk dfv dflkvjhfldkjv hfdlkjv\r\n hsfdlkjv slfdkjv hsfdlkvhvdalkjvh sdfkjvd\r\n";

      m_edit1.SetWindowText(sLicence);

      return TRUE;  // return TRUE unless you set the focus to a control
                    // EXCEPTION: OCX Property Pages should return FALSE
}

void CDummy::OnSetfocusEdit1()
{
      m_edit1.SetSel(-1, -1);
}

Vicky
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
bhatCommented:
Hi ,

It is not required to do that much as Vbapat has said.

Just change the tab order in the resource editor. The edit box may be having the tab order as 1. Change it to 2 .
and set the other control as 1.

Hope this helps
0
TimBAuthor Commented:
Fantastic!

That worked a treat...

Thanks,

Tim
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
System Programming

From novice to tech pro — start learning today.