Print Page | Close Window

Problem: Repaint MdiClient

Printed From: Codejock Forums
Category: Codejock Products
Forum Name: Command Bars
Forum Description: Topics Related to Codejock Command Bars
URL: http://forum.codejock.com/forum_posts.asp?TID=17613
Printed Date: 27 November 2024 at 8:22am
Software Version: Web Wiz Forums 12.04 - http://www.webwizforums.com


Topic: Problem: Repaint MdiClient
Posted By: ws0411101
Subject: Problem: Repaint MdiClient
Date Posted: 29 November 2010 at 2:25am
I'm developing a MdiForm programm, I want to paint some text on the MdiClient.

first, i get the client of the form:
--------------------------------------------------
    Function FindMDIClient() As MdiClient
        Dim i As Integer = 0
        While i < Me.Controls.Count
            If TypeOf Me.Controls(i) Is MdiClient Then
                Return CType(Me.Controls(i), MdiClient)
            End If
            i = i + 1
        End While
        Return Nothing
    End Function

   Private WithEvents myMdiClient As MdiClient
   myMdiClient=FindMDIClient()
----------------------------------------------------

second,  i define two functions:
----------------------------------------------------
  Private Sub Mdi_OnPaint(ByVal sender As System.Object, ByVal e As System.Windows.Forms.PaintEventArgs)
        Dim c As Control = CType(sender, Control)
        Dim r1 As Rectangle = c.ClientRectangle
        r1.Width -= 4
        r1.Height -= 4
        Dim r2 As Rectangle = r1
        r2.Width -= 1
        r2.Height -= 1
        Dim f As Font = New Font("Tahoma", 50)
        Dim str As String = "my test string"
        Dim sf As New StringFormat
        sf.Alignment = StringAlignment.Far
        sf.LineAlignment = StringAlignment.Far
        e.Graphics.DrawString(str, f, New SolidBrush(Color.Blue), r1, sf)
        e.Graphics.DrawString(str, f, New SolidBrush(Color.Yellow), r2, sf)
    End Sub

    Private Sub Mdi_OnResize(ByVal sender As System.Object, ByVal e As System.EventArgs)
        Dim c As Control = CType(sender, Control)
        c.Invalidate()
    End Sub
--------------------------------------------------------------------

then, add handler to MdiClient object "myMdiClient"
------------------------------------------------------------------
   AddHandler myMdiClient.Paint, AddressOf Mdi_OnPaint
   AddHandler myMdiClient.Resize, AddressOf Mdi_OnResize
----------------------------------------------------------------------

but, when I use xtremeCommandBars control, i use this code to bound the handle of MDIClient to myCmdManager:
---------------------------------------------------------------------------
myCmdManager.SetMDIClient(FindMDIClient.Handle.ToInt32) 
note:  myCmdManager is axCommandBars
---------------------------------------------------------------------------

now, the event handler seems failure, the function "Mdi_OnPaint" "Mdi_OnResize" don't respond
 the event “Paint” and “Resize”.

but before i  bound the handle of MDIClient to myCmdManager, the program is run well.

how can i solve this problem, thank you!!!




Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.04 - http://www.webwizforums.com
Copyright ©2001-2021 Web Wiz Ltd. - https://www.webwiz.net