Help: Quick question on API call to find when a textbox changes.

M

Mick Smith

Hi Group,

I have a C# Windows Form textbox. I pass it's handle to an external
unmanaged dll (ie TextBox.Handle). The unmanaged dll sometimes
changes the text in the textbox. Because this is being done directly
by the textbox's handle it doesn't trigger .Net events. For example
textbox1.TextChanged is not fired when the unmanaged dll changes the
text in my textbox.

So, how can I use the windows API, or otherwise, to find out when the
text is changed in my textbox?

Mick
 
H

Herfried K. Wagner [MVP]

Mick --

Mick said:
I have a C# Windows Form textbox. I pass it's handle to an external
unmanaged dll (ie TextBox.Handle). The unmanaged dll sometimes
changes the text in the textbox. Because this is being done directly
by the textbox's handle it doesn't trigger .Net events. For example
textbox1.TextChanged is not fired when the unmanaged dll changes the
text in my textbox.

So, how can I use the windows API, or otherwise, to find out when the
text is changed in my textbox?

Untested: Create a class that inherits from
'System.Windows.Forms.TextBox', override 'WndProc' there and listen for
'WM_SETTEXT'. Then use this class instead of the .NET Framework's
textbox control.
 
J

Jeff Johnson

I have a C# Windows Form textbox. I pass it's handle to an external
unmanaged dll (ie TextBox.Handle). The unmanaged dll sometimes
changes the text in the textbox. Because this is being done directly
by the textbox's handle it doesn't trigger .Net events.

That's odd. I would think .NET is simply monitoring EN_UPDATE or EN_CHANGE,
both of which should still reach the owner (the .NET app) regardless of
who's manipulating the text box. But who knows what's going on under the
covers...?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top