Codejock Forums Homepage
Forum Home Forum Home > Codejock Products > ActiveX COM > Command Bars
  New Posts New Posts RSS Feed - Problem: Repaint MdiClient
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

Problem: Repaint MdiClient

 Post Reply Post Reply
Author
Message
ws0411101 View Drop Down
Newbie
Newbie


Joined: 18 November 2010
Status: Offline
Points: 5
Post Options Post Options   Thanks (0) Thanks(0)   Quote ws0411101 Quote  Post ReplyReply Direct Link To This Post Topic: Problem: Repaint MdiClient
    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!!!

Back to Top
 Post Reply Post Reply
  Share Topic   

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.04
Copyright ©2001-2021 Web Wiz Ltd.

This page was generated in 0.156 seconds.