Sending or Posting message to other control

  • Thread starter Thread starter Leon Chi
  • Start date Start date
L

Leon Chi

I was a VC++ programer. Now I am learning C#. In VC, you can
use API SendMessage() or PostMessage() to send or post message
to other window. Are there some classes defined in .NET can do these?

Thanks.

Best Regards
Leon
 
Hi, Leon

In .Net it is expected that you use available methods and properties for
such tasks. So, the question is what you are trying to do?
For example, instead of SendMessage with WM_SETTEXT you can use Control.Text
property in assignment operator.

HTH
Alex
 
Alex

Thanks for your reply.

What I want to do is I want to Post a message to a control. For example. I
post a WM_SETFOCUS message to a control
in another control's WM_LBUTTONDOWN event handler. So after the mouse event
handled. the control can get focus.

Can you understand me?

Best Regards
Leon
 
Leon,

yes I think I get you. Once again - .Net Framework provides some level of
abstraction from underlying OS - be it Windows or something else. That's why
you should resort to Win32 API only when there are no standard methods and
properties, which can do same task.

HTH
Alex
 
Alex:

So I have to use API(s) to accomplish this? No way in .NET? If so, pity!

Leon
 
Leon,

your conclusion is not exactly right. You can use standard .Net methods for
this. Intercept mouse in MouseDown and set focus with Control.Focus and/or
Controll.Select methods.

HTH
Alex
 
AlexS:

I tried to do this but failed. When I called Control.Focus() and/or
Select() in MouseDown event handler. Control.Focus()
always return "false". So this way doesn't work. Is there other way?

Best Regards
Leon
 
Back
Top