Re: Preventing pasting in a TEdit

From: Duncan McNiven (duncan_at_mcniven.net)
Date: 08/05/04


Date: Thu, 05 Aug 2004 06:56:03 +0100

On Wed, 04 Aug 2004 17:53:15 -0400, not@any.adr wrote:

>On Wed, 04 Aug 2004 19:06:55 +0100, Duncan McNiven <duncan@mcniven.net> wrote:
>
>>You are mistaken there. Take your C/C++ hat off for a moment and look at
>>things the Delphi way <g>
>
>I wouldn't know how to write the first line of code in C++ ... so lets not go
>there, ok?

Yet you are writing your code with mindset, ignoring the benefits of the
RAD tool you are using. For the vast majority of tasks that is simply
inefficient and not necessary. Fast forward a decade or so and come up
to the present.

>>You can add a method to handle the WM_PASTE message (yes, it _does_ go
>>to the TEdit) and prevent pasting that way.
>
>In the underying code that amounts to the same thing I was suggesting.

The effect is certainly the same, but it is achieved in quite a
different way. Anyone maintaining apps written with your approach would
find it harder to locate the code in question, would require a greater
knowledge of Windows, and risk introducing bugs into other
functionality. Your approach is expensive up front and asking for
problems and costs down the line.

>>Very easy to do, using very
>>obvious, isolated/self-contained code that is easy to maintain, and
>>avoids having to go anywhere near the windows procedure for the control.
>
>Well, actually not true... the TEdit control subclasses the underlying windows
>Edit control for you.

Exactly; you don't have to bother with all that crap yourself. You just
add a procedure to handle that one message. Very easy, very clear,
maintainable by any junior programmer who picks up your code without
risk to the mountain of code that would inevitably get put into WndProc
if you do anything major via the sub-classing route.

>>There has always been a better way using the Delphi approach.
>
>And, for many things, there has always been a better way THAN using the Delphi
>approach [grin]. No one approach or language is ever adequate to all tasks.

No tool is best for everything, obviously, but ignoring the benefits of
the tools you use is, shall we say, perverse. Then to say that the
normal Delphi approach used by just about every other Delphi programmer
on the planet is not possible ... oh I get it, this is a troll. OK, you
got me.

-- 
Duncan


Relevant Pages

  • Re: Windows Forms app in Win32
    ... could you host internet explorer inside your Win32 app and then use that in turn to host your winforms code? ... Other applications and dvelopment tools that are capable of hosting ActiveX controls, including the ActiveX test containers from versions of Visual Studio that are earlier than Visual Stueio .NET 2003, are not supported hosts for Windows Forms control. ... I now need to get my dll, the basis of which is a Windows Forms Control, to display in the Delphi app, but I'm having no luck, and have been hitting my head against brick walls for weeks and weeks. ...
    (microsoft.public.dotnet.framework.windowsforms)
  • Re: Windows Forms app in Win32
    ... "with the exception of Microsoft Internet Explorer & MFC, Windows Form ... are not supported hosts for Windows Forms control. ... has a complicated piece of software written in Delphi 5. ... and delphi 2007 doesn't support windows forms. ...
    (microsoft.public.dotnet.framework.windowsforms)
  • Windows Forms app in Win32
    ... "with the exception of Microsoft Internet Explorer & MFC, Windows Form ... controls are not supported in applications designed to host ActiveX control. ... complicated piece of software written in Delphi 5. ... and delphi 2007 doesn't support windows forms. ...
    (microsoft.public.dotnet.framework.windowsforms)
  • Re: My story with registrations
    ... With Delphi, there's more money spent, ... I use a corporation based Windows which doesn't needs to be activated. ... in the case that it does, it will suffer the same faith than Delphi. ... send a picture of the user using the software just to control that the ...
    (borland.public.delphi.non-technical)
  • Re: NTFS Effective Permissions?
    ... > values in previous posts that gave the specific ACE flag values in question ... No, I'm not ignoring it - I've got the print-out in front of me, but I ... this usually DOES show up in the GUI - if you check the ... are showing as "Generic full control". ...
    (microsoft.public.scripting.wsh)