Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 411
  • Last Modified:

Sending mouse events to an ActiveX control

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
completecontrol
Asked:
completecontrol
  • 3
  • 2
1 Solution
 
AndyAinscowCommented:
Use the SDK version where you supply the HWND of the window to receive the message
 ::PostMessage(hWnd_FLASHCONTROL,...)
0
 
completecontrolAuthor Commented:
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
 
AndyAinscowCommented:
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
 
completecontrolAuthor Commented:
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
 
AndyAinscowCommented:
The other way with the handles is also useful for posting to windows in other apps.
Glad you got it sorted.
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now