You are here:

C++/term does not evaluate to a function


There is a  error in this code but I couldn't understand what is the problem.:

CPen    pen( PS_DOT, 1, RGB(0,255,0) );
CPen *pOldPen = pDC->SelectObject(&pen);          
CRect rect;
pDC->Ellipse( rect );

error C2064: term does not evaluate to a function
in this line.

Could u please help me for slow that problem. (I need to draw dotted line rectangle) use visual c++6 and GDI.

In fact you seem to be using the MFC wrapper classes for the straight Win32 GDI API. I think you will find these lines are your problem:

       CRect rect;


The second line tries to call an operator() (function call operator) on the CRect instance rect. You will find that CRect has no such call operator member function declared. I suggest you look up the documentation on the MFC CRect class.

Specifically note that you probably wish to call one of the constructors for CRect passing it your left, top and right, bottom corner coordinates.

Secondly CRect is _just_ a set of coordinate values (in fact it is probably two point values, each of which contains one x,y coordinate value pair). It has no use for pen types.

Thirdly, the GDI coordinate system is an integer coordinate system, not a floating point coordinate system as you might find with other graphics libraries such as OpenGL.

Finally - I am not sure but you appear to be using negative coordinates - is this really what you wish when using screen or window coordinates based on left,top being (0,0), or have you called the relevant coordinate member functions of the CDC object?

Here is what you might try to construct you CRect object:

       CRect rect( m_Objects[i].m_width/2
         , -m_Objects[i].m_height/2
         , m_Objects[i].m_width
         , m_Objects[i].m_height

You also state that you wish to draw a dotted line rectangle but then use Ellipse - eh?

You call the CDC::Rectangle function to draw a rectangle and you can pass it the left, top, right, bottom coordinate values:

       pDC->Rectangle( m_Objects[i].m_width/2
         , -m_Objects[i].m_height/2
         , m_Objects[i].m_width
         , m_Objects[i].m_height

or pass it the address of a CRect object:

       pDC->Rectangle( &rect );

This function will draw a rectangle using the current pen for the border and the current brush to fill the interior.

Note that in your code you create a pointer to a CDC object but you NEVER ASSIGN IT TO POINT TO ANYTHING! I hope this is only for demonstration purposes otherwise you will find your code will most likely crash when run.

Get into the habit of reading the MS documentation that comes with the Visual Studio products in the form of the MSDN library. If for some reason you do not have it to hand on CD or DVD and installed on your machine then you can find it online at:

All of the member functions and constructors I used above I checked out using the MSDN library first - there is no reason whatsoever why you cannot do the same.

You might also like to read up on any articles in the MSDN library on Windows programming, GDI programming and MFC programming.

Hope this helps a little.


All Answers

Answers by Expert:

Ask Experts


Ralph McArdell


I am a software developer with more than 15 years C++ experience and over 25 years experience developing a wide variety of applications for Windows NT/2000/XP, UNIX, Linux and other platforms. I can help with basic to advanced C++, C (although I do not write just-C much if at all these days so maybe ask in the C section about purely C matters), software development and many platform specific and system development problems.


My career started in the mid 1980s working as a batch process operator for the now defunct Inner London Education Authority, working on Prime mini computers. I then moved into the role of Programmer / Analyst, also on the Primes, then into technical support and finally into the micro computing section, using a variety of 16 and 8 bit machines. Following the demise of the ILEA I worked for a small company, now gone, called Hodos. I worked on a part task train simulator using C and the Intel DVI (Digital Video Interactive) - the hardware based predecessor to Indeo. Other projects included a CGI based train simulator (different goals to the first), and various other projects in C and Visual Basic (er, version 1 that is). When Hodos went into receivership I went freelance and finally managed to start working in C++. I initially had contracts working on train simulators (surprise) and multimedia - I worked on many of the Dorling Kindersley CD-ROM titles and wrote the screensaver games for the Wallace and Gromit Cracking Animator CD. My more recent contracts have been more traditionally IT based, working predominately in C++ on MS Windows NT, 2000. XP, Linux and UN*X. These projects have had wide ranging additional skill sets including system analysis and design, databases and SQL in various guises, C#, client server and remoting, cross porting applications between platforms and various client development processes. I have an interest in the development of the C++ core language and libraries and try to keep up with at least some of the papers on the ISO C++ Standard Committee site at


©2017 All rights reserved.

[an error occurred while processing this directive]