Discussion:
Usage of WM_NCPAINT for DIALOG boxes
(too old to reply)
Arun Srinivasan
2005-09-24 04:08:01 UTC
Permalink
Hi all,
I wolud be of grt help if someone could give pseudo or sample code
for handling WM_NCPAINT.I have developed a toaster box application using a
Dialog box.I am able to change the background color and text color of the
Dialog box.Now i need to change the Dialog box caption color from default
blue fading and i also need to change the caption color font.I came across
this WM_NCPAINT to be used for such purpose but not a detailed or upto point
answer.

Can anyone help me out to do coloring of Dialog box title! : - (
--
With Rdgs
Christian ASTOR
2005-09-24 22:39:35 UTC
Permalink
Post by Arun Srinivasan
Hi all,
I wolud be of grt help if someone could give pseudo or sample code
for handling WM_NCPAINT.I have developed a toaster box application using a
Dialog box.I am able to change the background color and text color of the
Dialog box.Now i need to change the Dialog box caption color from default
blue fading and i also need to change the caption color font.I came across
this WM_NCPAINT to be used for such purpose but not a detailed or upto point
answer.
Can anyone help me out to do coloring of Dialog box title! : - (
You must also handle WM_NCACTIVATE, WM_ACTIVATE, WM_SETTEXT where you
call the same function (called by a PostMessage() or SendMessage() (for
WM_ACTIVATE)(on WM_USER + x) to draw on the window DC (GetWindowDC())
In this function, the drawing is classic (caption height with
SPI_GETNONCLIENTMETRICS, FillRect() or GradientFill(), SetBkMode() &
TRANSPARENT, DrawText())
Otherwise, you can remove the caption and draw yourself a custom caption
(eg like Babylon)
Kellie Fitton
2005-09-24 23:05:39 UTC
Permalink
Hi,

A side from the good answer you got from christian ASTOR, you can
also use the following API's to change/adjust the caption colours
of your dialogBox and the appearance of your deskTop screen:

SystemParametersInfo()
GetDesktopWindow()
GetSysColor()
SetSysColors()
InvalidateRect()
UpdateWindow()

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/sysinfo/base/systemparametersinfo.asp

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/winui/winui/windowsuserinterface/windowing/windows/windowreference/windowfunctions/getdesktopwindow.asp

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/sysinfo/base/getsyscolor.asp

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/sysinfo/base/setsyscolors.asp

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/gdi/pantdraw_7ano.asp

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/gdi/pantdraw_4zef.asp

Hope these information helps,

Kellie.
Arun Srinivasan
2005-09-25 03:58:01 UTC
Permalink
Thnx Christian and Kellie...Actually i am doing an toaster box
application..my code looks like this...
case WM_NCPAINT:
{
RECT rc1, rc2;
HDC hDC;
int x, y;
DefWindowProc( hwndDlg, uMsg, wParam, lParam );
hDC = GetWindowDC( hwndDlg );
GetWindowRect( hwndDlg, (LPRECT)&rc2 );


x = GetSystemMetrics( SM_CXSIZE ) +
GetSystemMetrics( SM_CXBORDER ) +
GetSystemMetrics( SM_CXFRAME );
y = GetSystemMetrics( SM_CYFRAME );
rc1.left = x;
rc1.top = y;

rc1.right = rc2.right - rc2.left - 2*x - GetSystemMetrics( SM_CXFRAME );
rc1.bottom = GetSystemMetrics( SM_CYSIZE );

SetBkMode(hDC, TRANSPARENT);
SetTextColor(hDC, RGB(255, 255, 0));
DrawText( hDC, (LPSTR)" MobileIP - Status", -1, (LPRECT)&rc1, DT_CENTER
);
ReleaseDC( hwndDlg, hDC );
break;
}

i am getting the dialog title as desired but it is flickkering...wht could
be the prob?
--
With Rdgs
Post by Christian ASTOR
Post by Arun Srinivasan
Hi all,
I wolud be of grt help if someone could give pseudo or sample code
for handling WM_NCPAINT.I have developed a toaster box application using a
Dialog box.I am able to change the background color and text color of the
Dialog box.Now i need to change the Dialog box caption color from default
blue fading and i also need to change the caption color font.I came across
this WM_NCPAINT to be used for such purpose but not a detailed or upto point
answer.
Can anyone help me out to do coloring of Dialog box title! : - (
You must also handle WM_NCACTIVATE, WM_ACTIVATE, WM_SETTEXT where you
call the same function (called by a PostMessage() or SendMessage() (for
WM_ACTIVATE)(on WM_USER + x) to draw on the window DC (GetWindowDC())
In this function, the drawing is classic (caption height with
SPI_GETNONCLIENTMETRICS, FillRect() or GradientFill(), SetBkMode() &
TRANSPARENT, DrawText())
Otherwise, you can remove the caption and draw yourself a custom caption
(eg like Babylon)
Kellie Fitton
2005-09-25 05:12:23 UTC
Permalink
Hi,

How are you handling the window message WM_ERASEBKGND, you should
just return TRUE to avoid any flickering.

Kellie.

Loading...