Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Graphics linkage problem.

Status
Not open for further replies.

coldneut

Programmer
Apr 19, 2001
11
US
I have a picture object in a dialog which I need to modify at run time
in response to user input using LineTo/MoveTo. I have been spinning
my wheels trying to attain the proper linkage to the bitmapped
picture's ID property and my tires are getting bald. Can anyone
out there give me an example in a few lines of code, i..e

HDC pDC = ??????
if( myPen.CreatePen( PS_SOLID, 5, RGB(0,0,0) ) ) {
MoveToEx(pDC,0,0,NULL);
LineTo(pDC,270,50);
}
 
------------your post---------------------------
HDC pDC = ??????
if( myPen.CreatePen( PS_SOLID, 5, RGB(0,0,0) ) ) {
MoveToEx(pDC,0,0,NULL);
LineTo(pDC,270,50);
}
================================================

HDC pDC = GetDC(hWnd);
//pDC -> GDI Device context
//hWnd -> Storage for window handle

HtH
Welcome to the Pythian Games!
Long live Godess Athena!
dArktEmplAr of Delphi Oracle
 
HtH:

I tried the HDC pDC = GetDC(hWnd);
and get the compiler error:
'GetDC' : function does not take 1 parameters

If I use 0 parameters it builds the .exe but when
I try to draw lines nothing happens.
 
GetDC is a windows API and is not specific to VC++. I will list a portion of the API help:

===========================================
The GetDC function retrieves a handle of a display device context (DC) for the client area of the specified window. The display device context can be used in subsequent GDI functions to draw in the client area of the window.

This function retrieves a common, class, or private device context depending on the class style specified for the specified window. For common device contexts, GetDC assigns default attributes to the device context each time it is retrieved. For class and private device contexts, GetDC leaves the previously assigned attributes unchanged.

HDC GetDC(

HWND hWnd // handle of window
);


Parameters

hWnd

Identifies the window whose device context is to be retrieved. =========================================================

Why don't you check out the header files that you are using for the API, they must be wrong.

If you still have problems, try the API GetWindowDC, but just a remark:

GetWindowDC is intended for special painting effects within a window's nonclient area. Painting in nonclient areas of any window is not recommended.
Welcome to the Pythian Games!
Long live Godess Athena!
dArktEmplAr of Delphi Oracle
 
I just tried the GetDC funtion, it take one parameter namely HWND.

BTW, if you are really interested in Graphics programming, try using OpenGL, it is blazing fast than the windows GDI.
One more thing, it is cross platform.

For more information, you can visit
Welcome to the Pythian Games!
Long live Godess Athena!
dArktEmplAr of Delphi Oracle
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top