Rectangle to registry

  • Thread starter Thread starter Michael Wong
  • Start date Start date
M

Michael Wong

Hi,

I am new to C# and would like to store a Rectangle structure to the
registry, using the following syntax:

reg.SetValue(szRectangle,rect);

but then I don't know how to retrieve the stored information to a Rectangle
again.

rect = reg.GetValue(szRectangle,rect);

Any idea?
 
Michael Wong said:
I am new to C# and would like to store a Rectangle structure to the
registry, using the following syntax:

reg.SetValue(szRectangle,rect);

I'm surprised that works at all, if it does.
but then I don't know how to retrieve the stored information to a Rectangle
again.

rect = reg.GetValue(szRectangle,rect);

Any idea?

The registry can't store arbitrary objects. I suggest you store the top
left and bottom right points as a pair of DWORD values each.
 
Thanks Jon,

I'll do it this way then.

Jon Skeet said:
I'm surprised that works at all, if it does.


The registry can't store arbitrary objects. I suggest you store the top
left and bottom right points as a pair of DWORD values each.
 
Derive a class from rectangle, e.g.
public class RegableRect : Rectangle
{
public static RegableRect GetFromReg()
{
....//(implement Jon' s suggestion here
}
public void SaveToReg()
{
...// "" ""
}
}
 
Back
Top