Solved

IDirectDrawClipper::SetClipList question

Posted on 1999-01-19
3
352 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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This tutorial is about how to put some of your C++ program's functionality into a standard DLL, and how to make working with the EXE and the DLL simple and seamless.   We'll be using Microsoft Visual Studio 2008 and we will cut out the noise; that i…
This article describes how to programmatically preset the "Pages per Sheet" option that's available with most printer drivers.   This setting lets you do "n-Up" printing, where two, four, or more pages are printed on each sheet of paper. If your …
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…

825 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