Softer Windows Forms

G

Guest

I've noticed that a lot of programs have began to use a "softer" windows form. By that I mean the caption bar has lighter, softer colors and the corners are more rounded

How do you go about getting that look in a Visual Basic application? (v6 or .NET

Thanks~
 
H

Herfried K. Wagner [MVP]

* "=?Utf-8?B?SWNlZENyb3c=?= said:
I've noticed that a lot of programs have began to use a "softer"
windows form. By that I mean the caption bar has lighter, softer colors
and the corners are more rounded.

I have never seen such an application.
 
B

Brian Henry

if you mean forms like Roxio's CD-Creator 6 has, that's all custom drawn.


IcedCrow said:
I've noticed that a lot of programs have began to use a "softer" windows
form. By that I mean the caption bar has lighter, softer colors and the
corners are more rounded.
 
G

Guest

To get rounded corners try the following code in a module (.bas): [VB6

Private Declare Function GetWindowRect Lib "user32" (ByVal hWnd As Long, lpRect As RECT) As Lon
Private Declare Function SetWindowRgn Lib "user32" (ByVal hWnd As Long, ByVal hRgn As Long, ByVal bRedraw As Boolean) As Lon
Private Declare Function CombineRgn Lib "gdi32" (ByVal hDestRgn As Long, ByVal hSrcRgn1 As Long, ByVal hSrcRgn2 As Long, ByVal nCombineMode As Long) As Lon
Private Declare Function CreateEllipticRgn Lib "gdi32" (ByVal X1 As Long, ByVal Y1 As Long, ByVal X2 As Long, ByVal Y2 As Long) As Lon
Private Declare Function CreatePolygonRgn Lib "gdi32" (lpPoint As POINTAPI, ByVal nCount As Long, ByVal nPolyFillMode As Long) As Lon

Private Type POINTAP
X As Lon
Y As Lon
End Typ

Private Type REC
Left As Lon
Top As Lon
Right As Lon
Bottom As Lon
End Typ

Public Function RndRect(ByVal hWnd As Long, ByVal Arc As Long, Optional ByVal Redraw As Boolean = True) As Lon

' Written By: COD3B453 [[email protected]
' Legal: This comment MUST remain in this code snippe
' Description: Set window region so that it has rounded corner

Dim PointRgn(0 To 7) As POINTAP
Dim PolyRgn As Lon
Dim CircA As Lon
Dim CircB As Lon
Dim CircC As Lon
Dim CircD As Lon
Dim lArc As Lon
Dim W As Lon
Dim H As Lon
Dim wRect As REC

lArc = 2 * Ar
GetWindowRect hWnd, wRec
W = wRect.Right - wRect.Lef
H = wRect.Bottom - wRect.To

PointRgn(0).X = Ar
PointRgn(0).Y =

PointRgn(1).X = W - Ar
PointRgn(1).Y =

PointRgn(2).X =
PointRgn(2).Y = Ar

PointRgn(3).X =
PointRgn(3).Y = H - Ar

PointRgn(4).X = W - Ar
PointRgn(4).Y =

PointRgn(5).X = Ar
PointRgn(5).Y =

PointRgn(6).X =
PointRgn(6).Y = H - Ar

PointRgn(7).X =
PointRgn(7).Y = Ar

PolyRgn = CreatePolygonRgn(PointRgn(0), 8, 1
CircA = CreateEllipticRgn(0, 0, lArc, lArc
CircB = CreateEllipticRgn(W, 0, W - lArc, lArc
CircC = CreateEllipticRgn(W, H, W - lArc, H - lArc
CircD = CreateEllipticRgn(0, H, lArc, H - lArc

CombineRgn PolyRgn, PolyRgn, CircA,
CombineRgn PolyRgn, PolyRgn, CircB,
CombineRgn PolyRgn, PolyRgn, CircC,
CombineRgn PolyRgn, PolyRgn, CircD,

RndRect = SetWindowRgn(hWnd, PolyRgn, Redraw

End Functio

NOTE
'hWnd' should be the form's hwnd propert
'Arc' should be the radius of the curved corners in pixel
'Redraw' is optional and doesn't really matter too muc

Changing the colour of the caption bar is much harder, using the SetDIBitsToDevice API can do this but you have to override the window process for the form so that it doesn't draw the default one back on it

good luc

cod3b453
 
R

Rob Oldfield

Not having run anything that I've developed in XP I'm guessing, but are you
talking about just the standard XP 'look'?


IcedCrow said:
I've noticed that a lot of programs have began to use a "softer" windows
form. By that I mean the caption bar has lighter, softer colors and the
corners are more rounded.
 
G

Guest

Check out the new Yahoo Messager (Beta) for an example. The borders are rounded, the buttons are rounded, the colors softer

I am running windows 2000 at work so it's not an XP thing, though I notice XP has this as well.
 
C

CJ Taylor

I just realized maybe it's not good for me to comment on colors given that
I'm color blind and all. ;)
 
H

Herfried K. Wagner [MVP]

* "=?Utf-8?B?SWNlZENyb3c=?= said:
Check out the new Yahoo Messager (Beta) for an example. The borders are rounded, the buttons are rounded, the colors softer.

I am running windows 2000 at work so it's not an XP thing, though I notice XP has this as well.

I think these applications will use their own UI frameworks.
 
R

Rob Oldfield

Surely that makes you better placed than most? Which is the most useful
feedback about a UI?

"I like the colours."
"I don't like the colours."
"What UI?"



CJ Taylor said:
I just realized maybe it's not good for me to comment on colors given that
I'm color blind and all. ;)
 
C

Cor Ligthert

Hi Iced,

I thought I did not see *region* in this thread, do not know if you want it,
however maybe it gives you an idea.

Cor
\\\made by Herfried. K. Wagner, Fergus Cooney and Cor Ligthert
Private WithEvents button1 As New Button
Private Sub Form1_Load(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles MyBase.Load
Dim g As New System.Drawing.Drawing2D.GraphicsPath
g.AddString( _
"Iced", _
System.Drawing.FontFamily.GenericSansSerif, _
System.Drawing.FontStyle.Bold, _
200, _
New Point(0, 0), _
System.Drawing.StringFormat.GenericDefault _
)
Me.BackColor = Color.Red
Me.Region = New System.Drawing.Region(g)
g.Dispose()
Me.AutoScaleBaseSize = New System.Drawing.Size(0, 0)
Me.ClientSize = New System.Drawing.Size(800, 200)
button1.BackColor = System.Drawing.SystemColors.ActiveCaptionText
button1.ForeColor = System.Drawing.Color.Black
button1.Location = New System.Drawing.Point(50, 40)
button1.Size = New System.Drawing.Size(20, 20)
Me.Controls.Add(button1)
button1.Text = "X"
End Sub
Private Sub Button1_Click(ByVal sender As Object, _
ByVal e As System.EventArgs) Handles button1.Click
Me.Close()
End Sub
///
 
C

CJ Taylor

Herfried K. Wagner said:
* "CJ Taylor" <cege at the123 dont use this part till here tavayn dot com> scripsit:

I missed screenshots on the website...

Yes.. less the screenshots... it looked good.

=)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top