Re: Venting on .NET
- From: Joseph M. Newcomer <newcomer@xxxxxxxxxxxx>
- Date: Mon, 09 Jan 2006 15:40:07 -0500
You have to move the event handlers because, obviously, the events from the control now
have to be interpreted in the context of the new application. This is not a major
complication. Any event handler unique to the control should be embedded in the control.
A classic example is OnCtlColor for a child control being any place other than in the
child control.
Otherwise, you are arguing that it is hard to reuse a CEdit because an OnChanged handler
has to be added to each app. Handlers are unique to the application. Similarly, there
are only two kinds of initialization: the initialization of the control which are
intrinsic to the control, which of course belong in the control subclass and are
automatically invoked, typically, a place to do this is in PreSubclassWindow, so the
initialization is carried with the subclass. The other form of initialization is the
intiialization of the application-senstitive aspects of the control, for example, the
range of a spin control, the contents of a CEdit, etc. and there is no way this
initialization could be carried across with the control, because it is entirely dependent
on the needs of the application. So initializing a listbox would make no sense for
application-specific initialization.
If you wanted to initialize a listbox to a set of baud rates, then the control should be
subclassed and the initialization done as part of the control. Bad programming style
would always interfere with proper reuse.
The real problem is moving stringtable resources. This would be greatly simplified if it
were possible to organize .rc files but #includes do not work right. The resource
compiler is one of the major problems, but it has remained unchanged for well over a
decade.
So we could argue that features like the ability to include multiple .res files, use
#includes properly in the resource editor, and so on, are what should be supported.
Microsoft's excuse is that we should use ActiveX, but it is so gratuitously complex that
the cost of hand-editing a .rc file is vastly lower than the cost of learning or using
ActiveX.
joe
On Mon, 09 Jan 2006 15:28:48 GMT, "David Ching" <dc@xxxxxxxxxxxxxxxxxxxxxx> wrote:
>"Joseph M. Newcomer" <newcomer@xxxxxxxxxxxx> wrote in message
>news:auq4s15u5hcgkld9ipufj7r10e28fr1t4l@xxxxxxxxxx
>> Why would there be custom initialization code in OnInitDialog? Could it
>> be that the
>> control was badly designed?
>>
>> A control is defined by its interface. Therefore, the only semantics on
>> OnClicked would
>> be for the container of the control. Anything unique to the control would
>> be built into
>> the control. Perhaps you are used to seeing badly-designed controls.
>>
>
>No, reusing a control involves more than just putting the control into a new
>project. You also have to move the initialization and event handlers also,
>if you want to reuse those. MFC makes it easy to move the control itself
>(although not any resources it depends on). It doesn't make it easy to move
>the initialization and event handlers.
>
>
>> As far as I could tell from my work with C#, and in talking to others that
>> use it, there
>> *is* no .rc file, so discussing it is pointless.
>
>If there is no .rc file involved, then that is a major advantage in the code
>reuse of C#.
>
>-- David
>
Joseph M. Newcomer [MVP]
email: newcomer@xxxxxxxxxxxx
Web: http://www.flounder.com
MVP Tips: http://www.flounder.com/mvp_tips.htm
.
- Follow-Ups:
- Re: Venting on .NET
- From: Daniel James
- Re: Venting on .NET
- From: David Ching
- Re: Venting on .NET
- References:
- Re: Venting on .NET
- From: David Ching
- Re: Venting on .NET
- From: Tom Serface
- Re: Venting on .NET
- From: Gerry Quinn
- Re: Venting on .NET
- From: Ian Semmel
- Re: Venting on .NET
- From: Daniel James
- Re: Venting on .NET
- From: Alexander Grigoriev
- Re: Venting on .NET
- From: David Ching
- Re: Venting on .NET
- From: Joseph M . Newcomer
- Re: Venting on .NET
- From: David Ching
- Re: Venting on .NET
- From: Joseph M . Newcomer
- Re: Venting on .NET
- From: David Ching
- Re: Venting on .NET
- Prev by Date: Re: TCHAR string?
- Next by Date: Re: Preprocessor definitions in Release Mode
- Previous by thread: Re: Venting on .NET
- Next by thread: Re: Venting on .NET
- Index(es):
Relevant Pages
|