Use image as a border in C# - c#

I am creating a custom application in C# and I need to use a bitmap image instead of the standard windows borders. How can i do this?

If you are working with WinForms set
FormBorderStyle to None
BackgroundImage to your desired image
BackgroundImageLayout to Stretch
If you want to repeat a pattern on your boder instead, set
BackgroundImageLayout to Tile
and hide the center of the image with a panel.

Related

Transparent picturebox

I'm trying to add an icon to a Win Forms project, but I can't get the transparency working. I've tried with several different images but I'm not able to set the background color to blue.
What am I doing wrong?
Change back color of picturebox to Color.Transparent.
You can also try to use png file with transparency channel.
The PictureBox is transparent, you need to use a transparent image (such as a PNG), as already stated.

Forms background re-sizing?

i was wondering if there is anyway to Re-size a Forms background Image according to how high and how wide the form is. A property or a code maybe?
You could set
BackgroundImageLayout = ImageLayout.Stretch;
in either the Code or the Forms editor.

Equivalency to TransparencyKey in WPF

In Win Form, we can create non-rectangular forms by creating a bitmap that have a background color like blue. So, we can set it to background image of Win Form and with change TransparencyKey option to blue, we have a shaped-window.
So, my question is What is the equivalency to TransparencyKey in WPF that does like Win Form's TransparencyKey?
Thanks for your attention :)
There is no equivalent.
Just use an image with transparent areas (so it has to be a PNG or GIF), set the WindowStyle to None, set the window's background to Transparent, and set AllowTransparency to true.
Transparent areas will not be clickable.
Set AllowTransparency to true then use pixel shader effect library for wpf.
Use this link for more details about how to use pixel shader : Green screen in wpf

Windows Forms C# Panel should not have white background, and panel should be only image

I have a windows forms, i have placed an image on it, and the image is not rectangular, so white space lefts with it, because windows form is either square or rectangular, but image is not, i want panel should be only image, rest of the space should not be visible, i am attaching an image to describe further.
Thanks
Atif
as I understand it you want your form to be invisible?
that isn't supported well in winforms and you should consider moving to WPF.
however theres this example:
http://www.blackbeltcoder.com/Articles/winforms/non-rectangular-splash-screen-for-winforms
create a splash screen as the writer advices.
I think you have set form properties [BackgroundImageLayout:stretch] or
you have to change image size(width,height) same as form size(width,height)
Read the ImageSize before applying to the form.
Resize the form with the image size.
If you can set the ControlBox property of the Form, you can even hide the Close, Maximize and Minimize buttons from the right top corner.
So you mean to stretch your image to the window frame? Just dock the picturebox to full form size. There is an option called Dock in parent container. Use that
You need to set the BackgroundImageLayout property to ImageLayout.Stretch, ImageLayout.Zoom or ImageLayout.Tile depending on how you want the image to fill the Form.
Put the image on the form directly by setting the following properties:
Form1.BackgroundImage = MyBackgroundImage
Form1.BackgroundImageLayout = Stretch

How to make any control shape irregular in c#

how to make any control of win application transparent. i want that i will assign a background image for the target control and will invoke a routine and that routine will create that control transparent in such a way that only image will visible. as a example suppose image has assign to picture box. the picture shape is not square rather irregular. if i can make picture box transparent then user will see the image only. basically i want to make a picture box or any control irregular shape. how to achieve it through code in c#.
thanks
In WPF, transparency is quasi for free. For the image-element, assign a png-image with an alpha mask and the image will be rendered with active transparency.
For controls with an solid background, you generally have to set the Background to a transparent Brush:
If you want to make a whole window partial transparent, you have to remove the border, set the window style to none, set the background brush to a transparent brush, and set the AllowsTransparency-property of the window to true.
there is one for ordinary winform at
http://www.youtube.com/watch?v=K_JzL4kzCoE

Categories