Re: No TextBox method for clearing the selection

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance

From: Edward Diener (eddielee_at_tropicsoft.com)
Date: 10/01/04


Date: Fri, 1 Oct 2004 00:16:05 -0400

Joey Callisay wrote:
> I am not a C++ guy and I just read the documentation for WM_CLEAR
> method. Perhaps the functionality of the said method is not that
> common since one can just manipulate the Textbox's Text property, I
> don't really know.

It has nothing to do with C++. The .NET api is for all .NET languages and
Windows messages exist for all programming languages which use the Win32
API. Normally if a Windows message exists for a control, the .NET way is to
provide a method, or property, which encapsulates the same functionality as
was previously used in Win32 when sending the message to the control. I was
just pointing out that, in this case, there is no equivalent method or
property which enables one directly to delete the current selected text from
the control. In all other cases of TextBox there are methods, or properties,
which allow the programmer to directly achieve the same effect as sending a
particular message to the control. I found that really odd because if
usually MS is going to make things simple for a .NET programmer by replacing
Windows messages with methods or properties, they will do it consistently
for each Windows message to which the control normally reacts.

As an example the TextBox::Copy() method does the same thing as sending the
WM_COPY message to the edit control. If you look you will see this is the
same for all edit control messages, including the WM_ and EM_ set except for
WM_CLEAR, which has no direct analogue. Of course the indirect analogue,
changing the Text with a new string which contains the old string but with
the selected text removed, works fine but this sort of manual calculation is
something which a good API normally avoids if there is a direct equivalent.



Relevant Pages

  • Re: No TextBox method for clearing the selection
    ... and thanks for clearing my misconception about Win32 api and C++ ... > Windows messages exist for all programming languages which use the Win32 ... > was previously used in Win32 when sending the message to the control. ...
    (microsoft.public.dotnet.framework.windowsforms.controls)
  • Re: Windows message sent to control
    ... > ControlStyles.CacheText control style. ... WM_SETTEXT is just one of many Windows messages which I ... I do not want to worry what my base class does for any given Windows ... I have a derived control in which I only allow ...
    (microsoft.public.dotnet.framework)
  • Re: SendKeys cannot run inside this application
    ... from one control to another control) was not working. ... How are you launching the .Net Form? ... Id suggest using the TextBox's SelectNextControl method instead. ... {"SendKeys cannot run inside this application because the application is not handling Windows messages. ...
    (microsoft.public.dotnet.languages.vb)
  • Re: Windows message sent to control
    ... >> If a Windows message is sent directly to control, does the framework ... I am interested, in general, whether .net picks up Windows messages ... I have a derived control in which I only allow the text ...
    (microsoft.public.dotnet.framework)
  • Re: Asking Windows Specific Questions
    ... I would like to "launch" a file using the system's default handler (identical functionality to double clicking a file in explorer or putting file in run menu) I can use Runtime.getRuntime.execbut I believe that has high overhead, and it prompts if you want to open the file. ... interacts which interacts with a windows program called winamp. ... If I could send windows messages from my program directly the only command line interaction I would need would be to invoke winamp if it is not already running. ...
    (comp.lang.java.programmer)