left click, right click, double click
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 6 of 6

Thread: left click, right click, double click

  1. #1
    Join Date
    Jul 2011
    Posts
    2

    Red face left click, right click, double click

    hi everyone, i'm really new to C so please bear with me here. i am trying to make a simple app where you click on the form/main page and an external application is launched (let's call this C:\1.exe). when you double click, another application is launched (C:\2.exe). and finally when you right click, a third application (C:\3.exe) is launched. how is it possible to do this? i hope this is not too complicated. thanks in advance.

  2. #2
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Wallisellen (ZH), Switzerland
    Posts
    17,392

    Re: left click, right click, double click

    1. Create message handlers for WM_LBUTTONDOWN (or WM_LBUTTONUP), WM_LBUTTONDBLCLK, WM_RBUTTONDOWN (or WM_RBUTTONUP).
    2. Use ::CreateProcess API to launch external programs.
    Victor Nijegorodov

  3. #3
    Join Date
    Jul 2011
    Posts
    2

    Re: left click, right click, double click

    thanks. this works great.

  4. #4
    Arjay's Avatar
    Arjay is offline Moderator / MS MVP Power Poster
    Join Date
    Aug 2004
    Posts
    11,295

    Re: left click, right click, double click

    Food for thought....

    When you get on to building more complex applications with context menus, you'll want to handle WM_CONTEXTMENU rather than WM_RBUTTONDOWN.

    The reason is you can display a context menu with the SHIFT + F10 keyboard command. If you only handle a WM_RBUTTONDOWN, the context menu can't be invoked from the keyboard.

    If you use WM_CONTEXTMENU, it will work for the right mouse click and keyboard.

  5. #5
    Join Date
    May 1999
    Location
    DELAWARE, USA
    Posts
    9,915

    Re: left click, right click, double click

    [QUOTE=VictorN;2025343]1. Create message handlers...QUOTE]
    Hi Victor thanks for using message handlers instead of events handlers.
    It makes things much easier to comprehend.
    There are only 10 types of people in the world:
    Those who understand binary and those who do not.

  6. #6
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Wallisellen (ZH), Switzerland
    Posts
    17,392

    Re: left click, right click, double click

    Quote Originally Posted by JohnCz View Post
    Hi Victor thanks for using message handlers instead of events handlers.
    It makes things much easier to comprehend.
    Hi John,
    no problem, it is how I learned it...
    Victor Nijegorodov

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center