• <ins id="pjuwb"></ins>
    <blockquote id="pjuwb"><pre id="pjuwb"></pre></blockquote>
    <noscript id="pjuwb"></noscript>
          <sup id="pjuwb"><pre id="pjuwb"></pre></sup>
            <dd id="pjuwb"></dd>
            <abbr id="pjuwb"></abbr>

            Welcome to ErranLi's Blog!

              C++博客 :: 首頁 :: 聯系 :: 聚合  :: 管理
              106 Posts :: 1 Stories :: 97 Comments :: 0 Trackbacks

            常用鏈接

            留言簿(12)

            搜索

            •  

            積分與排名

            • 積分 - 177261
            • 排名 - 151

            最新評論

            閱讀排行榜

            這個是此換膚方法的基礎函數: 相關資料:Microsoft Knowledge Base Article - Q79212
            ///{{{{  for global function
            ///HOWTO: Drawing Transparent Bitmaps 
            see: Microsoft Knowledge Base Article - Q79212
            // TransparentBlt - Copies a bitmap transparently onto the destination DC
            // hdcDes - Handle to destination device context
            // xDes  - x-coordinate of destination rectangle's upper-left corner
            // yDes  - y-coordinate of destination rectangle's upper-left corner
            // width - Width of destination rectangle
            // height - height of destination rectangle
            // hbmSrc - Handle of the source bitmap
            // xSrc  - x-coordinate of source rectangle's upper-left corner
            // ySrc  - y-coordinate of source rectangle's upper-left corner
            // crTrans  - The transparent color
            // hPal     - Logical palette to be used with bitmap. Can be NULL
            BOOL TransparentBitBlt(HDC hdcDes,
                    int xDes,
                    int yDes,
                    int width,
                    int height,
                    HBITMAP hbmSrc,
                    int xSrc,
                    int ySrc,
                    COLORREF crTrans,
                    HPALETTE hPal
                    )

            {
             ASSERT(hdcDes!=NULL);//if(hdcDes == NULL) return FALSE;
             ASSERT(hbmSrc!=NULL);//if(hbmSrc == NULL) return FALSE;

             CDC dc, memDC, maskDC, tempDC;
             dc.Attach(hdcDes);
             maskDC.CreateCompatibleDC(&dc);
             CBitmap maskBmp;
             
             //add these to store return of SelectObject() calls
             CBitmap *pOldMemBmp = NULL;
             CBitmap *pOldMaskBmp = NULL;
             HBITMAP hOldTempBmp = NULL;
             
             memDC.CreateCompatibleDC(&dc);
             tempDC.CreateCompatibleDC(&dc);
             CBitmap bmpImage;
             bmpImage.CreateCompatibleBitmap(&dc, width, height);
             pOldMemBmp = memDC.SelectObject(&bmpImage);
             
             // Select and realize the palette
             if( dc.GetDeviceCaps(RASTERCAPS) & RC_PALETTE && hPal )
             {
              ::SelectPalette(dc, hPal, FALSE);
              dc.RealizePalette();
              
              ::SelectPalette(memDC, hPal, FALSE);
             }
             
             hOldTempBmp = (HBITMAP)::SelectObject(tempDC.m_hDC, hbmSrc);
             
             memDC.BitBlt(0, 0, width, height, &tempDC, xSrc, ySrc, SRCCOPY);
             
             // Create monochrome bitmap for the mask
             maskBmp.CreateBitmap(width, height, 1, 1, NULL);
             pOldMaskBmp = maskDC.SelectObject(&maskBmp);
             memDC.SetBkColor(crTrans);
             
             // Create the mask from the memory DC
             maskDC.BitBlt(0, 0, width, height, &memDC, 0, 0, SRCCOPY);
             
             // Set the background in memDC to black. Using SRCPAINT with black
             // and any other color results in the other color, thus making
             // black the transparent color
             memDC.SetBkColor(RGB(0,0,0));
             memDC.SetTextColor(RGB(255,255,255));
             memDC.BitBlt(0, 0, width, height, &maskDC, 0, 0, SRCAND);
             
             // Set the foreground to black. See comment above.
             dc.SetBkColor(RGB(255,255,255));
             dc.SetTextColor(RGB(0,0,0));
             dc.BitBlt(xDes, yDes, width, height, &maskDC, 0, 0, SRCAND);
             
             // Combine the foreground with the background
             dc.BitBlt(xDes, yDes, width, height, &memDC, 0, 0, SRCPAINT);
             
             
             if (hOldTempBmp)
              ::SelectObject(tempDC.m_hDC, hOldTempBmp);
             if (pOldMaskBmp)
              maskDC.SelectObject(pOldMaskBmp);
             if (pOldMemBmp)
              memDC.SelectObject(pOldMemBmp);
             
             dc.Detach();

             maskBmp.DeleteObject();
             bmpImage.DeleteObject();

             maskDC.DeleteDC();
             memDC.DeleteDC();
             tempDC.DeleteDC();

             pOldMemBmp = NULL;
             pOldMaskBmp = NULL;
             hOldTempBmp = NULL;

             return TRUE;
            }

            ///}}} for global function

             

            另三個很有意思的類,從高手那“盜”來的,呵呵:


            class CWinRect: public CRect
            {
            public:
             CWinRect(HWND hWnd)
             {
              ::GetWindowRect(hWnd, this);
             }
             CWinRect(const CWnd *pWnd)
             {
              ::GetWindowRect(pWnd->GetSafeHwnd(), this);
             }

            };

            class CWinText: public CString
            {
            public:
             CWinText(HWND hWnd)
             {
              (CWnd::FromHandle(hWnd))->GetWindowText(*this); 
             }
             CWinText(const CWnd *pWnd)
             {
              pWnd->GetWindowText(*this);
             }
            };


            class CClientRect: public CRect
            {
            public:
             CClientRect(HWND hWnd)
             {
              ::GetClientRect(hWnd, this);
             }
             CClientRect(CWnd *pWnd)
             {
              ::GetClientRect(pWnd->GetSafeHwnd(), this);
             }
            };

            posted on 2006-12-26 21:43 erran 閱讀(1571) 評論(0)  編輯 收藏 引用 所屬分類: WinCE
            亚洲伊人久久大香线蕉苏妲己| 97超级碰碰碰久久久久| 精品久久久久成人码免费动漫| 2021国产精品久久精品| 久久国产欧美日韩精品| 精品无码久久久久久久动漫| 久久亚洲精品人成综合网| 久久精品国产一区二区三区| 久久久久亚洲av无码专区导航| 日批日出水久久亚洲精品tv| 色婷婷综合久久久久中文| 久久99精品久久久久久噜噜| 狠狠狠色丁香婷婷综合久久俺| 精品久久久久成人码免费动漫| 成人国内精品久久久久影院VR| 久久狠狠高潮亚洲精品| 青青草原综合久久大伊人导航| 国产成人无码精品久久久久免费| 婷婷久久香蕉五月综合加勒比| 午夜肉伦伦影院久久精品免费看国产一区二区三区| 久久精品国产99久久久古代 | 久久久久久久久无码精品亚洲日韩 | 天天综合久久一二三区| 久久精品一区二区三区不卡| 色88久久久久高潮综合影院| 伊人热热久久原色播放www| 久久久久女教师免费一区| 日本免费久久久久久久网站| 久久A级毛片免费观看| 久久久老熟女一区二区三区| 久久99精品久久久大学生| 亚洲精品国产第一综合99久久| 欧美一级久久久久久久大| 久久夜色精品国产噜噜亚洲a| 亚洲精品无码久久久久AV麻豆| 久久强奷乱码老熟女网站| 区亚洲欧美一级久久精品亚洲精品成人网久久久久| 久久中文字幕一区二区| 精品久久久久久国产牛牛app| 国内精品免费久久影院| 亚洲一级Av无码毛片久久精品|