CLI/C++ DesignerAttribute quesion

G

Guest

Hi,

I'm using CLI/C++ to develop a custom control in VC2005 IDE for fun. I wrote
a designer class inheriting from ControlDesigner. I overrode Initialize
method to set up initial control properties like:
void MyDesigner::Initialize(IComponent^ component)
{
this->component = component;
Plate^ plate = safe_cast<Plate^>(component);
Plate->PanSize = Size(140, 140);

ControlDesigner::Initialize(component);
}

I also overrode SelectionRules property to make the control not resizable on
the designing form.
virtual property System::Windows::Forms::Design::SelectionRules
SelectionRules
{
System::Windows::Forms::Design::SelectionRules get () override
{
return
System::Windows::Forms::Design::SelectionRules::Visible |
System::Windows::Forms::Design::SelectionRules::Moveable;
}
};

I then added the designer attribute to my plate class:
[Designer("PlateDesigner", "ControlDesigner")]
public ref class Plate : public Control

I compiled/linked the code allright. However, when I drag and drop it from
general Toolbox of IDE onto the form, the control doesn't have the initial
size as I set up (i.e. 140x140), and also the resizing little resizing boxes
still appear. I'm new to such designable custom control. Could anyone tell me
what right way to control initial value and designtime behaviour when a
designable custom control is dropped from toolbox?

Thanks
 
B

Ben Voigt [C++ MVP]

cjs said:
Hi,

I'm using CLI/C++ to develop a custom control in VC2005 IDE for fun. I
wrote
a designer class inheriting from ControlDesigner. I overrode Initialize
method to set up initial control properties like:
void MyDesigner::Initialize(IComponent^ component)
{
this->component = component;
Plate^ plate = safe_cast<Plate^>(component);
Plate->PanSize = Size(140, 140);

ControlDesigner::Initialize(component);
}

I also overrode SelectionRules property to make the control not resizable
on
the designing form.
virtual property System::Windows::Forms::Design::SelectionRules
SelectionRules
{
System::Windows::Forms::Design::SelectionRules get () override
{
return
System::Windows::Forms::Design::SelectionRules::Visible |
System::Windows::Forms::Design::SelectionRules::Moveable;
}
};

I then added the designer attribute to my plate class:
[Designer("PlateDesigner", "ControlDesigner")]
public ref class Plate : public Control

I compiled/linked the code allright. However, when I drag and drop it from
general Toolbox of IDE onto the form, the control doesn't have the initial
size as I set up (i.e. 140x140), and also the resizing little resizing
boxes
still appear. I'm new to such designable custom control. Could anyone tell
me
what right way to control initial value and designtime behaviour when a
designable custom control is dropped from toolbox?

This question is about .NET design time behavior in general, not C++/CLI in
particular. You will probably have better luck posting in
microsoft.public.dotnet.framework.windowsforms.designtime because someone
using a different .NET language may still be familiar with your problem.
 

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