Solved

IDirectDrawClipper::SetClipList question

Posted on 1999-01-19
3
350 Views
Last Modified: 2013-12-03
I'm trying to set an IDirectDrawClipper so that it just clips all of a surface.  How do I do this?  I tried using SetClipList, using the following code to create the regiondata:

      HRGN hRgn = CreateRectRgn( 0, 0, Width, Height );
      DWORD dwBufferSize = GetRegionData( hRgn, 0, NULL );
      RGNDATA *rgnData = (RGNDATA *)(new char[dwBufferSize]);
      DWORD dwReturn = GetRegionData( hRgn, dwBufferSize, rgnData );
      if( dwReturn == 0 ) Error( "GetRegionData failed.\n" );
      else if( dwReturn != 1 ) Error( "GetRegionData returned a non-zero value (%d).\n", dwReturn );

But I get the "GetRegionData returned a non-zero value" error.  (dwReturn is 48 bytes, as I expect, because sizeof(RGNDATAHEADER) == 32)

All I wanted was to make a clipper that is Width x Height, for use on an offscreen surface.

Thanks for any help,
0
Comment
Question by:Bishop051997
  • 2
3 Comments
 

Author Comment

by:Bishop051997
ID: 1418989
Adjusted points to 300
0
 
LVL 1

Accepted Solution

by:
wirus earned 300 total points
ID: 1418990
There is a bug (or a mistake in documentation).
GetRegionData() returns always number of bytes copied, if buffer size >= required, or 0. However, after checking ReturnValue==dwBufferSize (ReturnValue<=dwBufferSize), you should always check for "1" (because documentation says so...):

ASSERT( ReturnValue<=dwBufferSize && ReturnValue>0 );

I mean your code works, you only have to modify error checking.

Anyway, if you need rectangular regions only, I suggest preparing RGNDATAHEADER youself:

// .......................

RECT theRect = {<rectLeft>, <rectTop>, <rectRight>, <rectBottom>};

// ......................

struct {
RGNDATAHEADER rdh;
RECT rect;
} rectRgnS;
rectRgnS.rdh.dwSize = sizeof(RGNDATAHEADER); // 32
rectRgnS.rdh.iType = RDH_RECTANGLES; // 1
rectRgnS.rdh.nCound = 1;
rectRgnS.rdh.nRgnSize = sizeof(RECT); // 16
memcpy(&rectRgnS.rdh.rcBound, &theRect, sizeof(RECT));
memcpy(&rectRgnS.rect, &theRect, sizeof(RECT));
// ready to use

// ...............................................

\Virus

0
 

Author Comment

by:Bishop051997
ID: 1418991
Goddamnit!!  I hate when the documentation is wrong :)

It works now, anyway - thanks.
0

Featured Post

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

This article describes how to add a user-defined command button to the Windows 7 Explorer toolbar.  In the previous article (http://www.experts-exchange.com/A_2172.html), we saw how to put the Delete button back there where it belongs.  "Delete" is …
This article surveys and compares options for encoding and decoding base64 data.  It includes source code in C++ as well as examples of how to use standard Windows API functions for these tasks. We'll look at the algorithms — how encoding and decodi…
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

746 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now