Hold Shift key down and Mouse Click event

Posted on 2007-08-03
Last Modified: 2013-11-20
I would like to respond when user hold the shift key down and mouse click.
How can I catch these two events occuring at the same time?
Question by:qkrwngml
    LVL 22

    Accepted Solution

    Check on out OnLButtonDown( UINT nFlags, CPoint point );
    If the MK_SHIFT bit is set in the nFlags parameter, the shift key is down.

    void CMyView::OnLButtonDown(UINT nFlags, CPoint point)
        if (nFlags & MK_SHIFT) {
          //shift key is pressed ..DO Processing
        CView::OnLButtonDown(nFlags, point);

    LVL 13

    Expert Comment


    to do that global, use a key/mouse hook

    set a flag when shift is pressed, unset it when shift is released

    now in the mouse hook, check if the good button is pressed, and check for the shift flag

    Author Comment

    Great mahesh1402!

    Featured Post

    6 Surprising Benefits of Threat Intelligence

    All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

    Join & Write a Comment

    When writing generic code, using template meta-programming techniques, it is sometimes useful to know if a type is convertible to another type. A good example of when this might be is if you are writing diagnostic instrumentation for code to generat…
    Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
    The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
    The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.

    745 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

    Need Help in Real-Time?

    Connect with top rated Experts

    16 Experts available now in Live!

    Get 1:1 Help Now