Solved

WM_CTLCOLORMSGBOX - How?

Posted on 1997-11-03
7
317 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
  • 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
Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

 
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

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Multi Table MS Access Query 5 76
error email attachment VB2010 5 39
Problem to packaging 1 91
Where did System.Data.Objects go? 2 27
This tutorial is about how to put some of your C++ program's functionality into a standard DLL, and how to make working with the EXE and the DLL simple and seamless.   We'll be using Microsoft Visual Studio 2008 and we will cut out the noise; that i…
This article describes how to programmatically preset the "Pages per Sheet" option that's available with most printer drivers.   This setting lets you do "n-Up" printing, where two, four, or more pages are printed on each sheet of paper. If your …
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…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…

777 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