Click here to Skip to main content
15,867,568 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I'm try to use webbrowser in mfc project.
But I don't know how to prevent select text from webbrowser.google result is "javascript function", any interface could do directly?
Posted
Updated 27-Apr-11 23:15pm
v2

No interfaces can prevent anything. Interfaces are interfaces.
And no, selection in the Web browser is always available, to best of my knowledge. I always thought it is very good: one can always copy any part of content at any time. Why anyone would need to prevent it?

[EDIT]
The trick suggested by Nishant will certainly work. In agreement with him, I don't think it makes practical sense. If your idea is to copy-protect any content — it makes no practical sense, would only make copy more difficult. Why?

—SA
 
Share this answer
 
v2
Comments
Joan M 28-Apr-11 12:19pm    
100% agree +5.
Sergey Alexandrovich Kryukov 28-Apr-11 12:35pm    
Thank you, Joan.
--SA
trickglom 1-May-11 11:35am    
Thanks.I want to use webbrowser as UI.Text selection make webbrowser-based UI bad,so I want to prevent it.
Sergey Alexandrovich Kryukov 1-May-11 14:50pm    
I would advice not to.
--SA
You could use a transparent static control over your hosted web browser. But this will prevent the user from selecting anything (not just text).

But this is a very poor and ineffective way to implement copy-protection. The user can still take a screen capture and get the text out of that. So be aware of that too.
 
Share this answer
 
v2
Comments
Sergey Alexandrovich Kryukov 28-Apr-11 11:42am    
Great trick! I failed to invent something like that (I'll reference your answer in mine). So, my 5.

As to the practical value of it -- of course it would not really copy-protect anything, perhaps just from the lamers. I don't think what OP wants makes sense at all.
--SA
Nish Nishant 28-Apr-11 11:42am    
Thanks SA!
Joan M 28-Apr-11 12:10pm    
:D nice one! 5
Nish Nishant 28-Apr-11 12:12pm    
Thanks Joan.
trickglom 1-May-11 11:49am    
Thanks.Prevent everything is not well.Copy-protection is not my goal.Using webbrowser as a simple UI,text selection make it bad,so I want to prevent it
As others say it is impossible to prevent everything... i.e. the user taking a picture on the screen and then rewriting the text... ^^¡

I would:

1. Show the web control and then capture and discard:
1.1. All the mouse events with the left button pressed.
1.2. The press of the Shift+F1 and the menu key.
1.3. PrintScr key.
1.4. Ctrl+C and Shift (I don't remember the other option (Insert perhaps?)).
2. Put the focus to another window just at the moment it is gained by the web control.

Pray for not having missed any of the possibilities...

PS: you are in a lost battle... i.e. there are plenty of other tools that will grab the screen...
PS2: Nish one is faster, easier and you'll get the same result...
PS3: And SAKryukov is completely right too.

Good luck...
 
Share this answer
 
Comments
trickglom 1-May-11 11:43am    
Thanks.I want to use webbrowser as UI.Text selection make webbrowser-based UI bad,so I just want to prevent it.After dig in msdn, to prevent a selectstart event handler at "IDispatch-invoke" maybe do.But it difficult to me.I just study VC++ 8 month,can't comfirm it.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900