• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 977
  • Last Modified:

visual c++ double click message

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.

1 Solution
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
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.

substandAuthor Commented:
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

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now