Sending messages to ActiveX user interface controls from a different thread 
Author Message
 Sending messages to ActiveX user interface controls from a different thread

My apologies in advance if this is not a pertinent place for this question.
My question is two part:
1) Can messages be sent to ActiveX UI controls in a dialog window to
simulate a mouse-click.
2) What if any are the complications introduced by attempting to send the
above message from a seperate thread.

Here is some background:
I am using some ActiveX user interface controls from National Instruments
Measurement Studio 1.0, the CW++ (Tools for C++) portion along
with MS Visual C++ 6.  I have an MFC application that has several
modeless dialogs containing ActiveX user interface controls.

The application also establishes a CAyncSocket-based server.  Each socket
session is handed to a seperate thread and CAsyncSocket upon the 'OnAccept'
call of the main listening socket. Some of the messages received through the
sockets interface are intended to have the same action as a user
manipulating one or more of the CW++ user interface controls.  For example,
I have a [CNiButton based] control for a camera shutter on one of the
dialogs with two states, Open and Closed.  The control is really a fancier
type of CButton done using ActiveX.  One of the messages receivable on the
socket interface is to Open or Close the shutter.

Is there a method to send a message to the ActiveX control that simulates
the
mouse clicking the button to the Open or Closed state?  If so, then I can
always drive the control of the actual shutter hardware frome the events
generated from the control changing between the Open and Closed state.

I have similar needs with other ActiveX user interface controls in the
application.

TIA,
Mark Greenman
Space Dynamics Laboratory
Utah State University
Logan, UT




Sat, 26 Apr 2003 03:00:00 GMT  
 Sending messages to ActiveX user interface controls from a different thread

Quote:

> My apologies in advance if this is not a pertinent place for this question.
> My question is two part:
> 1) Can messages be sent to ActiveX UI controls in a dialog window to
> simulate a mouse-click.
> 2) What if any are the complications introduced by attempting to send the
> above message from a seperate thread.

> Here is some background:
> I am using some ActiveX user interface controls from National Instruments
> Measurement Studio 1.0, the CW++ (Tools for C++) portion along
> with MS Visual C++ 6.  I have an MFC application that has several
> modeless dialogs containing ActiveX user interface controls.

> The application also establishes a CAyncSocket-based server.  Each socket
> session is handed to a seperate thread and CAsyncSocket upon the 'OnAccept'
> call of the main listening socket. Some of the messages received through the
> sockets interface are intended to have the same action as a user
> manipulating one or more of the CW++ user interface controls.  For example,
> I have a [CNiButton based] control for a camera shutter on one of the
> dialogs with two states, Open and Closed.  The control is really a fancier
> type of CButton done using ActiveX.  One of the messages receivable on the
> socket interface is to Open or Close the shutter.

> Is there a method to send a message to the ActiveX control that simulates
> the
> mouse clicking the button to the Open or Closed state?  If so, then I can
> always drive the control of the actual shutter hardware frome the events
> generated from the control changing between the Open and Closed state.

> I have similar needs with other ActiveX user interface controls in the
> application.

> TIA,
> Mark Greenman
> Space Dynamics Laboratory
> Utah State University
> Logan, UT



The general solution is to call the SendInput API with an appropriate mouse
position and a button down and button up event.  Old versions of Windows do not
have this API.

If you have the hwnd of the control you can probably fake it with:

::PostMessage(hwndControl, WM_COMMAND, MAKEWPARAM(ID_BUTTON, BN_CLICKED),
(LPARAM)m_hWnd);

Doing these things from a separate thread should be fine with no surprises.

--
Scott McPhillips [VC++ MVP]



Sat, 26 Apr 2003 03:00:00 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. How to send a message to a windowless ActiveX control from its worker thread

2. User-Interface Thread Messaging Problem

3. Posting Messages to user-interface threads

4. Problems posting messages to a User-Interface Thread???????????

5. Problem with ActiveX control in a different thread

6. Multithreading, User Interface Threads, SetWindowText/SendMessage, Thread Hangs

7. How to Send messages from worker thread to main thread

8. C++ MSMQ API Receive Blocks Send on different threads

9. Send message to objects of different type

10. CSocket: recieve/send in different threads

11. Can different threads use same Interface Pointer?

12. How do I send a user message to a windows process

 

 
Powered by phpBB® Forum Software