Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 1005387
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T08:17:11+00:00 2026-05-16T08:17:11+00:00

ok i know how to do the left mouse button down evet(WM_LBUTTONDOWN). but im

  • 0

ok i know how to do the left mouse button down evet(WM_LBUTTONDOWN). but im having some troubles with it. when use it with vectors it seems to add 101 elemnts everytime the left mouse button is down. i think that every time the mouse button is down, it sends 101 messages to WM_LBUTTONDOWN that causes 101 elements to be added.
here is the code for the event

case WM_LBUTTONDOWN:
    iRegularShots=0;
    pt.x = GET_X_LPARAM(lParam); 
    pt.y = GET_Y_LPARAM(lParam); 
    pRegularShots.push_back(pt); 
    InvalidateRect(hWnd, rect, false); 
    break;

any ideas ?


im not missing a break;
i used teh size() function to tell me how many elemnts were assigned.
i set two break points one one pRegularShots.push_back(pt); and the other one on different function that will use what is inside the vector to display the image. and i got 101 calls over there but only one call on the pRegularShots.push_back(pt);.
this is the function code

VOID fRegularShot(HDC hdc, HWND hWnd) 
{ 
    Graphics graphics(hdc); 
    Image shot(L"RegularShots.png"); 
    long index=0;
    long s=pRegularShots.size();
    while(index < (long)pRegularShots.size()) 
    { 
        graphics.DrawImage(&shot, pRegularShots[index].x, pRegularShots[index].y); 
        ++index;
    } 
} 

windows prudocer

switch (message)
    {
    case WM_COMMAND:
        wmId    = LOWORD(wParam);
        wmEvent = HIWORD(wParam);
        // Parse the menu selections:
        switch (wmId)
        {
        case IDM_ABOUT:
            DialogBox(hInst, MAKEINTRESOURCE(IDD_ABOUTBOX), hWnd, About);
            break;
        case IDM_EXIT:
            DestroyWindow(hWnd);
            break;
        default:
            return DefWindowProc(hWnd, message, wParam, lParam);
        }
        break;
    case WM_PAINT:
        hdc = BeginPaint(hWnd, &ps);
        OnPaint(hdc, hWnd, 1);
        if(iRegularShots==0)
        {
            fRegularShot(hdc, hWnd);
        }
        EndPaint(hWnd, &ps);
        break;
    case WM_LBUTTONDOWN:
        iRegularShots=0;
        pt.x = GET_X_LPARAM(lParam); 
        pt.y = GET_Y_LPARAM(lParam); 
        pRegularShots.push_back(pt); 
        InvalidateRect(hWnd, rect, false); 
        return 0;
        break; 
    case WM_LBUTTONUP:
            iRegularShots=1;
            break;
    case WM_DESTROY:
        PostQuitMessage(0);
        break;
    default:
        return DefWindowProc(hWnd, message, wParam, lParam);
    }
    return 0;
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T08:17:12+00:00Added an answer on May 16, 2026 at 8:17 am

    omg it was my fault i set the vetor to 100 elemnts sorry guys

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following situation I handle when the left mouse button is pressed
On mouse-down (and up) I need to check which mouse button has changed its
I know that most links should be left up to the end-user to decide
I know the rule-of-thumb to read declarations right-to-left and I was fairly sure I
Know of any good libraries for this? I did some searches and didn't come
I know this might be a no-brainer, but please read on. I also know
I know, I would have thought the answer was obviously no as well, but
I use MouseMove event to move objects(say labels). simple principle(schematic): OnMouseMove(e MouseEventArgs) if e.Button
Know of an OCAML/CAML IDE? Especially one that runs on Linux?
I know in certain circumstances, such as long running processes, it is important to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.