???其實這個很簡單,只是創建設備的時候那個hwnd有點不一樣!
???可能有人就會說,用GetDesktopWindows()獲得桌面的句柄不就行了?那就錯了!這樣會沒有效果的!正確的代碼如下:
????HWND?hWnd?
=
?FindWindowEx(GetDesktopWindow()?,?
0
?,?
"
Progman
"
?,?
"
Program?Manager
"
);
????hWnd?
=
?FindWindowEx(hWnd?,?
0
?,?
"
SHELLDLL_DefView
"
?,?
0
);
????hWnd?
=
?FindWindowEx(hWnd?,?
0
?,?
"
SysListView32
"
?,?
"
FolderView
"
);
????
//
?初始化?D3D?設備
????InitD3D(hWnd);

是不是很簡單!哈哈。
顯示的時候,如果想渲染在桌面的一角,則可以這樣寫:
//?顯示在左上角,128×128寬
????????RECT?rect;
????????rect.left?=?0;
????????rect.right?=?128;
????????rect.top?=?0;
????????rect.bottom?=?128;
????????//?顯示
????????g_pd3dDevice->Present(0?,?&rect?,?0?,?0);
