I have been trying to get my paletteset to remember it's closed location but cannot. I have tried using a ststic GUD when starting the Paletteset:
Dim MYGuid As Guid = New Guid("DC218198-EFDE-4802-AF55-C9613342F7A4")
M_ps = New Autodesk.AutoCAD.Windows.PaletteSet(String.Format("Rapid Layer", MYGuid))
I have tried saving the location value to the registry from the Close event of the palette, and then restoring it in the Command function.
I have also tried using the App settings to save and restore this value. Can someone help me out Please?
How can I get the Paletteset to remember it's last location?
Thanks
Matthew
Hi there,
Here's my pallet creation code:
System.Windows.Forms.UserControl Control = PalletControl; Pallet.Add("51F835F4-5369-43FA-B6E0-A8447DED66D1", Control); Pallet.MinimumSize = new System.Drawing.Size(300, 500); Pallet.Size = new System.Drawing.Size(507, 600); Pallet.StateChanged += new PaletteSetStateEventHandler(Pallet_StateChanged); Pallet.Location = new System.Windows.Point(X, y);
Please look at the last line. Here i set te position of the Palletset. But there is a getter aswell.
System.Windows.Forms.
Hi,
IMHO it will be saved by AutoCAD's WORKSPACE!
Open your palette, start command _WORKSPACE, save the workspace and the next time you start AutoCAD plus your application/palette the position should be where you left it.
- alfred -
Saving the workspace works If I leave the palette where it is. If I move the palete, close it, and then would like it to open where I left it, I need to save the the location out somewhere.
I found that I needed to subtract 1,000 from the DeviceIndependentLocation.y. ??
Thanks for your help.
Matthew
Public Sub PaletteCommand()
Dim MyPalette As MyLayerPalette = New MyLayerPalette()
' recover the location from the registry
Dim RegPLoca() As String = regapp.GetLocation("Rapid Layer").Split(",")
Dim PLoca As New Point
If SystemInformation.VirtualScreen.Width < RegPLoca.First Then
PLoca.X = 200
Else
PLoca.X = CInt(RegPLoca.First)
End If
If SystemInformation.VirtualScreen.Height < RegPLoca.Last Then
PLoca.Y = 200
Else
PLoca.Y = CInt(RegPLoca.Last)
End If
M_ps = New Autodesk.AutoCAD.Windows.PaletteSet("Rapid Layer", MYGuid)
M_ps.Add(MYGuid.ToString, MyPalette)
M_ps.Visible = True
M_ps.MinimumSize = New System.Drawing.Size(340, 140)
M_ps.DockEnabled = Autodesk.AutoCAD.Windows.DockSides.None
M_ps.Location() = PLoca
AddHandler M_ps.StateChanged, AddressOf Palette_Close
End Sub
Public Sub Palette_Close(ByVal sender As System.Object, ByVal e As System.EventArgs) 'Handles M_ps.StateChanged
RapidLayer.RapidLayerApp.regapp.SaveFormLocation(M_ps.Text, M_ps.DeviceIndependentLocation.X.ToString + "," & _
+ (M_ps.DeviceIndependentLocation.Y - 1000).ToString)
RemoveHandler M_ps.StateChanged, AddressOf Palette_Close
End Sub
Not sure if it helps, but this works for me...
myPaletteSet = New PaletteSet("Name", New Guid("C2C52873-B1D8-4D40-99F6-6ECEB4D932CC"))
Forgot to add...
Check out the "Restore Users Settings" section in the attached PDF from Mike Tuersley's AU class. I think it has everything you need to save the palette set settings.
Hope it helps!
If you create your own custom PaletteSet, AutoCAD can either remember its last size/location (when the PaleteSet has its identification supplied - a GUID), or AutoCAD do not remember its size/location at all (when there is no GUID id is provided).
Replies from Jeff_M and Dull_Blades clearly showed you how it is done: in the constructor, you supply a string value as name and a GUID as its id. Then AutoCAD will take care of persisting its location/size when the PaletteSet is closed.
However your 2 code sample showed here all are not supplying the GUID id, thus, AutoCAd does not remember your PaletteSet's size/location, so you are trying to reinvent a wheel here.
In your first post, you create your PaletteSet this way:
M_ps = New Autodesk.AutoCAD.Windows.PaletteSet(String.Format("Rapid Layer", MYGuid))
What does String.Format("XXXX", MyGuid) do is a mystry to me. But I am sure it would only produce a string value, at most.
So, it is like you do
M_ps = New Autodesk.AutoCAD.Windows.PaletteSet("xxxxxx").
That is, not GUID id is supplied. That is why Acad does not remember PaletteSet size/location for you.
So, as long as you use the same GUID correctly in the PaletteSet constructior, AutoCAD will recall its previous location/size. You do not painstakingly to try implement your own saving/calling code at all.
Norman Yuan
Can't find what you're looking for? Ask the community or share your knowledge.