Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

IDirectDrawClipper::SetClipList question

Posted on 1999-01-19
3
Medium Priority
?
358 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 1200 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

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

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 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…
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …

610 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