Solved

How to pass WM_CTLCOLORBTN to a ActiveX Control

Posted on 1998-08-05
5
326 Views
Last Modified: 2013-11-19
I'm trying to send a WM_CTLCOLORBTN message to a Active Control.  That control has been created by the MFC Control Wizard.
Using other application, I'm calling the PostMessage to send WM_CTLCOLORBTN msg to the ActiveX Control, but it isn't receiving the msg.
I've put the ON_MESSAGE( WM_CTLCOLORBTN, OnColorBtn ) statement inside the Control and implemented the OnColorBtn() method.
I've seen that no message arrived in OnColorBtn.
Important: I did the following test:
  I replaced WM_CTLCOLORBTN by a WM_USER + xxx and it worked.  So, it seems that there's some trick to MFC ActiveX work with WM_CTLCOLORBTN.
0
Comment
Question by:edsont
  • 3
5 Comments
 
LVL 15

Expert Comment

by:Tommy Hui
ID: 1320274
Instead of using ON_MESSAGE(WM_CTLCOLORBTN), try using

 ON_MESSAGE(OCM_CTLCOLORBTN, xxx)

instead.
0
 

Author Comment

by:edsont
ID: 1320275
I've already tried using ON_MESSAGE(OCM_CTLCOLORBTN, xxx) but
that solution didn't work in my case.

Could it be caused by the options I've checked in ActiveX ControlWizard ?

    Normal features I've checked:

         [ ] Activates when visible
         [x] Invisible at runtime
         [ ] Available in "Insert Object" dialog
         [ ] Has an "About" box
         [x] Acts as a simple frame control

    Advanced ActiveX enhancements:

         [x] Windowless activation
         [ ] <Other options are unchecked>

If the OCM_CTLCOLORBTN isn't arriving to my ActiveX Control because of the options I've checked, what could I do to fix the problem ?

Regards.

0
 

Author Comment

by:edsont
ID: 1320276
Adjusted points to 150
0
 
LVL 8

Accepted Solution

by:
Answers2000 earned 150 total points
ID: 1320277
You can't do this because WM_CTLCOLOR messages are actually sent to the parent of the control (in the app rather than the ActiveX) and then under normal circumstances reflected.

Get round this by using a stock property in the ActiveX control you develop to control the color of display.
0
 

Author Comment

by:edsont
ID: 1320278
Answers2000,

Could you give an example of your proposed solution ?

Regards.

0

Featured Post

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

Suggested Solutions

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 …
Introduction: Hints for the grid button.  Nested classes, templated collections.  Squash that darned bug! Continuing from the sixth article about sudoku.   Open the project in visual studio. First we will finish with the SUD_SETVALUE messa…
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.
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …

759 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

23 Experts available now in Live!

Get 1:1 Help Now