Custom Properties for Existing Controls

Mesh

New member
Joined
Jul 5, 2006
Messages
3
Programming Experience
1-3
What I would really like, is to add an Opacity property to a picturebox. Is this possible? If so, how? Any help will be greatly appreciated. Thank you.
 
I'm sure it can be done though i am struggling to think of how it could be useful. If you are going to put an image in it anyway what would be the point? It is possible, if you explain what you are trying to do then i could find another way round.
 
screen capture application

vis781,

Thanks for the reply. I am building an application where you can
turn the opacity of a picturebox down to zero, click a button, and
a picture would be taken of whatever was behind the picturebox.

I have a check box that turns the picturebox transparent using the
transparencyKey property but I would like it much better if I could
use a trackbar to control the opacity.

Also, I would really like to know how to add custom properties to
controls that already exist. That would be very useful in the future.

Thanks again for your reply.
 
Ok, well as i said there is probably a better way to do that. I would use a borderless form. Give me a few minutes or so and i'll get back to you with an outline model,
 
Is this going to be some kind of image capture utility? something like iconcool editors screen capture?
I would'nt go down the picutre box route. As i said i would be thinking about a borderless form.
If you need help with the screen capture routine have something that will help you.
It's basically a function that captures an image of whatever is underneath the form your using.

As for the properties, a property can be of any type you want.
The only things you need to make custom properties are, about 2 minutes and a private varaible.
So i have a contol that i want to add a on/off property to. I would simply do this....


VB.NET:
'Create an enum to be our new OnorOff type
Public Enum OnorOff
On
Off
End Enum
 
'All we need now is to create a private variable in the class that is going to hold the property, 
which will hold the current value of our enum (which will be on or off)
 
Private _OnOff as OnorOff
 
'Has to be public so it can be seen outside the application it has been created in.
Public Property IsItOnorOff as OnorOff
Get
Return me._OnOff
End Get
Set(byval value as OnorOff)
me._OnOff = value
End Set 
End Property
Thats it. Our new property would be visible to intellisense and in the properties window at design time.
It doesn't do anything yet, but then it's up the the class to perform actions based on the value
of that private variable we declared. See Where i'm going?
 
vis781,

Thank you for the information. I think you're right, a borderless form seems the way to go. I have coded the screen capture function and it is working as I would like. It also seems that I can control the opacity of a form with a trackbar just fine so I will use that instead of a picturebox.

The application I am attempting to build is more like FlySketch by Flying Meat.com for the Mac. There is a video here. (under screenshots, titled "Highlight and Capture")

Your example of adding a property was great. That will come in handy. Thanks again for your time.
 
Last edited:
Back
Top