GDI-functions on DirectDraw-surfaces

Started by
2 comments, last by Beutelteufel 21 years, 10 months ago
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
Advertisement
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.
------------------------------BASIC programmers don't die, they just GOSUB and don't return.
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
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.
------------------------------BASIC programmers don't die, they just GOSUB and don't return.

This topic is closed to new replies.

Advertisement