Rectangle to registry

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?
 
J

Jon Skeet [C# MVP]

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.
 
M

Michael Wong

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.
 
B

Bonj

Derive a class from rectangle, e.g.
public class RegableRect : Rectangle
{
public static RegableRect GetFromReg()
{
....//(implement Jon' s suggestion here
}
public void SaveToReg()
{
...// "" ""
}
}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top