Solved

Sending mouse events to an ActiveX control

Posted on 2003-11-19
5
380 Views
Last Modified: 2013-11-20
Hi

I have an MFC Dialog application with a single Dialog. In it is a Flash ActiveX control. I am using SetCapture and ReleaseCapture to send the mouse events to the dialog rather than to the control when the mouse is over it, and this is working fine.

What I need to do now is capture the WM_RBUTTONDOWN messages and deal with them myslef, but send the WM_LBUTTONDOWN and WM_MOUSEMOVE messages onto the control. I guess I need to use PostMessage to do this, but i don't know how to direct it to the control.

I am new to MFC programming and still trying to get to grips with how to reference things, but it appears to me that the whole dialog is one class, with one instance name and none of its contents (including the Flash control) have any instance names. How do I reference it?

Thanks for your help
0
Comment
Question by:completecontrol
  • 3
  • 2
5 Comments
 
LVL 44

Expert Comment

by:AndyAinscow
ID: 9779703
Use the SDK version where you supply the HWND of the window to receive the message
 ::PostMessage(hWnd_FLASHCONTROL,...)
0
 

Author Comment

by:completecontrol
ID: 9779915
How can I get the hWnd for it.

This might be a stupid question. I have done Win32 C programming before and there are window handles flying around all over the place. But in MFC it seems like they are purposely hidden from you.
0
 
LVL 44

Accepted Solution

by:
AndyAinscow earned 200 total points
ID: 9779982
I don't know how you have put this Flash control on your dialog so the following is a bit of guesswork.

GetDlgItem(IDC_FLASH)->GetSafeHwnd();

0
 

Author Comment

by:completecontrol
ID: 9780724
I've done it now. There is no need to use handles here, I used:

CWnd *FlashContolWnd = GetDlgItem(IDC_FLASH);
FlashControlWnd->PostMessage(WM_MOUSEMOVE, ...);
0
 
LVL 44

Expert Comment

by:AndyAinscow
ID: 9781001
The other way with the handles is also useful for posting to windows in other apps.
Glad you got it sorted.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

In this article, I'll describe -- and show pictures of -- some of the significant additions that have been made available to programmers in the MFC Feature Pack for Visual C++ 2008.  These same feature are in the MFC libraries that come with Visual …
Introduction: Load and Save to file, Document-View interaction inside the SDI. Continuing from the second article about sudoku.   Open the project in visual studio. From the class view select CSudokuDoc and double click to open the header …
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…

863 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

24 Experts available now in Live!

Get 1:1 Help Now