Solved

IDirectDrawClipper::SetClipList question

Posted on 1999-01-19
3
354 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Windows Mobile 6.5 device Apache Flex 3 49
File Watcher and Deleter with Email notification 5 136
Post a good COM tutorial 1 72
Mobile apps - web/native or hybrid? 1 120
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…
A theme is a collection of property settings that allow you to define the look of pages and controls, and then apply the look consistently across pages in an application. Themes can be made up of a set of elements: skins, style sheets, images, and o…
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…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

737 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