密码HRESULT错误

Cryptic HRESULT errors

本文关键字:错误 HRESULT 密码      更新时间:2023-10-16

以下EndDraw()函数返回HRESULT错误代码:http://msdn.microsoft.com/en-us/library/windows/desktop/dd371924%28v=vs.85%29.aspx

文件规定:

如果该方法成功,则返回S_OK。否则,它将返回HRESULT错误代码,并将tag1和tag2设置为错误发生时处于活动状态的标记。

然后返回指示操作成功的HRESULT。。。

我得到CCD_ 1的返回值;公共HRESULT值";页码:http://msdn.microsoft.com/en-us/library/windows/desktop/aa378137%28v=vs.85%29.aspx

我也在WinError.h中搜索了错误代码,但也找不到。如果它返回此代码,那么必须有一种方法来了解它的含义。

我该如何解释此错误代码以找出问题所在?

您使用Google,该十六进制代码的顶部结果为:

D2DERR_WRONG_STATE
0x88990001
The object was not in the correct state to process the method.

http://msdn.microsoft.com/en-us/library/windows/desktop/dd370979(v=vs.85).aspx

我不知道图形编程或Windows编程的第一件事,但我认为这回答了你的问题,再加上文档中指出的标记值将返回给你,指的是错误发生的点。

最后但并非最不重要的。。

我也遇到了同样的错误,直到我意识到我没有首先调用ID2D1HwndRenderTarget::BeginDraw()来为绘制调用准备渲染目标。

(我刚刚创建了一个帐户来投票支持Loul G.的答案,但我还没有投票权限…)

我也遇到过同样的问题。。。

当BeginDraw()和EndDraw(

追溯以查看调用它们的顺序。

此外,为了防止这种情况,您可以围绕BeginDraw()、EndDraw(

bool beginCalled;
int beginCount;//for debugging
int endCount;//for debugging
//initialize variables somewhere...
void begin(){
   rendTarget>BeginDraw();
   beginCalled = true;
   beginCount++;
}
void end(){
   if(beginCalled){
      rendTarget->EndDraw();
      beginCalled = false;
   }
   endCount++;
} 
//print counts as necessary for debugging