zoukankan      html  css  js  c++  java
  • 设置对话框的背景颜色

    第一种方法,用图片控件piture Control ;

    但是这种方法不能刷新背景,如果程序被其他程序覆盖的话,切换回程序的话,背景图片会把程序的其他控件覆盖掉;

    第二种:

    在程序的OnPaint()函数里面用双缓冲进行贴图;

    if (IsIconic() )
    {
    
    CPaintDC dc(this); // device context for painting
    
    SendMessage(WM_ICONERASEBKGND, reinterpret_cast<WPARAM>(dc.GetSafeHdc()), 0);
    
    
    // Center icon in client rectangle
    int cxIcon = GetSystemMetrics(SM_CXICON);
    int cyIcon = GetSystemMetrics(SM_CYICON);
    CRect rect;
    GetClientRect(&rect);
    int x = (rect.Width() - cxIcon + 1) / 2;
    int y = (rect.Height() - cyIcon + 1) / 2;
    
    // Draw the icon
    dc.DrawIcon(x, y, m_hIcon);
    
    }
    
    else
    {
    CPaintDC dc(this); CDC memdc; memdc.CreateCompatibleDC(&dc);//创建兼容DC CBitmap bkg; bkg.LoadBitmap( IDB_BITMAP_DIALOG);//载入位图 BITMAP bkginfo; bkg.GetBitmap(&bkginfo);//获取位图信息 memdc.SelectObject(&bkg); RECT rect; GetWindowRect(&rect);//获取对话框信息 dc.StretchBlt(0,0,rect.right-rect.left,rect.bottom-rect.top,&memdc,0,0,bkginfo.bmWidth,bkginfo.bmHeight,SRCCOPY); }
  • 相关阅读:
    [CF1475F] Unusual Matrix
    [JXOI2018] 游戏
    [ZJOI2010] 排列计数
    [CF1474E] What Is It?
    [CF375D] Tree and Queries
    [CF519E] A and B and Lecture Rooms
    [CF321C] Ciel the Commander
    [CF1C] Ancient Berland Circus
    [CF321A] Ciel and Robot
    [CF1450C1] Errich-Tac-Toe (Easy Version)
  • 原文地址:https://www.cnblogs.com/chenzuoyou/p/3507561.html
Copyright © 2011-2022 走看看