在onSize一起改变对话框指定控件的位置和大小,譬如拉大listctrl,移动button紧贴右下角。
在显示属性设置了“移动窗口时显示窗口内容”后,为了避免界面的闪烁,我重载了OnEraseBkgnd 如下:BOOL CResourceDlg::OnEraseBkgnd(CDC* pDC)
{
// TODO: 在此添加消息处理程序代码和/或调用默认值
RECT rcCtrl = {0};
CWnd* pwndCtrl = GetWindow(GW_CHILD);
while(pwndCtrl)
{
if(IsWindow(pwndCtrl->m_hWnd)&&pwndCtrl->IsWindowVisible())
{
pwndCtrl->GetWindowRect(&rcCtrl);
ScreenToClient(&rcCtrl);
pDC->ExcludeClipRect(&rcCtrl);
}
pwndCtrl = pwndCtrl->GetNextWindow();
}
return CDialog::OnEraseBkgnd(pDC);
}在win2000下运行正常,在 xp的经典主题下也正常,但在xp的xp效果主题下发现对话框中的button没有重绘,成了小黑框。
请大家指点,谢谢!

解决方案 »

  1.   

    去掉 OnEraseBkgnd 就可以了
      

  2.   

    return true; not return CDialog::OnEraseBkgnd(pDC); //maybe
      

  3.   

    我是用了manifest文件以达到xp效果,这时就出现了问题。请大家试一试。还有有没有微软MVP出来给解释一下?分数不够的话,另开帖给分。谢谢!
      

  4.   

    MVP的同学的大哥的叔叔的朋友的儿子的同学的邻居出来解释行嘛?
    Manifests
    Manifests are XML files that accompany and describe side-by-side assemblies or isolated applications. Manifests uniquely identify the assembly through the assembly's <assemblyIdentity> element. They contain information used for binding and activation, such as COM classes, interfaces, and type libraries, that has traditionally been stored in the registry. Manifests also specify the files that make up the assembly and may include Windows classes if the assembly author wants them to be versioned. Side-by-side assemblies are not registered on the system, but are available to applications and other assemblies on the system that specify dependencies in manifest files.
    On Windows XP, manifest files enable administrators and applications to manage side-by-side assembly versions after deployment. Every side-by-side assembly must have a manifest associated with it. The installation of Windows XP installs the supported Microsoft side-by-side assemblies with their manifests. If you develop your own side-by-side assemblies, you must also install manifest files. For more information, see Installing Side-by-Side Assemblies and Manifest Files Reference.Manifests and configuration files are not localized.The following types of manifests are used with side-by-side assemblies:
    Assembly manifests describe side-by-side assemblies. They are used to manage the names, versions, resources, and dependent assemblies of side-by-side assemblies. The manifests of shared assemblies are stored in the WinSxS folder of the system. Private assembly manifests are stored either as a resource in the DLL or in the application folder 
    Application manifests describe isolated applications. They are used to manage the names and versions of shared side-by-side assemblies that the application should bind to at run time. Application manifests are copied into the same folder as the application executable file or included as a resource in the application's executable file. 
    Application Configuration Files, are manifests used to override and redirect the versions of dependent assemblies used by side-by-side assemblies and applications. 
    Publisher Configuration Files, are manifests used to redirect the version of a side-by-side assembly to another compatible version. The version that the assembly is being redirected to should have the same major.minor values as the original version.
      

  5.   

    to  goodheartppl(goodheart) 兄弟您说的好像和我的问题没有关系啊?我问的是为什么在下列条件下,dialog中的button 显示成了黑框
      1、Win2000, .net 2003 C++下开发
      2、在 OnEraseBkgnd中ExcludeClipRect对话框中所有Visiable子窗口区域
      3、在XP下运行,系统采用XP效果主题,程序使用manifest文件达到XP Style
      

  6.   

    经昨夜验证,发现button和group-box都不能重画,估计是button和group是由对话框绘制的,现修改程序如下://if(IsWindow(pwndCtrl->m_hWnd)&&pwndCtrl->IsWindowVisible())
    if(IsWindow(pwndCtrl->m_hWnd) && pwndCtrl->IsWindowVisible() && (!(pwndCtrl->SendMessage(WM_GETDLGCODE)&(DLGC_BUTTON|DLGC_STATIC))))
    不会出现黑框的现象,但所有的button和static及group-box都出现了闪烁。
    暂时结贴,学习一下在问。