visual c++ double click message

Posted on 2003-03-03
Medium Priority
Last Modified: 2007-12-19
I'm trying to access the double click message in my VC++ (6.0) program message loop.

the callback procedure is defined as:

WPARAM wParam, LPARAM lParam)

just so you know which one i'm talking about.  I'm not using MFC.

I've read that it is supposed to be "WM_DBLCLK" or "WM_LDBLCLK" and have also read that I need to set the window class style member to CS_DBLCLKS to catch the message.  None of this works.  

Also, I would appreciate if someone could point me in the direction of how to draw a circle.  is there a function which takes the radius and center point to draw it?  I'd really rather not use the LineTo(...) function over and over again just to draw a circle.

Finally, does anyone know anything about splines?  I can't find any info on them.  I need these to connect the circles.

My problem is that I missed a final last semester and now my "makeup" is to write a fully functional automata simulator (including dfa's, nfa's, turing machines, and cfg's).  I've got the "simulation" part down just fine, I just need to show it using graphics in vc++.  I told the prof I'd have something to show him by the end of the week- so I'd really appreciate some help.  I can't offer many points yet, because I'm a new member and just found this place, so I'm offering all I have.

Question by:substand
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions

Expert Comment

ID: 8062105
i constantly write that wrong myself
you got the cs_ flag right
gdi has a function for circle, its called ellipse
in math there is no such thing as a circle really its an ellipse with a constant radius all around.
ellipse does not take a radius though, it takes a rectangle (you can see on msdn.microsoft.com)
it takes the hdc (GetDC msdn also)
then the left, top, right, and bottom of the rect and uses that as the bounds of the ellipse.
if your good in math im sure you can make a function to do what you want, i stink in math.
splines? i think thats what i ruptured when i got into that accident last year.. no sorry i have no idea what that is

Accepted Solution

vadik earned 300 total points
ID: 8065379
This is my code snippet for your problem:

ATOM MyRegisterClass(HINSTANCE hInstance)
     WNDCLASSEX wcex;

     wcex.cbSize = sizeof(WNDCLASSEX);

     wcex.style               = CS_HREDRAW | CS_VREDRAW | CS_DBLCLKS; // !!!!!!!! You are right. It's really important.
     wcex.lpfnWndProc     = (WNDPROC)WndProc;
     wcex.cbClsExtra          = 0;
     wcex.cbWndExtra          = 0;
     wcex.hInstance          = hInstance;
     wcex.hIcon               = LoadIcon(hInstance, (LPCTSTR)IDI_DBLCLICKS);
     wcex.hCursor          = LoadCursor(NULL, IDC_ARROW);
     wcex.hbrBackground     = (HBRUSH)(COLOR_WINDOW+1);
     wcex.lpszMenuName     = (LPCSTR)IDC_DBLCLICKS;
     wcex.lpszClassName     = szWindowClass;
     wcex.hIconSm          = LoadIcon(wcex.hInstance, (LPCTSTR)IDI_SMALL);

     return RegisterClassEx(&wcex);

     int wmId, wmEvent;
     HDC hdc;
     LoadString(hInst, IDS_HELLO, szHello, MAX_LOADSTRING);

     switch (message)
          case WM_LBUTTONDBLCLK:
                    HDC dc = GetDC(hWnd);

                    int xPos = (int)LOWORD(lParam); //horizontal position of cursor
                    int yPos = (int)HIWORD(lParam); //vertical position of cursor

                    Ellipse(dc, xPos - 50, yPos - 50, xPos + 50, yPos + 50);

                    ReleaseDC(hWnd, dc);

.............. etc

About splines this snippet from the "Programming Windows" by Charlse Petzold. I hope this help you. Sorry for my English...

The following parametric equations for the Bezier spline. The begin point is (x0, y0), and the end point is (x3, y3). The two control points are (x1, y1) and (x2, y2). The curve is drawn for values of t ranging from 0 to 1:

x(t) = (1 - t)^3 x0 + 3t (1 - t)^2 x1 + 3t^2 (1 - t) x2 + t^3 x3

y(t) = (1 - t)^3 y0 + 3t (1 - t)^2 y1 + 3t^2 (1 - t) y2 + t^3 y3

You don't need to know these formulas in Windows 98. To draw one or more connected Bezier splines, you simply call

PolyBezier (hdc, apt, iCount) ;


PolyBezierTo (hdc, apt, iCount) ;

In both cases, apt is an array of POINT structures. With PolyBezier, the first four points indicate (in this order) the begin point, first control point, second control point, and end point of the first Bezier curve. Each subsequent Bezier requires only three more points because the begin point of the second Bezier curve is the same as the end point of the first Bezier curve, and so on. The iCount argument is always one plus three times the number of connected curves you're drawing.

The PolyBezierTo function uses the current position for the first begin point. The first and each subsequent Bezier spline requires only three points. When the function returns, the current position is set to the last end point.

One note: when you draw a series of connected Bezier splines, the point of connection will be smooth only if the second control point of the first Bezier, the end point of the first Bezier (which is also the begin point of the second Bezier), and the first control point of the second Bezier are colinear; that is, they lie on the same straight line.

LVL 10

Author Comment

ID: 8074901
I hope you'll answer this, even though I already graded and chose the answer, but what is the point structure defined as.  how do i set the points?


Featured Post

Want to be a Web Developer? Get Certified Today!

Enroll in the Certified Web Development Professional course package to learn HTML, Javascript, and PHP. Build a solid foundation to work toward your dream job!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Unlike C#, C++ doesn't have native support for sealing classes (so they cannot be sub-classed). At the cost of a virtual base class pointer it is possible to implement a pseudo sealing mechanism The trick is to virtually inherit from a base class…
What is C++ STL?: STL stands for Standard Template Library and is a part of standard C++ libraries. It contains many useful data structures (containers) and algorithms, which can spare you a lot of the time. Today we will look at the STL Vector. …
The viewer will be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.
The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.
Suggested Courses

764 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question