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

  • Thread starter Thread starter Mick Smith
  • Start date Start date
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
 
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.
 
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...?
 
Back
Top