Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Can't Get Form's Paint Method To Work...
Message
 
To
28/11/2006 09:24:39
Alexandre Palma
Harms Software, Inc.
Alverca, Portugal
General information
Forum:
ASP.NET
Category:
Other
Environment versions
Environment:
VB 8.0
OS:
Windows XP SP2
Network:
Windows 2003 Server
Database:
MS SQL Server
Miscellaneous
Thread ID:
01172750
Message ID:
01172926
Views:
12
This message has been marked as the solution to the initial question of the thread.
Actually, what you suggested got me thinking, so I did some more digging. As it turns out, I was trying to paint the wrong object. Apparently when using am MDI Parent form, the form itself is not the object you need to paint, but rather a control inside the form's ControlsCollection is used as the background. Apparently this control is automatically created when you specify that the form is am MDI Parent. Here is the code that works for me for anyone else that may encounter this issue:
    '***************************************
    ' Private Global Properties/Variables/Objects
    '***************************************
    Private WithEvents _MDIClient As MdiClient

    Private Sub frmMain_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Load
        '************************************************************************
        ' Procedure/Function: frmMain_Load()
        ' Author: Ben Santiago
        ' Last Revision: 04/05/2006
        ' Description:
        '       Initialize form.
        '************************************************************************

        '***************************************
        ' Find MDI Client Area At Load
        '***************************************
        For Each objControl As Control In Me.Controls
            If TypeOf objControl Is MdiClient Then
                Me._MDIClient = objControl
                Exit For
            End If
        Next
    End Sub

    Private Sub _MDIClient_Paint(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles _MDIClient.Paint
        '************************************************************************
        ' Procedure/Function: _MDIClient_Paint()
        ' Author: Ben Santiago
        ' Created On: 11/28/2006
        ' Description:
        '       Draw MDI Parent background.
        '************************************************************************

        Me.DrawBackground(e.Graphics)
    End Sub

    Private Sub _MDIClient_Resize(ByVal sender As Object, ByVal e As System.EventArgs) Handles _MDIClient.Resize
        '************************************************************************
        ' Procedure/Function: _MDIClient_Resize()
        ' Author: Ben Santiago
        ' Created On: 11/28/2006
        ' Description:
        '       Draw MDI Parent background.
        '************************************************************************

        Me.DrawBackground(Me._MDIClient.CreateGraphics())
    End Sub

    Private Sub DrawBackground(ByVal objCanvas As Graphics)
        '************************************************************************
        ' Procedure/Function: DrawBackground()
        ' Author: Ben Santiago
        ' Created On: 11/28/2006
        ' Description:
        '       Draw the gradient background for the MDI Parent form.
        '************************************************************************

        '***************************************
        ' Initialize Variables
        '***************************************
        Dim brushBlueGradient As LinearGradientBrush

        '***************************************
        ' Default Values
        '***************************************
        brushBlueGradient = New LinearGradientBrush(Me.ClientRectangle, _
                                                    Color.FromArgb(115, 160, 196), _
                                                    Color.FromArgb(194, 213, 224), _
                                                    LinearGradientMode.Vertical)

        '***************************************
        ' Draw Main Gradient Area
        '***************************************
        objCanvas.Clear(Me._MDIClient.BackColor)
        objCanvas.FillRectangle(brushBlueGradient, New Rectangle(0, 0, Me.ClientSize.Width, Me.ClientSize.Height))
    End Sub
________________________
Ben Santiago, MCP & A+
Programmer Analyst (SQL, FoxPro, VB, VB.Net, Java, HTML, ASP, JSP, VBS)
Eastern Suffolk BOCES - Student Data Services


Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning.
-Rich Cook
Previous
Reply
Map
View

Click here to load this message in the networking platform