I suspect the problem is not the static variable, but
something your code may be doing in an event handler
that's triggered when the paletteset is undocked.
--
http://www.caddzone.com
AcadXTabs: MDI Document Tabs for AutoCAD 2004/2005/2006/2007
http://www.acadxtabs.com
wrote in message news:5492293@discussion.autodesk.com...
I have placed a paletteset reference as a shared private member of my User Control so that any Added controls can be added to it. This works fine on some machines but on others when i undock the palettes it disappears.
How does the GUID get stored in Autocad?
(I have generated a unique GUID).
(Because it load if i don't include a GUID when creating the paletteset but when i undock it disappears. If i use a GUID it will load the first time with the GUID and then when i undock it will not load at all even on the creation.)
Is it a problem if the paletteset is a Private Shared member of the user control?
Thanks in advance...
Evan
Public Class DrawingData
Inherits System.Windows.Forms.UserControl
'Associated file control on the second tab
Private Shared AssocCtrl As AssocFiles
'collection that reference's the User Control in the paletteset
'because you can't get the User control from the paletteset
Private Shared m_DwgDataCollection As Collection
'holds the number of "drawingdata" user controls on the paletteset
Private Shared DwgdataCount As Integer
'holds reference to the paletteset
Private Shared dps As Autodesk.AutoCAD.Windows.PaletteSet
'unique key for DwgdataCollection
Private ReadOnly m_DwgDataIndexKey As String
ReadOnly Property dwgdataindexkey() As String
Get
Return m_DwgDataIndexKey
End Get
End Property
Public Shared Property PaletteVisiable() As Boolean
Get
If Not dps Is Nothing Then
Return dps.Visible
End If
End Get
Set(ByVal value As Boolean)
If Not dps Is Nothing Then dps.Visible = value
End Set
End Property
'replace the brackets so it displays correct
[CommandMethod("DwgDataPalette")]_
Public Sub dwgPalette()
If dps Is Nothing Then
Dim myCtrl As Windows.Forms.UserControl = New DrawingData()
AddDrawingDataToPaletteSet(myCtrl)
End If
dps.Visible = True
dps.RolledUp = False
dps.Activate(0)
End Sub
Public Sub New()
' This call is required by the Windows Form Designer.
InitializeComponent()
' Add any initialization after the InitializeComponent() call.
Me.m_DwgDataIndexKey = Now.Date.Day.ToString & "-" & _
Now.TimeOfDay.TotalSeconds.ToString & "-" & Now.Millisecond.ToString
End Sub
Public Shared Sub AddDrawingDataToPaletteSet(ByVal myctrl As DrawingData)
If dps Is Nothing Then
CreatePaletteSet()
dps.Add("Drawing Data", myctrl)
Else
dps.Visible = False
End If
'add the next tab
If AssocCtrl Is Nothing Then
AssocCtrl = New AssocFiles()
End If
If m_DwgDataCollection Is Nothing Then m_DwgDataCollection = New Collection
m_DwgDataCollection.Add(myctrl, myctrl.dwgdataindexkey)
DwgdataCount += 1
dps.Visible = True
End Sub
Private Shared Sub CreatePaletteSet()
'use constructor with Guid so that we can save/load user data
dps = New Autodesk.AutoCAD.Windows.PaletteSet("Drawing Data", _
New Guid("{54631659-64D7-4a3c-A40C-2D08D9D0E523}"))
'dps.Style = 16 'PaletteSetStyles.NameEditable
'dps.Style = 4 'PaletteSetStyles.ShowPropertiesMenu
'dps.Style = 2 'PaletteSetStyles.ShowAutoHideButton
'dps.Style = 8 'PaletteSetStyles.ShowCloseButton
dps.Style = 30
dps.Opacity = 0
dps.MinimumSize = New System.Drawing.Size(210, 420)
End Sub
'UserControl overrides dispose to clean up the component list.
'replace the brackets so it displays correct
[System.Diagnostics.DebuggerNonUserCode()] _
Protected Overrides Sub Dispose(ByVal disposing As Boolean)
If disposing AndAlso components IsNot Nothing Then
components.Dispose()
If Not m_DwgDataCollection Is Nothing Then
If Not m_DwgDataCollection.Contains(Me.dwgdataindexkey) Then
'do some stuff to cleanup
End If
End If
End If
MyBase.Dispose(disposing)
End Sub
End Class
Message was edited by: Mahersy