Solved

How to pass WM_CTLCOLORBTN to a ActiveX Control

Posted on 1998-08-05
5
341 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Will your db performance match your db growth?

In Percona’s white paper “Performance at Scale: Keeping Your Database on Its Toes,” we take a high-level approach to what you need to think about when planning for database scalability.

Question has a verified solution.

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

Here is how to use MFC's automatic Radio Button handling in your dialog boxes and forms.  Beginner programmers usually start with a OnClick handler for each radio button and that's just not the right way to go.  MFC has a very cool system for handli…
Introduction: Finishing the grid – keyboard support for arrow keys to manoeuvre, entering the numbers.  The PreTranslateMessage function is to be used to intercept and respond to keyboard events. Continuing from the fourth article about sudoku. …
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.
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…

632 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