创建不规则对话框

源码下载地址: http://download.youkuaiyun.com/detail/a117653909/4704728MFC,VS2008,Win7 64位先把底图(bg.bmp)中要扣掉的部分ps成RGB(255, 0, 255)
在OnInitdialog里
bmp_Seperator.LoadBitmap( IDB_SEPERATOR );

if ( bmp_Seperator.GetSafeHandle() )
{
     CRect nocheck_rc(0,0,500,300);  //这个是bg.bmp的size
     RegionWindow( &bmp_Seperator, nocheck_rc.left, nocheck_rc.top, nocheck_rc.right, nocheck_rc.bottom );
}

void CxxxDlg::RegionWindow( CBitmap* p, int left, int top, int right, int bottom )
{
    CDC memDC;
    memDC.CreateCompatibleDC( GetDC() );
    CBitmap* pOldBitmap = memDC.SelectObject( p );
    CRgn rgnWnd, rgnTemp;
    CRect rectWnd;
    GetWindowRect( &rectWnd );
    rgnWnd.CreateRectRgn( 0, 0, rectWnd.Width(), rectWnd.Height() );
    COLORREF color; 
    for ( long x = left; x < right; x ++ )
    {
        for ( long y = top; y < bottom; y ++ )
        {
            color = memDC.GetPixel( x, y );
            if ( color == RGB(255,0,255) ) //Seperator.bmp中要抠掉的颜色
            {
                rgnTemp.CreateRectRgn( x, y, x+1, y+1 );
                rgnWnd.CombineRgn( &rgnWnd, &rgnTemp, RGN_XOR );
                rgnTemp.DeleteObject();
            }
        }
    }

    memDC.SelectObject( pOldBitmap );
    SetWindowRgn( (HRGN)rgnWnd,TRUE );
}


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值