Re: [2008] Glassy aero form
you can use an image for your form background + change the shape of the form using its region property. i've got some code that creates a rounded rectangle graphicspath that you can use to create the new region. i'll post it as soon as i find it
Re: [2008] Glassy aero form
vb Code:
Public Class Form1
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Me.Region = New Region(roundedRectangle(0, 0, 500, 200, 50))
End Sub
Public Function roundedRectangle(ByVal X As Integer, ByVal Y As Integer, _
ByVal Width As Integer, ByVal Height As Integer, ByVal diameter As Integer) As System.Drawing.Drawing2D.GraphicsPath
''the 'diameter' parameter changes the size of the rounded region
Dim graphics_path As New System.Drawing.Drawing2D.GraphicsPath
Dim BaseRect As New RectangleF(X, Y, Width, Height)
Dim ArcRect As New RectangleF(BaseRect.Location, New SizeF(diameter, diameter))
'top left Arc
graphics_path.AddArc(ArcRect, 180, 90)
graphics_path.AddLine(X + CInt(diameter / 2), _
Y, X + Width - CInt(diameter / 2), Y)
' top right arc
ArcRect.X = BaseRect.Right - diameter
graphics_path.AddArc(ArcRect, 270, 90)
graphics_path.AddLine(X + Width, _
Y + CInt(diameter / 2), X + Width, _
Y + Height - CInt(diameter / 2))
' bottom right arc
ArcRect.Y = BaseRect.Bottom - diameter
graphics_path.AddArc(ArcRect, 0, 90)
graphics_path.AddLine(X + CInt(diameter / 2), _
Y + Height, X + Width - CInt(diameter / 2), _
Y + Height)
' bottom left arc
ArcRect.X = BaseRect.Left
graphics_path.AddArc(ArcRect, 90, 90)
graphics_path.AddLine(X, Y + CInt(diameter / 2), _
X, Y + Height - CInt(diameter / 2))
Return graphics_path
End Function
End Class
Re: [2008] Glassy aero form
the original form (you can set the region of controls too) has to be larger than the new region or it won't display properly
Re: [2008] Glassy aero form
Cheers paul. Its a nice simple workaround for the moment, though I'll still be open to suggestions, since finding a faux transparent bg to suit all colours isnt easy to get right.
Also, I'm hoping to be able to use a gui such as this in the future:
http://www.teebo.com/images/glassplain.png
Many thanks
Re: [2008] Glassy aero form
Surely if you want to support Aero Glass then you should be using WPF, not Windows Forms.
Re: [2008] Glassy aero form
AeroGlass is a Vista theme. You dont have to do anything to get the Aero theme applied to your form when its run on Vista. Now the rounded glassy button is a different story. If its just advanced graphics you want then using the GDI+ classes is enough but to mimic the aero theming on custom controls will require the use of the WPF like John posted.
Re: [2008] Glassy aero form
Check this out, it might help you (there's a VB code too, scroll a bit down):
http://www.aeroxp.org/board/lofivers...php?t1641.html
Re: [2008] Glassy aero form
Cheers though it says 'InitializeComponent' is not declared:
Code:
Imports System.Data
Imports System.Drawing
Imports System.Text
Imports System.Windows.Forms
Imports System.Runtime.InteropServices
Namespace GlassTest
Public Class Form1
Inherits Form
' Import functions from dwmapi.dll - get this info from the sdk dwmapi.h
<DllImport("dwmapi.dll", CharSet:=CharSet.Auto)> _
Public Shared Sub DwmExtendFrameIntoClientArea(ByVal hWnd As System.IntPtr, ByRef pMargins As Margins)
End Sub
<DllImport("dwmapi.dll", CharSet:=CharSet.Auto)> _
Public Shared Sub DwmIsCompositionEnabled(ByRef IsIt As Boolean)
End Sub
' Create the brush that'll work around the Alpha transparency issue
Private DWMFrame As SolidBrush = New SolidBrush(Color.Black)
' Define the Margins struct - get this from dwmapi.h
Public Structure Margins
Public Left As Integer
Public Right As Integer
Public Top As Integer
Public Bottom As Integer
End Structure
' Create an instance of the Margins struct for use in our form
Private inset As Margins = New Margins
Public Sub New()
InitializeComponent()
AddHandler Me.Paint, AddressOf Me.Form1_Paint
' Set the Margins to their default values
inset.Top = 40
inset.Left = 0
inset.Right = 0
inset.Bottom = 0
' Check if DWM is enabled. This is a pretty stupid way to check, since it requires dwmapi.dll to be present anyway...
Dim isit As Boolean = False
DwmIsCompositionEnabled(isit)
If isit Then
' If DWM is enabled, call the function that gives us glass, passing a reference to our inset Margins
DwmExtendFrameIntoClientArea(Me.Handle, inset)
Else
' If DWM isn't enabled, shout it out
MessageBox.Show("DWM isn't enabled")
End If
End Sub
' We need to override the Paint event as well as call the glass function. This is because of WindowsForms and Alpha-blending...
Private Sub Form1_Paint(ByVal sender As Object, ByVal e As PaintEventArgs)
e.Graphics.FillRectangle(DWMFrame, 0, 0, Width, inset.Top)
e.Graphics.FillRectangle(DWMFrame, 0, 0, inset.Left, Height)
' Note the numbers ( -14, -34) are just trial-and-error values, used to fix the glass... try omitting them, you'll get the idea.
e.Graphics.FillRectangle(DWMFrame, Width - inset.Right - 14, 0, inset.Right, Height)
e.Graphics.FillRectangle(DWMFrame, 0, Height - inset.Bottom - 34, Width, inset.Bottom)
End Sub
End Class
End Namespace
Any suggestions?
Re: [2008] Glassy aero form
It worked for me, although I think I might have left out the "Namespace GlassTest" and "End Namespace" bits... Not sure though
1 Attachment(s)
Re: [2008] Glassy aero form
You should not be using the New constructor or the Paint event to do aero as its better to use the OnPaint overrides instead if you are not going to use WPF.
Just try writting on glass with the non-WPF methods :D