默认NCPaint会覆盖Windows 8或更高版本中的自定义绘制 [英] Default NCPaint overrides custom painting in Windows 8 or higher

查看:112
本文介绍了默认NCPaint会覆盖Windows 8或更高版本中的自定义绘制的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在标题栏的角落画一个矩形。如果在我的绘画之前调用默认框架非客户端绘制,我无法在Windows 8或更高版本的标题栏上看到矩形。但是,同样适用于Windows 7.如果我在下面的NCPaint中注释
的Default()方法,那么我可以在标题栏上看到绘制的矩形。以下是代码:

I want to draw a rectangle in the corner of the title bar. I am unable to see the Rectangle on title bar in Windows 8 or higher if default framework non client paint is called before my painting. However, the same works fine with Windows 7. If I comment the Default() method inside NCPaint below then I can see the rectangle drawn on title bar. Here is the code:

void CCustomDlg :: OnNcPaint()

{

//如果您只更改菜单栏,请让框架首先绘制&bbsp
//窗口

默认();
$


CWindowDC dc(this);

CRect rc;

GetWindowRect(rc);
$


//菜单栏(非客户区)的大小较小

rc.bottom = GetSystemMetrics(SM_CYCAPTION) + GetSystemMetrics(SM_CYFRAME);
$


//按钮区域

CRect closeRect;

closeRect.left = rc。 right - rc.left - 20;

closeRect.top = GetSystemMetrics(SM_CYFRAME);

void CCustomDlg::OnNcPaint()
{
// If you only change the menu bar, let the framework draw 
// the window first
Default();

CWindowDC dc(this);
CRect rc;
GetWindowRect(rc);

// Size of menu bar (non-client area) is smaller
rc.bottom = GetSystemMetrics(SM_CYCAPTION) + GetSystemMetrics(SM_CYFRAME);

// Area for buttons
CRect closeRect;
closeRect.left = rc.right - rc.left - 20;
closeRect.top = GetSystemMetrics(SM_CYFRAME);

        closeRect.right = rc.right - rc.left - 5;

closeRect.bottom = GetSystemMetrics(SM_CYSIZE);



//绘制矩形 

CBrush br;

COLORREF clr(RGB(255,0,0));

br.CreateSolidBrush(clr);

dc.FillRect(closeRect,&brie);



ReleaseDC(& dc);

}

        closeRect.right = rc.right - rc.left - 5;
closeRect.bottom = GetSystemMetrics(SM_CYSIZE);

// draw rectangle 
CBrush br;
COLORREF clr(RGB(255,0,0));
br.CreateSolidBrush(clr);
dc.FillRect(closeRect, &br);

ReleaseDC(&dc);
}

如果我按框架评论默认的NC绘图,那么不同主题的帧有差异。我希望我的绘图后面的默认NC绘图在Windows 8或更高版本中可以正常工作,就像Windows 7一样。请建议。

If I comment the default NC drawing by framework then there is difference in the frames in different themes. I would like the default NC drawing followed by my drawing to work fine in Windows 8 or higher which is the case with Windows 7. Please suggest.

推荐答案

没有评论默认?如果我在NCPaint开始时没有评论Default方法调用,我就无法看到它。

Without commenting Default? I am not able to see it if I dont comment Default method call at the begining of NCPaint.

有没有更简单的方法来解决这个问题?

Is there a simpler way of resolving this issue?

我也看到了  GetSysColor(COLOR_ACTIVECAPTION)的问题。应用Windows主题时,这不会返回Windows 10中的默认白色背景。它适用于高对比度主题。

Also I see problem with GetSysColor(COLOR_ACTIVECAPTION). This does not return the default white background in Windows 10 when the Windows theme is applied. It works with high contrast themes though.


这篇关于默认NCPaint会覆盖Windows 8或更高版本中的自定义绘制的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆