Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

I find that the icon of a maximised MDI child form does not show correctly until the MDI form is resized. Instead you get the standard icon with a red, blue and yellow box showing. Only when the MDI form is resized is this refreshed. This problem occurs whether the icon is set at design time or on loading the child form. The best solution I can come up with is the truly awful:

 

  Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
       Timer1.Enabled = True
   End Sub

   Private Sub Timer1_Tick(ByVal sender As Object, ByVal e As System.EventArgs) Handles Timer1.Tick
       MDIParent1.Width = MDIParent1.Width + 1
       MDIParent1.Width = MDIParent1.Width - 1
       Timer1.Enabled = False
   End Sub

Any better ideas?

Posted

Hi,

 

What version of Visual Studio are using?

 

What are the steps you follow to add an icon to your form? Do you use code, the form designer or the App.ico? Give us a little more information about how to recreate your problem.

 

Thanks,

kmg

You're either a one or a zero. Alive or dead.
Posted

Visual Studio Express 2005. If you have this then I'm sure you can replicate the problem by adding an MDI form through the Project/Add Windows Form menu and setting an icon in the child form at design time. I'm not using the AppIcon as I want that to be different.

 

As I say, it happens whether I set the icon in the form designer or in code. As you'll know, the icon appears in the MDI form menu strip when the child form is maximised. Since making the original post I've discovered that you can solve the problem by making this menu strip invisible and then visible again after loading the form, so slightly better than my first solution but still not very good.

Posted

This works OK:

 

 Private Sub ShowNewForm(ByVal sender As Object, ByVal e As EventArgs) Handles NewToolStripButton.Click

       Dim q As New Form1

       q.WindowState = FormWindowState.Maximized
     
       q.MdiParent = Me
      
       q.Show()
      
       If TypeName(Me.MenuStrip.Items(0)) = "SystemMenuItem" Then
            Dim t As Long
            t = Me.MenuStrip.Height
           Me.MenuStrip.Items(0).Image = q.Icon.ToBitmap
           Me.MenuStrip.Height = t    'otherwise it goes too big.
       Else
           Debug.Print("SystemMenuItem not found.")
       End If

   End Sub

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...