Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Button behavior - single button multiple behaviour

Button behavior - single button multiple behaviour

Scheduled Pinned Locked Moved C / C++ / MFC
tutorial
1 Posts 1 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    Software_Developer
    wrote on last edited by
    #1

    At 5:35 on the 13th of May 2010, AbhiHcl wrote: >>> >>> Hi, >>> >>> Can I use single button for more than one behaviour. >>> For example one button is devide into 2 parts, >>> If I click on first part minus operation should be performed >>> and click on second part + opeartion should be performed. >>> >>> Yes you can use one single button for more than one behaviour. Here is how. If you have the coordinates of a point in device coordinates and want to find the corresponding position in logcal view - use CDC::DPtoLP to convert the device coordinates to logcal coordinates. Call on OnPrepareDC first to set the mapping mode and factor. For example: Here is a WM_LEFTBUTTONDOWN handler that performs a simple hit test to determine whether the click point lies in the upper or lower half of the logcal view. CPoint objects passed to OnLButtonDown and other mouse message handlers always contain device coordinates so conversion is essential.

    void CMyView::OnLButtonDown(UINT nFlags, CPoint Point)
    {
    CPoint pos=Point;
    CClientDC dc (this);
    OnPrepareDC(&dc); //
    dc.DPtoLP(&pos);
    CSize size=GetTotalSize();
    if(::abs( pos.y ) < (size.cy/2) )
    {
    //Upper half was clicked
    }
    else
    {
    //lower half was clicked
    }

    }

    ...

    1 Reply Last reply
    0
    Reply
    • Reply as topic
    Log in to reply
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes


    • Login

    • Don't have an account? Register

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • World
    • Users
    • Groups