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

            常用鏈接

            留言簿(12)

            搜索

            •  

            積分與排名

            • 積分 - 175253
            • 排名 - 151

            最新評論

            閱讀排行榜

            這個是此換膚方法的基礎(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

             

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


            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 閱讀(1554) 評論(0)  編輯 收藏 引用 所屬分類: WinCE
            国产精品热久久无码av| 国产精品欧美久久久天天影视| 国产精品一区二区久久| 久久亚洲中文字幕精品一区四| 久久精品国产91久久综合麻豆自制| 久久精品国产亚洲AV蜜臀色欲 | 一本一道久久a久久精品综合 | 久久九九兔免费精品6| 亚洲精品乱码久久久久久不卡| 久久精品这里只有精99品| 亚洲国产精品婷婷久久| 久久中文娱乐网| 亚洲国产精品久久66| 精品欧美一区二区三区久久久| 99久久精品免费看国产一区二区三区| 久久久久中文字幕| 99久久精品费精品国产| 久久夜色精品国产亚洲av| 亚洲成av人片不卡无码久久| 69久久精品无码一区二区| 久久午夜羞羞影院免费观看| 久久精品9988| 99久久免费只有精品国产| 久久中文精品无码中文字幕| 国产欧美久久久精品影院| 波多野结衣久久| MM131亚洲国产美女久久| 91精品国产高清久久久久久国产嫩草 | 久久精品草草草| 久久综合成人网| 久久久亚洲欧洲日产国码aⅴ| 久久国产精品成人免费| 欧美色综合久久久久久| 国内精品久久久久影院薰衣草| 国产精品久久久久AV福利动漫| 久久中文娱乐网| 97精品依人久久久大香线蕉97| 精品久久一区二区三区| 欧美久久亚洲精品| 久久天堂AV综合合色蜜桃网| 国产激情久久久久影院|