求助! C++的D2D编程问题。。
d3d吧
全部回复
仅看楼主
level 3
目测这个地方没人..
我想在一个windows窗口上 创建目标呈现器 调用ID2D1Factory::CreateHwndRenderTarget()方法 使用一个用FindWindow方法传来的HWND做参数以及D2D1::RenderTargetProperties()和D2D1::HwndRenderTarget()方法初始化的默认参数 但是创建HwndRenderTarget失败 返回的HRESULT是0x887A0001 跪求解决方法
2013年06月03日 05点06分 1
level 3
@忘了5555
求吧主大人现身。。
2013年06月03日 08点06分 2
终于有一起做D2D的了,唔唔,好鸡冻
2013年06月03日 10点06分
level 14
DXGI_ERROR_INVALID_CALL
The application provided invalid parameter data; this must be debugged and fixed before the application is released.
目测参数传递问题 看看FindWindow是否返回空值
2013年06月03日 10点06分 3
FindWindow检查过了 我有个疑问 为什么Findwindow给HWND结构赋值的时候 是给hwnd赋值一个地址 而不是给hwnd->unused赋值。。。 还有就是我用GetDeskTopwindow给HWND赋值的时候unused就会被赋值 我把程序贴上来 吧主大人帮我看看吧
2013年06月03日 10点06分
回复 萌化笨脑壳 :在Windows中的Handle里面的unused就是unused的意思,就是说没有用,有用的只是Handle本身的值而已,句柄都是DECLARED_HANDLE宏定义出来的,所以一般不会用结构体的思维看他,因为他unused在api编程时并没有实际意义,仅供系统维护而已
2013年06月03日 11点06分
_(:з」∠)_ 原来是这样。。。。某因为不知道HWND结构去看了windef结果看到那个结构体。。还以为句柄会赋值到unused。。。
2013年06月03日 12点06分
level 3
test.cpp
#include<windows.h>
#include<WinDef.h>
#include<d2d1.h>
#include<tchar.h>
#include"decode.h"
#include<iostream>
#include<DXGIFormat.h>
using namespace std;
#pragma comment (lib,"d2d1")
struct hwnd{int p;public:hwnd(int s){p=s;}};
struct Rect{long left;long top;long right;long bottom;public:Rect(long l,long t,long r,long b){left=l;top=t;right=r;bottom=b;}};
int main(){HWND a = FindWindow(_T("Notepad"),NULL);//(HWND)malloc(sizeof HWND); if(a==NULL){cout<<"failed"<<endl;}
HWND deskTop = GetDesktopWindow();//cout<<deskTop->unused<<endl;//struct hwnd *ptrhWnd= (hwnd *)a;
cout<<"窗口句柄暂定为笔记本 人工输入方式出现bug"<<endl;
//cin>>a->unused;
int s = 0; //暂停程序用的
cout<<"HWND:"<<a->unused<<endl;
//程序开头
//Initalize ID2I1HwndRenderTarget myHwndRenderTarget
//Initalize Rectangle of HWND a
Rect c(0,0,0,0);
LPRECT myRect;
myRect = (LPRECT)&c;
//myRect->bottom=myRect->left=myRect->right=myRect->top = 0;
if(GetWindowRect(a,myRect)==0)//desktop testonly 测试结束请修改为变量a
{cout<<"getwindowrect has failed"<<endl;}
cout<<c.left<<c.top<<c.right<<c.bottom<<endl;
Rect *myRectTrans;myRectTrans = (Rect *)myRect;
//
//Initialize D2D1Factory
//d2d全部依赖于ID2D1Factory 这是一个重要的接口
ID2D1Factory *myFactory;
HRESULT hResult = D2D1CreateFactory(D2D1_FACTORY_TYPE_MULTI_THREADED,&myFactory);if(hResult!=0)
{cout<<"here is some error:"<<hResult<<endl;cin>>s;return 0;}
decode::dosomthing(a,(decode::Rect*)myRectTrans,myFactory);
2013年06月03日 10点06分 4
level 3
我还是截图算了 复制粘贴过来没有换行符。。。
2013年06月03日 10点06分 5
level 3
decode.h
HRESULT rendertargetcheckflag = myFactory->CreateHwndRenderTarget
(D2D1::RenderTargetProperties(),D2D1::HwndRenderTargetProperties(Hwnd,D2D1::SizeU(
myRectTrans->right-myRectTrans->left,
myRectTrans->bottom-myRectTrans->top)),
&myHwndRenderTarget);
if(FAILED(rendertargetcheckflag))
{
cout<<"create HWNDRenderTarget failed:"<<rendertargetcheckflag<<endl;
int l;
cin>>l;
exit(1);
}
2013年06月03日 10点06分 6
1