473,654 Members | 3,289 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

disable using "protected override void OnPaint(..." method.

Hi,

Is there any way disable using "protected override void OnPaint(..." method
out of the assembly. I create usercontrol and i do not want user adds extra
codes OnPaint method for securtity purpose. And i don't give a permission to
call "CreateGraphics ()".

Thanks your responses.
Sep 7 '08 #1
7 3636
protected override sealed void OnPaint........ ..
{
}

Add the word "sealed" after "override"

Sep 7 '08 #2
i had used your advice but it has alreay used onpaint outside of the
assembly. I can add "private void graph2D1_Paint( object sender,
PaintEventArgs e)" method from properties->events->paint but ı don't this
event calling.

"Peter Morris" wrote:
protected override sealed void OnPaint........ ..
{
}

Add the word "sealed" after "override"

Sep 7 '08 #3
ramo9941 <ra******@discu ssions.microsof t.comwrote:
i had used your advice but it has alreay used onpaint outside of the
assembly. I can add "private void graph2D1_Paint( object sender,
PaintEventArgs e)" method from properties->events->paint but ? don't this
event calling.
That's adding an event handler for the Paint event, which isn't the
same as overriding the OnPaint method. And no, you can't prevent that.
--
Jon Skeet - <sk***@pobox.co m>
Web site: http://www.pobox.com/~skeet
Blog: http://www.msmvps.com/jon.skeet
C# in Depth: http://csharpindepth.com
Sep 7 '08 #4
ok,
if user adds under codes to "graph2D1_Paint " method:
base.OnPaint(e) ;
MessageBox.Show ("1");
Has any protection mechanism this state?

And same as above state protect to not caling "CreateGraphics ()" method
outside of the assembly.

thanks yor replies.

"Jon Skeet [C# MVP]" wrote:
ramo9941 <ra******@discu ssions.microsof t.comwrote:
i had used your advice but it has alreay used onpaint outside of the
assembly. I can add "private void graph2D1_Paint( object sender,
PaintEventArgs e)" method from properties->events->paint but ? don't this
event calling.

That's adding an event handler for the Paint event, which isn't the
same as overriding the OnPaint method. And no, you can't prevent that.
--
Jon Skeet - <sk***@pobox.co m>
Web site: http://www.pobox.com/~skeet
Blog: http://www.msmvps.com/jon.skeet
C# in Depth: http://csharpindepth.com
Sep 7 '08 #5
ramo9941 <ra******@discu ssions.microsof t.comwrote:
if user adds under codes to "graph2D1_Paint " method:
base.OnPaint(e) ;
MessageBox.Show ("1");
Has any protection mechanism this state?
No. You can't stop them from calling methods they're normally allowed
to call. That violates object oriented principles. If you don't want
users to be calling certain methods, you shouldn't be deriving from a
class which exposes those methods.

--
Jon Skeet - <sk***@pobox.co m>
Web site: http://www.pobox.com/~skeet
Blog: http://www.msmvps.com/jon.skeet
C# in Depth: http://csharpindepth.com
Sep 8 '08 #6
>i had used your advice but it has alreay used onpaint outside of the
assembly.
Then you shouldn't try to seal it.
Sep 8 '08 #7
Jon Skeet [C# MVP] wrote:
ramo9941 <ra******@discu ssions.microsof t.comwrote:
>if user adds under codes to "graph2D1_Paint " method:
base.OnPaint(e );
MessageBox.Sho w("1");
Has any protection mechanism this state?

No. You can't stop them from calling methods they're normally allowed
to call. That violates object oriented principles. If you don't want
users to be calling certain methods, you shouldn't be deriving from a
class which exposes those methods.
As in:

Instead of inheriting, make the object you want to limit access to a private
member (or even a private nested class derived from the base class). Then
you can call any methods on it you want, and intercept any calls your user
makes, because they are not called on the protected object but rather on
your class.
Sep 8 '08 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

28
3408
by: Act | last post by:
Why is it suggested to not define data members as "protected"? Thanks for help!
7
2569
by: Ollej Reemt | last post by:
Hello, I would like to know if there is a difference in c++ between the following two method-declarations: void Method(); and void Method(void);
4
7341
by: p988 | last post by:
using System; using System.Windows.Forms; using System.Drawing; class MyForm : Form { MyForm () { Text = "Windows Forms Demo"; }
3
6703
by: Jordan Taylor | last post by:
I am confused about protected member functions and objects. Is there any particular advantage of declaring members protected?
4
1816
by: Tina | last post by:
This is an issue regarding what exactly is accomplished by using "Protected" when defining a variable. It seems it does much more than just applying Protected status to a variable. I have an ascx control named HeadingBar. I have dragged it onto an aspx page. If I use the following statement..... Dim HeadingBar1 as HeadingBar
5
8858
by: none | last post by:
I'd like to create a new static property in a class "hiding" the property present in a base class. Since this needs to happen at runtime I tried doing this via DynamicMethod. But obviously the created methods are not "registered" and only available through the DynamicMethod class. So a method lookup finds the origin property. A little test: public class DerivedClass : BaseClass {
1
2256
by: hpandey | last post by:
sigaction : using "void (*sa_sigaction)(int, siginfo_t *, void *);" -------------------------------------------------------------------------------- hello, in sigaction manpage it's written : sa_sigaction also specifies the action to be associated with signum. This function receives the signal number as its first argument, a pointer to a siginfo_t as its second argument and a pointer to a ucon-
4
2141
by: =?Utf-8?B?WWFlbA==?= | last post by:
Hi, com add-in vs.net 2003 & outlook 2003 & c# I need to access to protected method of AxHost, How can I do this? I get nothing after the dot (base.), Why? This is my code: I need to set icon on commandBarButton: I need to get this: return(stdole.IPictureDisp)base.GetIPictureDispFromPicture(image); Thank you.
2
1647
by: Rob Richardson | last post by:
Greetings! Consider the following: class CBase { public: CBase(); virtual ~CBase();
0
8376
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8290
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8708
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8489
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8594
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6161
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5622
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
2716
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1596
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.