Archived

This topic is now archived and is closed to further replies.

GDI-functions on DirectDraw-surfaces

This topic is 5673 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi, I''m trying to use GDI-functions with DirectDraw7-Surface, but it won''t work. It looks like this(where lpDDSBack points to the surface): ... HDC hdc; if (DD_OK==lpDDSBack->GetDC(&hdc)) { HPEN hPen; HPEN hPenold; HBRUSH hBrush,hBrushold; hBrush=CreateSolidBrush(RGB(255,100,0)); hPen=CreatePen(PS_SOLID,2,RGB(0,255,255)); hBrushalt=SelectObject(hdc,hBrush); hPenalt=SelectObject(hdc,hPen); MoveToEx(hdc,250,250,NULL); LineTo(hdc, 300,400); lpDDSBack->ReleaseDC(hdc); } ... Now, I get a bunch of error messages that I don''t understand. Any help? i just want to draw an ordinary white line on my surface. Thanks! alex

Share this post


Link to post
Share on other sites
hBrushalt=SelectObject(hdc,hBrush);
hPenalt=SelectObject(hdc,hPen);
You never declared hBrushalt and hPenalt. Perhaps you meant hBrushold and hPenold? Also, are you releasing the HPENs and HBRUSHES when you are done with them?

------------------------------
BASIC programmers don''t die, they just GOSUB and don''t return.

Share this post


Link to post
Share on other sites
hi,

>hBrushalt=SelectObject(hdc,hBrush);
>hPenalt=SelectObject(hdc,hPen);
>You never declared hBrushalt and hPenalt. Perhaps you meant hBrushold and hPenold?

yes, but in my original program, it''s ok (just translated it and forgot that line).

>Also, are you releasing the HPENs and HBRUSHES when you are done with them?

I tried that, but I get the same error messages:

"fatal error LNK1120: 2 unresolved external symbols" (ugly translation!)

I used DeleteObject(...) for hPen,hBrush... after drawing the line , but no success!

thanks for any help!

alex

Share this post


Link to post
Share on other sites
You must use DeleteObject() before ReleaseDC(). If that doesn''t work, post the errors you are getting, because it is hard to help you with errors if we don''t even know what they are.

------------------------------
BASIC programmers don''t die, they just GOSUB and don''t return.

Share this post


Link to post
Share on other sites