From: JCO on
I'm using VS2008 and C++ code.

I had to derive a class as (class CMyEdit : public CEdit) in order to trap
the the users key strokes and only allow numeric along with a decimal point.
I will need over 30 of these derived edit boxes on a dialog form. I don't
want to use the create feature at runtime because this makes it difficult to
place the edit box where I need them.

Is there any way to drag this derived edit box at design time as if I was
dragging a regular edit box from the toolbox?


From: Mikel Luri on
El 21/04/2010 7:28, JCO escribi�:
> I'm using VS2008 and C++ code.
>
> I had to derive a class as (class CMyEdit : public CEdit) in order to
> trap the the users key strokes and only allow numeric along with a
> decimal point. I will need over 30 of these derived edit boxes on a
> dialog form. I don't want to use the create feature at runtime because
> this makes it difficult to place the edit box where I need them.
>
> Is there any way to drag this derived edit box at design time as if I
> was dragging a regular edit box from the toolbox?
>
>
Well, you should be able to put normal CEdits using the resource editor,
then replace in the .cpp and .h the corresponding CEdit occurrences with
CMyEdit. That's what I usually do, and it works OK.

I've never done a control that you can put in the resource editor's
toolbox to drag it from there, but as far as I know, it involves
creating an ActiveX control.
From: Goran on
On Apr 21, 7:28 am, "JCO" <some...(a)somewhere.com> wrote:
> I'm using VS2008 and C++ code.
>
> I had to derive a class as (class CMyEdit : public CEdit) in order to trap
> the the users key strokes and only allow numeric along with a decimal point.
> I will need  over 30 of these derived edit boxes on a dialog form.  I don't
> want to use the create feature at runtime because this makes it difficult to
> place the edit box where I need them.

In the resource editor, just place a normal edit control from the
toolbox onto a dialog. Then...

Using the IDE:

Invoke "Add Variable..." command on the newly placed control (e.g.
right-click on it). "Add Member variable Wizard" should appear. In
"Variable type" field you can type any class name you want. In
"Category" combo, you should already have "Control". If not, pick
that.

Manually:

In CMyDialog class, add CMyEdit m_myEdit. In
CMyDialog::DoDataExchange, add DDX_Control(pDX, IDC_MY_EDIT,
m_myEdit). Frankly, that's not hard and you have 100% control on where
you put stuff and how it's typed in. That IMO beats +/- rigid IDE
automatism.

Goran.
From: Hector Santos on
JCO wrote:

> I'm using VS2008 and C++ code.
>
> I had to derive a class as (class CMyEdit : public CEdit) in order to
> trap the the users key strokes and only allow numeric along with a
> decimal point. I will need over 30 of these derived edit boxes on a
> dialog form. I don't want to use the create feature at runtime because
> this makes it difficult to place the edit box where I need them.
>
> Is there any way to drag this derived edit box at design time as if I
> was dragging a regular edit box from the toolbox?

AFAIK, the only way to do that is to create a control and add it the
tool box palette. I think for MFC, either a ActiveX or ATL/COM can be
used. Once you do that, then you can right click the Toolbox (create
your own tab first) and choose Item to add to it.

The other way, more manual, I am aware of is with using the class
wizard. After dropping the CEDIT control, right click it to create a
member for the edit box. At the point you have the option to set the
base class, in your case CMyEdit.

That is what I have in a few my applications where when I have a
serials of CHelpEdit, CHelpListBox, etc, classes, so when I drop of
the controls, all I need to do is change the base class,

CEdit mc_UserName; ----> CHelpEdit mc_UserName;

Have the problem with this method is getting the Class Wizard to
recognize CMyEdit existence. Creating it within the IDE is one way.
By just adding the *.H/CPP into the project wasn't. In that case,
under VS6.0, I had to manually edit the *.CLW file or delete it and
with the IDE recreate the *.CLW and include the *.H/CPP in its Add List.

I haven't gone this far with VS2005 (I assume VS2008 is the same), but
it was very easy to create .NET with COM exposure controls and add
them into the ToolBox. I had a lot of fun working and creating the
Property Editor for it.

--
HLS
From: Scott McPhillips [MVP] on
"JCO" <someone(a)somewhere.com> wrote in message
news:u4CL5NR4KHA.3844(a)TK2MSFTNGP05.phx.gbl...
> I'm using VS2008 and C++ code.
>
> I had to derive a class as (class CMyEdit : public CEdit) in order to trap
> the the users key strokes and only allow numeric along with a decimal
> point. I will need over 30 of these derived edit boxes on a dialog form.
> I don't want to use the create feature at runtime because this makes it
> difficult to place the edit box where I need them.
>
> Is there any way to drag this derived edit box at design time as if I was
> dragging a regular edit box from the toolbox?


Yes. Place all the controls at design time, exactly the same as if you were
not deriving. Then add a line like this to DoDataExchange for each edit
control:

DDX_Control(pDX, IDC_EDIT1, m_edit1);

where m_edit1 is a CMyEdit member variable.

--
Scott McPhillips [VC++ MVP]