Duplicate Windows Appearing When App is Runned

I’m having a weird problem. I have two windows, Window1 and Window2. On Window2’s Activate method, I have code which renders the ListBox with for example ColumnCount and HasHeading. During run time, when I open Window2 via my Menu Handler, two copies of Window2 appear. The first one (hidden behind the second) does not have the ListBox rendered, meanwhile, the second copy (above the first), does have the ListBox rendered.

Update: Oh, when I remove the rendering code, only one Window2 appears, but paragraph one occurs when I have the rendering code enabled.

Code:

MusicToolWindow.MusicFileProperties.HasHeading = True MusicToolWindow.MusicFileProperties.ColumnCount = 2 MusicToolWindow.MusicFileProperties.Heading(0) = "Property Name" MusicToolWindow.MusicFileProperties.Heading(1) = "Property Value"

Any ideas? Project file can be supplied if needed. Thanks,
Shane.

Sound like Implicit Instantiation. Is there more code? Like w = New MusicToolWindow?

Would make sense if your menuhandler is creating a new instance like Tim said, and the rendering code is creating an implicit instance by referring to the window class rather than using self.
if the window class is named MusicToolWindow.
try
self.MusicFileProperties.HasHeading = True
etc…

Fixed. See quote below.

[quote=56168:@jim mckay]Would make sense if your menuhandler is creating a new instance like Tim said, and the rendering code is creating an implicit instance by referring to the window class rather than using self.
if the window class is named MusicToolWindow.
try
self.MusicFileProperties.HasHeading = True
etc…[/quote]

Thanks!
I fixed the code by taking the rendering code and inserting it into the Menu Handler.

[code] Dim MTWindow As New MusicToolWindow
MTWindow.MusicFileProperties.HasHeading = True
MTWindow.MusicFileProperties.ColumnCount = 2
MTWindow.MusicFileProperties.Heading(0) = “Property Name”
MTWindow.MusicFileProperties.Heading(1) = “Property Value”
MTWindow.Show

Return True[/code]

Code now opens only one MusicTool Window.

Thanks for the help!