[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

a_pess

4/21/2008 6:17:00 PM

Hi
I'am Trying to overrides WinProc to change the NonClient Area to use
my own skin
once i start the Debugging i can see the the changes, and then the
form will paint the standard windows nonClient Area
and form will be frozen

the code looks something like that

Public Class Form1

' API Declarations

Declare Function ScreenToClient Lib "user32" (ByVal hwnd As
Integer, ByRef lpPoint As Point) As Integer
Declare Function GetWindowDC Lib "user32" (ByVal hwnd As Integer)
As Integer
Declare Function GetWindowRect Lib "user32" (ByVal hwnd As
Integer, ByRef lpRect As Rectangle) As Integer


<System.Security.Permissions.PermissionSetAttribute(System.Security.Permissions.SecurityAction.Demand,
Name:="FullTrust")> _
Protected Overloads Overrides Sub WndProc(ByRef m As
System.Windows.Forms.Message)
'handle hits here
If m.Msg = 132 Then
ElseIf m.Msg = 133 Then
' (WM_NCPAINT)
Dim g As Graphics =
Graphics.FromHdc(GetWindowDC(Me.Handle))

Dim aRect2 As New Rectangle()
GetWindowRect(Me.Handle, aRect2)

Dim pt As New Point(aRect2.Left, aRect2.Top)
ScreenToClient(Me.Handle, pt)

Dim pt2 As New Point(aRect2.Right, aRect2.Bottom)
ScreenToClient(Me.Handle, pt2)

Dim aRect As New Rectangle(0, 0, aRect2.Right -
aRect2.Left, aRect2.Bottom - aRect2.Top)

Dim imgTopLeft As Image = Image.FromFile("c:\skins
\TopLeft.png")
Dim imgTopMid As Image = Image.FromFile("c:\skins
\TopMid.png")
Dim imgTopRight As Image = Image.FromFile("c:\skins
\TopRight.png")
Dim imgBottomLeft As Image = Image.FromFile("c:\skins
\BottomLeft.png")
Dim imgBottomMid As Image = Image.FromFile("c:\skins
\Bottom.png")
Dim imgBottomRight As Image = Image.FromFile("c:\skins
\BottomRight.png")
Dim imgRight As Image = Image.FromFile("c:\skins
\Right.png")
Dim imgLeft As Image = Image.FromFile("c:\skins\Left.png")

g.DrawImageUnscaled(imgTopLeft, 0, 0)
g.DrawImage(imgTopMid, imgTopLeft.Width, 0, (Width -
(imgTopRight.Width + imgTopLeft.Width) + 2), imgTopMid.Height)
g.DrawImage(imgTopRight, Width - imgTopRight.Width,
aRect.Top, imgTopRight.Width, imgTopRight.Height)
g.DrawImage(imgBottomLeft, aRect.Left, Height -
imgBottomLeft.Height, imgBottomLeft.Width, imgBottomLeft.Height)

g.DrawImage(imgBottomMid, imgBottomLeft.Width, Height -
imgBottomMid.Height, Width - imgBottomLeft.Width, imgBottomMid.Height)
g.DrawImage(imgBottomRight, Width - imgBottomRight.Width,
Height - imgBottomRight.Height, imgBottomRight.Width,
imgBottomRight.Height)



g.DrawImage(imgRight, Width - imgRight.Width,
imgTopRight.Height, imgRight.Width, Height - imgBottomRight.Height)
g.DrawImage(imgLeft, Left, imgTopLeft.Height,
imgLeft.Width, Height)


g.Dispose()
Else
MyBase.WndProc(m)
End If

End Sub


End Class

thnaks
a_pess