pointers with directX

A12f8436cf328e2d424a2fe92d9e32df
0
Renaud 101 Sep 13, 2004 at 19:03

// How come I can do this????????

LPDIRECTDRAWSURFACE7    lpDDSButtons=NULL;  

// surface loading code
....

HDC hdc;
lpDDSButtons->GetDC(&hdc);
COLORREF PreColor = GetPixel(hdc, X-x+normalState.left, Y-y+normalState.top); 
lpDDSButtons->ReleaseDC(hdc);
if (PreColor != RGB(0,255,0))
{
   return true;
}

// but I can't do this ????

LPDIRECTDRAWSURFACE7*   mtempSurface;
mtempSurface = &lpDDSButtons;

HDC hdc;
mtempSurface->GetDC(&hdc);
COLORREF PreColor = GetPixel(hdc, X-x+normalState.left, Y-y+normalState.top); 
lpDDSButtons->ReleaseDC(hdc);
if (PreColor != RGB(0,255,0))
{
   return true;
}

I get compiler errors, its like it doesnt realize that mtempSurface is a pointer to lpDDSButtons

any help appreciated thanks

2 Replies

Please log in or register to post a reply.

F7a4a748ecf664f189bb704a660b3573
0
anubis 101 Sep 13, 2004 at 20:21

LPDIRECTDRAWSURFACE is a pointer already if you create a pointer to a pointer using -> won’t work anymore (that’s the problem i guess)

48d5487f357fbcacc89e84720577f0ac
0
Steven_Hansen 101 Sep 13, 2004 at 20:53

This will make it work:

(*mtempSurface)->GetDC(&hdc);

Though why you want a pointer to a pointer to an interface confuses me in this context. If you want a copy of the actual draw surface interface pointer, you should do this instead:

LPDIRECTDRAWSURFACE7 lpDDSButtons;
// ... initialization stuff.

LPDIRECTDRAWSURFACE7 mtempSurface = lpDDSButtons;
mtempSurface->AddRef();

Make sure you release your COM interfaces when you are done with them.