• <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++博客 :: 首頁(yè) :: 聯(lián)系 :: 聚合  :: 管理
              106 Posts :: 1 Stories :: 97 Comments :: 0 Trackbacks

            常用鏈接

            留言簿(12)

            搜索

            •  

            積分與排名

            • 積分 - 175924
            • 排名 - 151

            最新評(píng)論

            閱讀排行榜

            這個(gè)是此換膚方法的基礎(chǔ)函數(shù): 相關(guān)資料: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

             

            另三個(gè)很有意思的類(lèi),從高手那“盜”來(lái)的,呵呵:


            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 閱讀(1560) 評(píng)論(0)  編輯 收藏 引用 所屬分類(lèi): WinCE
            国产91久久综合| 久久婷婷五月综合97色直播| 无码超乳爆乳中文字幕久久| 久久香蕉国产线看观看精品yw | 久久er热视频在这里精品| 久久久噜噜噜www成人网| 久久亚洲春色中文字幕久久久| 久久精品国产第一区二区三区| 国产精品无码久久久久| 超级碰碰碰碰97久久久久| 97久久超碰国产精品2021| 伊人精品久久久久7777| 久久久久久久亚洲Av无码| 久久亚洲中文字幕精品一区四| 色婷婷久久综合中文久久蜜桃av| 狠狠精品干练久久久无码中文字幕| 久久久久久精品无码人妻| 国产成人久久777777| 久久亚洲精精品中文字幕| 日本五月天婷久久网站| 91亚洲国产成人久久精品| 精品久久久久久中文字幕人妻最新| 久久人人爽人人精品视频| 夜夜亚洲天天久久| 99久久成人国产精品免费 | 国产一区二区三区久久精品| 97精品伊人久久大香线蕉| 久久久久人妻一区精品果冻| 久久九九全国免费| 久久99国产精品一区二区| 国产成人精品久久二区二区| 人妻丰满AV无码久久不卡| 亚洲熟妇无码另类久久久| 久久精品成人欧美大片| 伊人久久综合成人网| 亚洲精品乱码久久久久久自慰| 久久精品国产色蜜蜜麻豆| 久久精品中文字幕一区| 一本一本久久A久久综合精品| 伊人久久大香线焦AV综合影院| 亚洲va久久久噜噜噜久久狠狠|