the above discussion should point you in the right direction, but it leaves out a very important part of the puzzle for getting your clipper to work correctly.
when u create and attach a clipper to a directdraw surface it will clip everything that you try to draw to that surface(it does this by default). this is the case with the above code snippet. it will compile and run, but you will just get a blank screen because the clipper clipped everything.
you have to explicity tell the clipper what area of the screen you want to be a valid drawing area. the following code shows you how to setup the clipper that will clip to the edges of the screen (you can clip any area(s) of the screen of course, but that code is a little more tedious). here's the basic approach for a 640x480 surface:
where lpddsbuffer is the dd surface u want clipped, and lpdd is your dd object...
// local variables
LPDIRECTDRAWCLIPPER lpddclipper;
LPRGNDATA cliplist;
RECT screen_rect = {0,0,640,480};
// we need to allocate some memory
cliplist = (LPRGNDATA)malloc(sizeof(RGNDATAHEADER) + sizeof(RECT));
//copy to the buffer
memcpy(cliplist->Buffer,&screen_rect,sizeof(RECT));
// set the data fields
cliplist->rdh.dwSize = sizeof(RGNDATAHEADER);
cliplist->rdh.iType = RDH_RECTANGLES;
cliplist->rdh.nCount = 1;
cliplist->rdh.nRgnSize = sizeof(RECT);
cliplist->rdh.rcBound.left= 0;
cliplist->rdh.rcBound.top = 0;
cliplist->rdh.rcBound.right = 640;
cliplist->rdh.rcBound.bottom = 480;
//now create,set,and clip!
if(lpdd->CreateClipper(NULL,&lpddclipper,NULL)!=DD_OK)
return(FALSE); // failed
if(lpddclipper->SetClipList(cliplist,0)!=DD_OK)
return(FALSE); // failed
if(lpddsbuffer->SetClipper(lpddclipper)!=DD_OK)
return(FALSE); // failed
free(cliplist);
return(TRUE); // success
as you can see, you have to declare and fill out the data fields of a RGNDATA structure and then pass it to the SetClipList() function in order to get the clipper to do what u want.
it's a pain at first, but after that it's not so bad. also, i'd put all this stuff in a sub-routine to hide all the grusome details. hence the return statements.
good luck,
don