Form Transparency in Visual Studio .NET

Encode QR Code JIS X 0510 in Visual Studio .NET Form Transparency
Form Transparency
Make Denso QR Bar Code In Visual Studio .NET
Using Barcode drawer for .NET Control to generate, create Denso QR Bar Code image in Visual Studio .NET applications.
In addition to the properties that specify how the non-client area of a form are rendered by Windows, the Form class provides a set of properties that allow you to change the appearance of the form as a whole, including making it partially transparent or removing pieces of the form altogether The property that governs transparency of the entire form is called Opacity and defaults to 10, or 100% opaque A value between 00 and 10 denotes a degree of opacity using the alpha-blending[7] support in more modern versions of Windows, where any number less than 10 results in a form that is partially transparent Opacity is mostly a parlor trick, but it's kind of fun for making top-level windows less annoying than they would normally be, as shown here:
QR Code Reader In VS .NET
Using Barcode scanner for .NET Control to read, scan read, scan image in .NET framework applications.
Alpha-blending is the blending of partially transparent elements together based on an alpha value denoting their level of transparency
Draw Barcode In Visual Studio .NET
Using Barcode generation for .NET Control to generate, create barcode image in Visual Studio .NET applications.
void InitializeComponent() { thisOpacity = 05; thisText = "Opacity = 05"; thisTopMost = true; } void OpacityForm_Activated(object sender, EventArgs e) { timer1Enabled = true; } void timer1_Tick(object sender, EventArgs e) { if( thisOpacity < 10 ) thisOpacity += 01; thisText = "Opacity = " + thisOpacityToString(); } void OpacityForm_Deactivate(object sender, EventArgs e) { timer1Enabled = false; thisOpacity = 05; thisText = "Opacity = " + thisOpacityToString(); } This example shows code from a top-level form whose Opacity property starts at 50% When the form is activated, it starts a timer that increases the Opacity by 10% on each tick, giving a nice "fade in" effect, as shown in Figure 24 When the form is deactivated, it is set to 50% opaque again, making it available for viewing and clicking but hopefully not obscuring too much
Barcode Recognizer In VS .NET
Using Barcode recognizer for .NET Control to read, scan read, scan image in .NET applications.
Figure 24 Opacity
QR Code Drawer In Visual C#
Using Barcode creator for Visual Studio .NET Control to generate, create QR Code ISO/IEC18004 image in Visual Studio .NET applications.
Nonrectangular Forms
Denso QR Bar Code Creation In .NET
Using Barcode drawer for ASP.NET Control to generate, create QR Code image in ASP.NET applications.
Opacity affects the transparency of the entire form It's also possible to change the shape of the form by making parts of the form completely transparent One way to do this is with the TransparencyKey property, which designates a color to use in marking transparent pixels When a pixel on the form is supposed to be drawn with the transparent key color, that pixel will instead be removed from the form, in two senses: The pixel will not be drawn, and clicking on that spot on the form will actually result in a click on what's showing through from underneath For example, setting the TransparencyKey property to the same as the BackColor property of the form will cause a form to lose its background (as well as anything else drawn with that color), as shown in Figure 25
Generate QR Code JIS X 0510 In VB.NET
Using Barcode encoder for VS .NET Control to generate, create QR Code 2d barcode image in Visual Studio .NET applications.
Figure 25 Form Shown in Front of Notepad with TransparencyKey Set to BackColor
UPC-A Generator In .NET
Using Barcode encoder for VS .NET Control to generate, create UPC A image in Visual Studio .NET applications.
The novelty of the form shown in Figure 25 seems limited until you combine it with FormBorderStyleNone, which removes the non-client area altogether, as shown in Figure 26
Drawing Bar Code In .NET
Using Barcode printer for VS .NET Control to generate, create barcode image in .NET framework applications.
Figure 26 TransparencyKey Combined with FormBorderStyleNone
Creating Barcode In VS .NET
Using Barcode drawer for VS .NET Control to generate, create barcode image in Visual Studio .NET applications.
The combination of a transparent color to erase the form's background and the removal of the form border yields a nonrectangular window, which is all the rage with the kids these days The transparency key color is used to create a region that describes the visible area of the form to Windows As easy as setting TransparencyKey is, you need to be careful with it For example, you need to choose a color that you know won't appear in the parts of your form that you need to show, or else they'll be made transparent, too Also, when using the TransparencyKey, you must calculate the region each time the form is drawn And most importantly, TransparencyKey requires certain capabilities of the video driver that are often missing, causing it to fail completely So instead of using TransparencyKey, you may want to set the form's Region property directly This approach is slightly less convenient but much more robust Regions are covered in detail in 6: Advanced Drawing, but here's an example of using an ellipse as the form's region: using SystemDrawingDrawing2D; void SetEllipseRegion() { // Assume: thisFormBorderStyle = FormBorderStyleNone Rectangle rect = thisClientRectangle; using( GraphicsPath path = new GraphicsPath() ) { pathAddEllipse(rect); thisRegion = new Region(path); } } void TransparentForm_Load(object sender, EventArgs e) { SetEllipseRegion(); } void TransparentForm_SizeChanged(object sender, EventArgs e) { SetEllipseRegion(); } Notice that our code sets the region both when the form is loaded and whenever the form is resized However, as careful as we are to handle resizing, with the caption and the edges on the form missing, there's no way for the user to actually move or resize the form When that's the case, you're on the hook to implement moving and resizing yourself Here's an example of
GTIN - 128 Maker In .NET Framework
Using Barcode creation for .NET framework Control to generate, create GTIN - 128 image in .NET framework applications.
using the mouse events to move the form around when the user clicks in the client area of the form: Point downPoint = PointEmpty; void TransparentForm_MouseDown(object sender, MouseEventArgs e) { if( eButton != MouseButtonsLeft ) return; downPoint = new Point(eX, eY); } void TransparentForm_MouseMove(object sender, MouseEventArgs e) { if( downPoint == PointEmpty ) return; Point location = new Point( thisLeft + eX - downPointX, thisTop + eY - downPointY); thisLocation = location; } void TransparentForm_MouseUp(object sender, MouseEventArgs e) { if( eButton != MouseButtonsLeft ) return; downPoint = PointEmpty; } When the user clicks on the client area of the form, the MouseDown event is fired, and we handle this event by caching the point on the screen where the user clicked When the user moves the mouse, the MouseMove event is fired, and we use that to move the form based on the difference between the current mouse location and the point where the user first clicked Finally, when the user releases the mouse button, the MouseUp event fires, which we use to stop the move You'd need something similar to implement resizing The details of mouse events, as well as keyboard events, are covered in 8: Controls [ Team LiB ]
Encode Delivery Point Barcode (DPBC) In Visual Studio .NET
Using Barcode creation for .NET framework Control to generate, create Postnet 3 of 5 image in VS .NET applications.
[ Team LiB ]
GS1 - 13 Recognizer In .NET
Using Barcode reader for .NET framework Control to read, scan read, scan image in Visual Studio .NET applications.
Data Matrix Creation In .NET Framework
Using Barcode drawer for ASP.NET Control to generate, create ECC200 image in ASP.NET applications.
Barcode Recognizer In Java
Using Barcode scanner for Java Control to read, scan read, scan image in Java applications.
Bar Code Generation In Visual Basic .NET
Using Barcode encoder for VS .NET Control to generate, create barcode image in VS .NET applications.
Code39 Creation In C#
Using Barcode printer for VS .NET Control to generate, create USS Code 39 image in .NET applications.