Search:
Namespaces
Discussions
.NET v1.1
Feedback
Overriding WndProc in custom TextBox
Messages
Related Types
This message was discovered on
microsoft.public.dotnet.framework.compactframework
.
Responses highlighted in red are from those people who are likely to be able to contribute good, authoratitive information to this discussion. They include Microsoft employees, MVP's and others who IMHO contribute well to these kinds of discussions.
Post a new message to this list...
PeterB
Hi!
I'm trying to override WndProc( ref
Message
m) in my custom
TextBox
control.
Unfortunately it seems like the System.Windows.Forms.
Message
class is not
available in CF. Is there a was to reference this class anyway?
I tried referencing Microsoft.WindowsCE.Forms but I get the following
compile error:
WndProc(ref Microsoft.WindowsCE.Forms.Message)': no suitable method found to
override
I am not sure whether it is impossible to override the WndProc method in
this context or if I'm just using the wrong
Message
definition.
Ideas?
Thanks!
/ Peter
Reply to this message...
Peter Foot [MVP] (VIP)
You cannot override the WndProc in the Compact Framework. You can use the
Smart Device Framework ApplicationEx object to implement an
IMessageFilter
to capture incoming windows messages for your application.
www.opennetcf.org/sdf/
Peter
--
Peter Foot
Windows Embedded MVP
www.inthehand.com | www.opennetcf.org
Do have an opinion on the effectiveness of Microsoft Windows Mobile and
Embedded newsgroups? Let us know!
https://www.windowsembeddedeval.com/community/newsgroups
"PeterB" <
Click here to reveal e-mail address
> wrote in message
news:
Click here to reveal e-mail address
...
[Original message clipped]
Reply to this message...
PeterB
Well... it's not an application, so using ApplicationEx (which is a great
asset though) is not an option :-)
What I want to do is capture the WM_PASTE message to prevent pasting to the
textbox, any suggestions on how this could be done without overriding
WndProc?
regards,
Peter
"Peter Foot [MVP]" <
Click here to reveal e-mail address
> skrev i meddelandet
news:%23%
Click here to reveal e-mail address
...
[Original message clipped]
Reply to this message...
Paul G. Tobey [eMVP]
Your code is not an application? Are you building a library for other
applications to use?
Paul T.
"PeterB" <
Click here to reveal e-mail address
> wrote in message
news:
Click here to reveal e-mail address
...
[Original message clipped]
Reply to this message...
PeterB
I am creating a custom
TextBox
Control, so yes I am making a library of
custom controls for our company :-)
So I want to handle the paste functionality within the
TextBox
control to
prevent it from happening. Is this possible without WndProc?
/ Peter
"Paul G. Tobey [eMVP]" <ptobey no spam AT no instrument no spam DOT com>
skrev i meddelandet news:
Click here to reveal e-mail address
...
[Original message clipped]
Reply to this message...
Paul G. Tobey [eMVP]
I don't see any way to do it without subclassing the control, no.
Paul T.
"PeterB" <
Click here to reveal e-mail address
> wrote in message
news:
Click here to reveal e-mail address
...
[Original message clipped]
Reply to this message...
PeterB
Paul,
I am not sure I understand you correct here, I am subclassing the
TextBox
class into my own TextBoxInt class. I am overriding the KeyPress method to
make sure only valid characters are entered. However, the user can still
copy/paste illegal characters into the TextBoxInt, which is why I need to
prevent that functionality (or handle it in some way).
But as WndProc isn't available it seems hard to intercept any pasting into
the custom TextBoxInt control. A workaround, which is very ugly, is to
override the TextChange event and validate the text when it changes. In this
way it is possible to catch a paste and if the new text is invalid, fix the
text back to the previous state (which was valid).
thanks,
Peter
"Paul G. Tobey [eMVP]" <ptobey no spam AT no instrument no spam DOT com>
skrev i meddelandet news:
Click here to reveal e-mail address
...
[Original message clipped]
Reply to this message...
Chris Tacke, eMVP
Yep. and unfortunately I don't think there's much option other than your
workaround. Without function pointer support, you're kinda stuck.
-Chris
"PeterB" <
Click here to reveal e-mail address
> wrote in message
news:eRt47t%
Click here to reveal e-mail address
...
[Original message clipped]
Reply to this message...
PeterB
Ok, thanks for the help guys!
Would it be possible to make the textchange event occur before the actual
re-painting of the textbox. What I want to achieve is to remove the
flashing, non-wanted characters from the paste.
Also, sometimes I add special characters (for example hyphen/minus sign to
make the number in the textbox negative), the cursor is then moved to one
position and then back to the original position. Would it be possible to
prevent this flashing as well?
/ Peter
"Chris Tacke, eMVP" <ctacke[at]OpenNETCF_dot_org> skrev i meddelandet
news:
Click here to reveal e-mail address
...
[Original message clipped]
Reply to this message...
Chris Tacke, eMVP
Override OnPaint and use a synchronization object like a Monitor wait or
some such to serialize the repaint after you handle the textchange.
-Chris
"PeterB" <
Click here to reveal e-mail address
> wrote in message
news:
Click here to reveal e-mail address
...
[Original message clipped]
Reply to this message...
PeterB
Thanks for the idea Chris, however, it seems like you can't override OnPaint
for a custom control inherited from
TextBox
:-(
If I look at your TextBoxEx, it does inherit from
TextBox
and override
OnPaint but for design support (or do I misunderstand the code?). Anyway, I
can't get OnPaint to fire in my own code.
I guess I could inherit from Control class instead but I get the impression
this would demand a lot of extra work. I'm having a look at that right now..
/ Peter
"Chris Tacke, eMVP" <ctacke[at]OpenNETCF_dot_org> skrev i meddelandet
news:
Click here to reveal e-mail address
...
[Original message clipped]
Reply to this message...
Chris Tacke, eMVP
You're probably right. There are definitely a few things with Controls I'd
change if I had my way.
-Chris
"PeterB" <
Click here to reveal e-mail address
> wrote in message
news:
Click here to reveal e-mail address
...
> Thanks for the idea Chris, however, it seems like you can't override
OnPaint
[Original message clipped]
Reply to this message...
System.Web.UI.MobileControls.TextBox
System.Web.UI.WebControls.TextBox
System.Windows.Forms.IMessageFilter
System.Windows.Forms.Message
System.Windows.Forms.TextBox
Ad
MBR BootFX
Best-of-breed application framework for .NET projects, developed by Matthew Baxter-Reynolds and MBR IT
Copyright © Matthew Baxter-Reynolds 2001-2008. '.NET 247 Software Development Services' is a trading style of MBR IT Solutions Ltd.
Contact Us
-
Terms of Use
-
Privacy Policy
-
www.dotnet247.com