CWnd wnd;
wnd.Attach(::GetDesktopWindow());
m_MyWnd.Create(IDD_DESKTOPBARDLG_DIALOG,&wnd);
//.....
wnd.Detach();

解决方案 »

  1.   

    你的窗口类的实例。就是:
     CFloatDlg m_MyWnd;understand?
      

  2.   

    bool cdrawtestapp::initinstance()
    {
        crect rect(0, 0, 320, 150);
        ctransparentwnd* ptwnd = new ctransparentwnd;
        m_pmainwnd = ptwnd;
        pframe->createtransparent("transparent test", rect, idb_mask, idb_back);
        pframe->showwindow(sw_show);
        pframe->updatewindow();
        return true;
    }
    void ctransparentwnd::setupregion(cdc *pdc, unsigned short maskid)
    {
        cdc              memdc;
        cbitmap         cbitmap;
        cbitmap*        poldmembmp = null;
        colorref        col;
        crect            crect;
        int              x, y;
        crgn             m_rgn, rgntemp;    getwindowrect(&crect);    cbitmap.loadbitmap(maskid);
        memdc.createcompatibledc(pdc);
        poldmembmp = memdc.selectobject(&cbitmap);    m_rgn.createrectrgn(0, 0, crect.width(), crect.height());
        for(x=0; x<=crect.width(); x++)
        {
            for(y=0; y<=crect.height(); y++)
            {
                col = memdc.getpixel(x, y);
                if(col == 0)
                {
                    rgntemp.createrectrgn(x, y, x+1, y+1);
                    m_rgn.combinergn(&m_rgn, &rgntemp, rgn_xor);
                    rgntemp.deleteobject();     
                }
            }
        }
        if (poldmembmp) memdc.selectobject(poldmembmp);
        setwindowrgn((hrgn)m_rgn, true);
    }void ctransparentwnd::onlbuttondown(uint nflags, cpoint point) 
    {
        cwnd::onlbuttondown(nflags, point);
        postmessage(wm_nclbuttondown, htcaption, makelparam(point.x,point.y));
    }
      

  3.   

    typedef BOOL (FAR PASCAL*LAYERFUNC)(HWND,COLORREF,BYTE,DWORD);
    void SetTransparent(HWND hwnd,UINT alpha)
    {
    LAYERFUNC SetLayer;
    HMODULE hmod=LoadLibrary("user32.dll");
    SetWindowLong(hwnd,GWL_EXSTYLE,GetWindowLong(hwnd,GWL_EXSTYLE)|0x80000L);
    SetLayer=(LAYERFUNC)GetProcAddress(hmod,"SetLayeredWindowAttributes");
    SetLayer(hwnd,0,(255*alpha)/100,0x2); FreeLibrary(hmod);
    }只能在WinNT下执行,要9x下自己写算法。