Hey,
I wanted to know how I could create custom forms in VB.NET such as:

http://www.oobox.com/music/graphics/InstrumentTunerV2.gif

It seems like all the programming I've done in .Net has the typical square edged forms. Is this even possible in .Net or is it some other language?

Thanks

Recommended Answers

All 9 Replies

its possible

Any clue on how to do it?

Ive seen a c# app where you can give the program wierd shaped skins (like you can with windows media player) so i know its possible.

No way to do it visually though, i dont think. They probably used GDI or DirectX

I've been wondering this same thing.

This could come in handy for many situations (creating splash screen, creating skinned interface, etc.).

I think it's a matter of hiding the titlebar, first of all, to get rid of default windows gui. Then if you want rounded or customized looking window, you have to set transparency and x and y of where the transparency will effect.

I remember messing with this a long time ago (VB3.0 long time ago). But haven't seen any code since then. I'm sure it's out there, just haven't looked for it.

to get rid of the titlebar: set FormBorderStyle to None

this one here is about the GDI i think: http://visualbasic.about.com/od/usingvbnet/l/aa080703a.htm

i just looked this site up: http://www.freevbcode.com/ShowCode.asp?ID=3725

you can use VB6/ActiveX to get any shape form. I know that. I made a traffic light once

check your pms

You can use the Windows Region and GDI++ GraphicsPath to set your shape then paint the interior like you want.
I have code somewhere if I can find it.

Couldn't find old code so whipped up this. Gives you idea on what to do. Create a new project and add this code.

Imports System.Drawing
Imports System.Drawing.Drawing2D

Public Class Form1

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Me.Show()
        Dim gp As New GraphicsPath
        Dim reg As New Region
        Dim border As Integer = (Me.Width - Me.ClientRectangle.Width) / 2
        Dim title As Integer = Me.Height - Me.ClientRectangle.Height - border
        gp.AddLine(New Point(border, title), New Point(Me.Width - border - 50, title))
        gp.AddLine(New Point(Me.Width - border - 50, title), New Point(Me.Width - border - 50, (Me.Height - border) / 2))
        Dim rect As New Rectangle(Me.Width - border - 175, (Me.Height - border) / 2 - 20, 150, 150)
        gp.AddArc(rect, 320, 180)
        gp.AddLine(New Point(Me.Width - 165, Me.Height - 150), New Point(border, Me.Height - 150))
        gp.CloseFigure()
        reg = New Region(gp)
        Me.Region = reg
        gp.Dispose()
        Me.Refresh()
    End Sub

    Private Sub Form1_MouseClick(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Me.MouseClick
        If e.Button = Windows.Forms.MouseButtons.Right Then Me.Close()
    End Sub

    Private Sub Form1_Paint(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles Me.Paint
        Dim rect = New Rectangle(0, 0, Me.Width, Me.Height)
        Dim lBrush As New LinearGradientBrush(rect, Color.Black, Color.Blue, LinearGradientMode.Vertical)
        Dim g As Graphics = Me.CreateGraphics
        g.FillRectangle(lBrush, rect)
        Dim myBrush = New SolidBrush(Color.LightGray)
        rect = New Rectangle(200, 200, 500, 500)
        g.FillRectangle(myBrush, rect)
        myBrush = New SolidBrush(Color.DarkGray)
        rect = New Rectangle(350, 200, 500, 500)
        g.FillRectangle(myBrush, rect)
        myBrush = New SolidBrush(Color.DimGray)
        rect = New Rectangle(490, 200, 500, 500)
        g.FillRectangle(myBrush, rect)
        g.Dispose()

    End Sub
End Class
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.