I have a palette with a user control that I would like to format when it loads. (change sizes of some elements)
Problem is AutoCAD wants to automatically handle the palette layout and locks me out.
I had a similar problem in the past with a dialog. The solution there was to pass a "false" to the persistSizeAndPosition argument of ShowModalDialog.
Is there a solution for palettes? I like the fact that AutoCAD remembers a lot of the layout settings for me. I just want to tweak some settings when the palette loads.
If you don't use the constructor that takes a GUID, the palette will not
be persisted, and will not be reloaded when AutoCAD starts, but I don't
think that's a solution.
I have been using this for a pallette that I want reset to this state everytime the user enters the command. IIRC it requires references to System.Drawing and WindowsBase.
{ code }
mypallette = New Autodesk.AutoCAD.Windows.PaletteSet("pallette1")
mypallette.MinimumSize = New System.Drawing.Size(400, 300)
mypallette.Dock = DockSides.None
mypallette.DeviceIndependentLocation = New System.Windows.Point(200, 200)
{ code }
I am still working on the location. I am planning to check where the top left of the autocad window is and offset from there.
It took a bit of digging. This is working for me. Again, I want the palette to open to the same place and size when the user enters my command. I am using "Rect" which is a member of System.Windows. The autocad window is my start point so "hopefully" the palette can't get lost off screen when switching from dual to single monitors.
Dim acadx As Integer = Application.MainWindow.Location.X Dim acady As Integer = Application.MainWindow.Location.Y MsgBox("acad window is X " & acadx & " Y " & acady) Dim offset As Integer = 100 m_ps = New PaletteSet("position") Dim myrect As New Rect() myrect.X = acadx + offset myrect.Y = acady + offset 'the height and width are from the size of my user control (container) myrect.Width = 450 myrect.Height = 300 m_ps.InitializeFloatingPosition(myrect) m_ps.Visible = True m_ps.Dock = DockSides.None
When you create your instance of the the palletteSet or here is a example
PS =New PaletteSet("Pallete Set Name", New Guid("96A4562E-146C-48ac-98E6-EF4454C1D5A5"))
After you type new Guid
Select the tools menu and chose Create Guid click new copy paste and delete curly brace
In my case I don't want the application loaded automatically. And, I want it to always load as defined. It is only used maybe 10 times per year.
The Guid will not load it automatically the next time you netload it will return to its last position like if you hade it docked on the right
Here are settings u can use intellisense to see other
'''The numbers are the integer value for the PaletteSetStyles enum''''
m_ps.Style = PaletteSetStyles.ShowTabForSingle
m_ps.Style = 16
m_ps.Style = 4
m_ps.Style = 2
m_ps.Style = PaletteSetStyles.ShowCloseButton
m_ps.Style = PaletteSetStyles.SingleRowNoVertResize
m_ps.Style = PaletteSetStyles.SingleColDock
m_ps.Style = PaletteSetStyles.SingleRowDock
m_ps.Style = 30
m_ps.Opacity = 90
''''I think you need add a userControl to the pallette set before you call these''
m_ps.DockEnabled = DockSides.Right
m_ps.AutoRollUp = True