draw icon on d3d surface in vista, it is a bug of ms or not
- From: John <John@xxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Sun, 3 Aug 2008 20:35:21 -0700
hi, everyone:
so i make a simple samle,
use the the same process like my real code.
and the result is the same with my real application
////////////////////////////////////////////////////
first: i use D3D (direct draw) to draw a surface "A",
second: i draw a icon on the "A" using gdi
the background of the icon i make using vc2005 is transparent.
it is right when aero is disabled in Vista or Xp,
but when aero is enabled in vista , the icon 's backbround is white,
but not transparent .so it is wrong.
the sample code like below
///use direct draw to draw surface begin
////////////////////////////////////////////////////
LPDIRECTDRAWSURFACE7 m_pddsFrontBuffer;
LPDIRECTDRAWSURFACE7 m_pddsStoreBuffer;
HRESULT hRet;
RECT rt;
POINT p = {0, 0};
ClientToScreen(hWnd, &p);
rt.left = 0 + p.x; rt.top = 0 + p.y; rt.right = 800 + p.x; rt.bottom = 600 +
p.y;
while( 1 )
{
hRet = m_pddsFrontBuffer->Blt(&rt, m_pddsStoreBuffer, NULL, DDBLT_WAIT,
NULL);
if (hRet == DD_OK)
break;
else if(hRet == DDERR_SURFACELOST)
{
m_pddsFrontBuffer->Restore();
m_pddsStoreBuffer->Restore();
}
else if(hRet != DDERR_WASSTILLDRAWING)
return;
}
///use direct draw to draw surface end
/// draw icon on surface begin
HICON icon = AfxGetApp()->LoadIcon(IDI_ICON1);
CClientDC dc(this);
RECT rtClient;
this->GetClientRect(&rtClient);
// x, y is the coordinate when user left-click mouse on surface.
dc.DrawIcon(x, y, icon);
/// draw icon surface end
////////////////////////////////////////////////////////////////
the result is wrong, icon 's background is white.
but when i add three lines code ,
the icon 's background is transparent when aero is enabled in vista,
the code like below
///////////////////////////////////////
///use direct draw to draw surface end
/// draw icon on surface begin
HICON icon = AfxGetApp()->LoadIcon(IDI_ICON1);
CClientDC dc(this);
RECT rtClient;
this->GetClientRect(&rtClient);
// the new code
HDC hDCDisplay = ::CreateDC(_T("DISPLAY"), NULL, NULL, NULL);
::BitBlt(dc.m_hDC, 0, 0, rtClient.right - rtClient.left, rtClient.bottom -
rtClient.top, hDCDisplay, rtClient.left, rtClient.top, SRCCOPY);
DeleteDC(hDCDisplay);
/// draw icon surface end
// x, y is the coordinate when user left-click mouse on surface.
dc.DrawIcon(x, y, icon);
//////////////////////////////////
so i think it is a bug of microsoft?
when draw icon which use gdi on surface which use d3d, when aero is enabled
in
vista, the icon 's background cant still keep transparent like normal.
only a guess.
hope your response.
good regards
John
.
- Prev by Date: Re: Spacing between letters, ID3DXFont
- Next by Date: Activex Directx
- Previous by thread: How to manipulate edges of a mesh?
- Next by thread: Activex Directx
- Index(es):
Relevant Pages
|