Solved

IDirectDrawClipper::SetClipList question

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

Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

Question has a verified solution.

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

This article shows how to make a Windows 7 gadget that accepts files dropped from the Windows Explorer.  It also illustrates how to give your gadget a non-rectangular shape and how to add some nifty visual effects to text displayed in a your gadget.…
As more and more people are shifting to the latest .Net frameworks, the windows presentation framework is gaining importance by the day. Many people are now turning to WPF controls to provide a rich user experience. I have been using WPF controls fo…
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…
There are cases when e.g. an IT administrator wants to have full access and view into selected mailboxes on Exchange server, directly from his own email account in Outlook or Outlook Web Access. This proves useful when for example administrator want…

688 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