Solved

WM_CTLCOLORMSGBOX - How?

Posted on 1997-11-03
7
335 Views
Last Modified: 2013-12-03
Unfortuinately it doesn't work in my app.
50 Points for a working description or
source code.

thanks
0
Comment
Question by:Onkel
[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
  • 4
  • 3
7 Comments
 
LVL 22

Expert Comment

by:nietod
ID: 1408150
Just convert the WParam to a DCH.  Set the foreground and background colors and return a brush handle.

case WM_CTLCOLORMSGOX:
{
   HDC    DCHnd  = (HDC) WParam;
   HBRUSH BckBrh = CreateSolidBrush(RGB(0,255,0));  // Green background brush.
   SetTextColor(DCHnd,RGB(255,0,0)); // Set red text.
   SetBkColor(DCHnd,RGB(0,255,0));   // Set green background.

   return (LRESULT) BckBrh;
}
0
 
LVL 22

Expert Comment

by:nietod
ID: 1408151
If that isn't enough, post more info.  i.e. what are your trying to do and what is happening.  Posting source code is always good.
0
 

Author Comment

by:Onkel
ID: 1408152
Well, your example looks almost like my code.

The main question seems to be where to place this message handling.
Usually messages in the MainWndProc do not return anything.
Another question is which MessageBox(I use some very regular ones
created with MessageBox(hwnd,text,captiontext,MB_OK);)
will show the color change. I tried various.
My aim are message boxes which use a selfdefined color.

I raised the reward to 55 points, that's all I have. :-)


0
PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

 
LVL 22

Expert Comment

by:nietod
ID: 1408153
You place the code in the window procedure of the window that owns the message box.  The owner window will get the message and the lParam will be the handle to the message box.  You can then test the lParam to see if it is one of the message box's you want to color differently.  If so, handle the message.  If not pass it on to the default window procedure.

I have to warn you, I've never used this, but it seems straightforeward.

As for messages in the main window procedure not returning anything.  That's not true.  Or I'm missunderstanding you.

0
 

Author Comment

by:Onkel
ID: 1408154
I will cite you:
"You can then test the lParam to see if it is one of the message box's you want to color differently."

But how do I do that?
My message boxes do not return any handle.
There are - as I mentioned before - various message boxes
which are all owned by the main window.
I think that I have to accept that all of them will
have the same color. But well, that's not a problem.



0
 
LVL 22

Accepted Solution

by:
nietod earned 50 total points
ID: 1408155
if there is only one message box up at a time, use a global variable or one related to the owner window to determine how to handle message box.  

If message boxes can be poping up simultaneously, you can use the handle to find out things about the message box.  You can get the title for example.  

Its not a great way of going things, but if it works, its pretty easy.  If it doesn't work, create your own message box from scratch.  (That's what I do.)  Its not hard to do and much more flexible.  I can give more details, if you need.
0
 

Author Comment

by:Onkel
ID: 1408156
WM_CTLCOLORMSGBOX does not occur in the main window
procedure. I checked that with a message box ;-)
and a message spy.
So it looks like I have to create a dialog finally.
Thanks for your help.


0

Featured Post

Instantly Create Instructional Tutorials

Contextual Guidance at the moment of need helps your employees adopt to new software or processes instantly. Boost knowledge retention and employee engagement step-by-step with one easy solution.

Question has a verified solution.

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

This article shows how to make a Windows 7 gadget that extends its U/I with a flyout panel -- a window that pops out next to the gadget.  The example gadget shows several additional techniques:  How to automatically resize a gadget or flyout panel t…
For a while now I'v been searching for a circular progress control, much like the one you get when first starting your Silverlight application. I found a couple that were written in WPF and there were a few written in Silverlight, but all appeared o…
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
There's a multitude of different network monitoring solutions out there, and you're probably wondering what makes NetCrunch so special. It's completely agentless, but does let you create an agent, if you desire. It offers powerful scalability …

690 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