Multicolor form

Shamsher
03-25-2002, 01:11 PM
Everybody seen the windows 98 title bar which contains multicolor between two color.
I want to do same with my form in VB. Is there any idea that how can I do this.:rolleyes:

Robby
03-25-2002, 01:24 PM
Here's a sample you can fool around with...

Private Sub Command1_Click()
SpinGradient Me, 11, 11, 2, 222, 255, 255, True

End Sub

Sub SpinGradient(frm As Form, rs%, gs%, bs%, re%, ge%, be%, smooth As Boolean)

If frm.WindowState = vbMinimized Then Exit Sub
frm.BackColor = RGB(rs, gs, bs)
If smooth = True Then
frm.DrawStyle = 6
Else
frm.DrawStyle = 0
End If
If frm.ScaleWidth <> 255 Then
frm.ScaleWidth = 255
End If
If frm.ScaleHeight <> 255 Then
frm.ScaleHeight = 255
End If
frm.DrawWidth = 5
frm.Refresh
ri = (rs - re) / 255 / 2
gi = (gs - ge) / 255 / 2
bi = (bs - be) / 255 / 2
rc = rs: bc = bs: gc = gs
For x = 0 To 255
DoEvents
frm.Line (x, 0)-(255 - x, 255), RGB(rc, gc, bc)
rc = rc - ri
gc = gc - gi
bc = bc - bi
Next x
For x = 0 To 255
DoEvents
frm.Line (255, x)-(0, 255 - x), RGB(rc, gc, bc)
rc = rc - ri
gc = gc - gi
bc = bc - bi
Next x
End Sub

Robby
03-25-2002, 01:26 PM
Here's another one...

Private Sub Command1_Click()
Explode Me
GradientPlus Me, 200, 0, 150, 100, 250, 250
End Sub

Sub Explode(frm As Form)
frm.Width = 0
frm.Height = 0
frm.Show
For x = 0 To 10000 Step 250
frm.Width = x
frm.Height = x
With frm
.Left = (Screen.Width - .Width) / 2
.Top = (Screen.Height - .Height) / 2
End With
Next x
End Sub

Sub GradientPlus(frm As Form, StartRed As Integer, StartGreen As Integer, StartBlue As Integer, EndRed As Integer, EndGreen As Integer, EndBlue As Integer)
On Error Resume Next
Dim x As Integer
Dim RedChange As Integer
Dim GreenChange As Integer
Dim BlueChange As Integer

frm.DrawStyle = 6 ' Inside Solid
frm.ScaleMode = 3 ' Pixels
frm.DrawMode = 13 ' Copy Pen
frm.DrawWidth = 2
frm.ScaleHeight = 256

For x = 0 To 255 'Start Loop
'Draws Line With correct color
frm.Line (0, x)-(Screen.Width, x - 1), RGB(StartRed + RedChange, StartGreen + GreenChange, StartBlue + BlueChange), B
RedChange = RedChange + (EndRed - StartRed) / 255 '
GreenChange = GreenChange + (EndGreen - StartGreen) / 255 ' Sets Next Loops Color
BlueChange = BlueChange + (EndBlue - StartBlue) / 255 '
Next x
End Sub

Volte
03-25-2002, 02:19 PM
Those are great examples of gradiant drawing functions, but in
order to make the titlebar gradient, you'll need to subclass the
form and intercept the WM_NCPAINT (and quite possibly
other WM_NCxxxx messages. NC meaning
'non-client', referring to the Form's borders and titlebar.

I am fairly certain there is an example on www.planetsourcecode.com,
but I can't be sure how well coded it is. The Hand is the expert in
this area.

Flyguy
03-25-2002, 03:19 PM
Wait a moment, I don't understand it anymore ...

I never used any special technique to have colored titlebars, it's all handled by the OS itself. Has nothing to do with VB...
Only when you want to emulate it on Win95 you have to draw your own titlebar.

Robby
03-25-2002, 03:28 PM
Idiot me, I thought Shamsher wanted to color the form. :D

Shamsher
03-27-2002, 04:09 AM
Hey,

Thankx to all you guys. This realy I want.

ChiefRedBull
03-28-2002, 06:47 AM
Some funky effects Robby - I like!! :D

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum