• <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)

            搜索

            •  

            積分與排名

            • 積分 - 175949
            • 排名 - 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 閱讀(1561) 評論(0)  編輯 收藏 引用 所屬分類: WinCE
            亚洲精品无码久久久久| 亚洲乱码日产精品a级毛片久久| 亚洲色大成网站WWW久久九九| 狠狠色丁香久久婷婷综合| 精品久久久噜噜噜久久久| 国产精品热久久毛片| 7777精品久久久大香线蕉| 久久久中文字幕| 日韩欧美亚洲综合久久| 久久综合久久综合久久| 久久久久久久精品成人热色戒| 国产精品视频久久久| 97精品伊人久久大香线蕉| 国产成人久久精品麻豆一区| 久久精品国产男包| 国产ww久久久久久久久久| 久久婷婷五月综合97色一本一本| 久久精品国产99久久丝袜| 久久精品成人影院| 亚洲第一永久AV网站久久精品男人的天堂AV | 久久久中文字幕| 亚洲伊人久久综合影院| 99久久国产亚洲高清观看2024 | 丰满少妇人妻久久久久久4| 久久精品国产亚洲AV不卡| 久久99久久成人免费播放| 99久久99久久久精品齐齐| 国产成人精品综合久久久| 色综合久久88色综合天天 | 国产精品亚洲美女久久久| www.久久热.com| 久久99热精品| 久久99国产精品久久99果冻传媒| 久久综合给合久久狠狠狠97色| 亚洲国产另类久久久精品黑人| 亚洲美日韩Av中文字幕无码久久久妻妇 | 狠狠色丁香久久综合五月| 久久精品亚洲日本波多野结衣| 日本国产精品久久| 无码国内精品久久综合88| 国产毛片欧美毛片久久久|