Problem: Repaint MdiClient |
Post Reply |
Author | |
ws0411101
Newbie Joined: 18 November 2010 Status: Offline Points: 5 |
Post Options
Thanks(0)
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!!! |
|
Post Reply | |
Tweet
|
Forum Jump | Forum Permissions You cannot post new topics in this forum You cannot reply to topics in this forum You cannot delete your posts in this forum You cannot edit your posts in this forum You cannot create polls in this forum You cannot vote in polls in this forum |