Thread: common controls and mouse clicks

  1. #1
    mustang benny bennyandthejets's Avatar
    Join Date
    Jul 2002
    Posts
    1,401

    common controls and mouse clicks

    say in Win 32 API, when a user clicks on a progress bar or a status bar, and i want something to occur as a result, how do i capture that event? im sure there must be some WM_COMMAND code or something.

    ps
    by da way, this is MSVC++
    [email protected]
    Microsoft Visual Studio .NET 2003 Enterprise Architect
    Windows XP Pro

    Code Tags
    Programming FAQ
    Tutorials

  2. #2
    pronounced 'fib' FillYourBrain's Avatar
    Join Date
    Aug 2002
    Posts
    2,297
    Subclass the control

    You have to create a callback for it, set it to the control's callback, and call the original callback each time through.

    look up subclassing a window on MSDN. There's an example there somewhere.
    "You are stupid! You are stupid! Oh, and don't forget, you are STUPID!" - Dexter

  3. #3
    erstwhile
    Join Date
    Jan 2002
    Posts
    2,227
    The common controls send notification messages to their parent window in the form of WM_NOTIFY which are sort of analagous to the WM_COMMAND sent by standard or user controls (buttons, edits, etc). [Note that common controls may still also send notifications in the form of WM_COMMAND messages; check the specific control on msdn for more details.]

    The LPARAM of the WM_NOTIFY is a pointer to a NMHDR structure, and the 'code' parameter of this structure contains a specific notification message.

    Ones of interest to you in this regard are NM_CLICK (mouse left-click) and NM_RCLICK (mouse right-click).

    There are many more notifications sent in this manner which you can also test for, some general to all common controls, some specific to particular common controls.

    If you find that this WM_NOTIFY mechanism is insufficient for your needs then window subclassing, as FillYourBrain has suggested, remains a viable option.

    Hope that helps.

  4. #4
    train spotter
    Join Date
    Aug 2001
    Location
    near a computer
    Posts
    3,868
    and some child windows send their parents callback a WM_PARENTNOTIFY msg for mouse clicks.

    Code:
    case	WM_PARENTNOTIFY:
    {
        //may want to see which control sent the message
        if(WM_RBUTTONDOWN==(WPARAM)wParam)
    "Man alone suffers so excruciatingly in the world that he was compelled to invent laughter."
    Friedrich Nietzsche

    "I spent a lot of my money on booze, birds and fast cars......the rest I squandered."
    George Best

    "If you are going through hell....keep going."
    Winston Churchill

  5. #5
    mustang benny bennyandthejets's Avatar
    Join Date
    Jul 2002
    Posts
    1,401
    WM_NOTIFY works for status bars but not for progress bars. does this mean i have to use window subclassing?

    is the callback procedure mentioned by fillyourbrain similar to a window procedure? if so, how do i specify the procedure for the control?
    [email protected]
    Microsoft Visual Studio .NET 2003 Enterprise Architect
    Windows XP Pro

    Code Tags
    Programming FAQ
    Tutorials

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. GLUT keyboard and mouse func separated
    By krappa in forum Game Programming
    Replies: 1
    Last Post: 04-20-2005, 06:27 PM
  2. DirectInput8 Action Mapping Using Mouse Input
    By LuckY in forum Game Programming
    Replies: 11
    Last Post: 08-09-2004, 12:09 PM
  3. Mouse Events
    By Jubba in forum Windows Programming
    Replies: 1
    Last Post: 10-30-2003, 12:03 PM
  4. I need help disabling Keyboard and Mouse input on Edit controls
    By Templario in forum Windows Programming
    Replies: 4
    Last Post: 01-07-2003, 12:59 AM
  5. Tab Controls - API
    By -KEN- in forum Windows Programming
    Replies: 7
    Last Post: 06-02-2002, 09:44 AM