Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

OnButtonup and onbuttondown

Posted on 2004-10-24
10
Medium Priority
?
836 Views
Last Modified: 2013-11-20
Hi, could anyone provide me some sample codes on how to do a seperate control for onbuttoup and for onbuttondown please?
I know OnLButtonDown and OnLButtonUp is needed , but i do not know how to use it. Could anyone teach me how to do it please?
Thanks
0
Comment
Question by:mwcmp
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
10 Comments
 
LVL 12

Accepted Solution

by:
OnegaZhang earned 500 total points
ID: 12397244

add two message handlers WM_LBUTTONDOWN  and WM_LBUTTONUP
when left mouse button is down, OnLButtonDown is being called.
0
 
LVL 6

Assisted Solution

by:Amritpal Singh
Amritpal Singh earned 500 total points
ID: 12397471
have a look at the sample at the following link

http://www.funducode.com/freevc/mouse_vc/mouse_vc3.asp
0
 
LVL 2

Assisted Solution

by:Ruskialt
Ruskialt earned 500 total points
ID: 12397583
As OnegaZhang points out you need WM_LBUTTONDOWN and WM_LBUTTONUP messages.

You can use the class wizard to add messages to the message map, or you can add them manually. Right click the class in the project tree to use wizard. The messagemap entries for button up/down look like this in my CMapView class (a CView descendant)

BEGIN_MESSAGE_MAP(CMapView, CView)
  ON_WM_LBUTTONDOWN()
  ON_WM_LBUTTONUP()
END_MESSAGE_MAP()

Your class member function looks like this

afx_msg void OnLButtonDown( UINT nFlags, CPoint point );
afx_msg void OnLButtonUp( UINT nFlags, CPoint point );

The "nFlags" are typically used to identify if control of shift is down. The "point" is the mouse position when clicked. Press F1 in the source window with the cursor on the "ON_WM_LBUTTONDOWN()", and you will find the info you need.

Good luck
Ruskialt
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 

Author Comment

by:mwcmp
ID: 12442098
ah...i'm sorry...i forgot to add that i need the onbuttonup and onbuttondown to be implemented on a Cbutton. WM_LBUTTONDOWN  only works for the whole MFC but not on the button...
0
 
LVL 2

Expert Comment

by:Ruskialt
ID: 12443841
Is the button placed in your own dialog, created in the resource editor maybe?
0
 

Author Comment

by:mwcmp
ID: 12457133
it's placed in my own dialog , created using the class wizard
0
 
LVL 1

Assisted Solution

by:suryaxchange
suryaxchange earned 500 total points
ID: 12838003
Hi,
    If you wnat to implement onbuttonup and onbuttondown to be implemented on a Cbutton.
Derive a class from CButton and handle these messages (onbuttonup and onbuttondown )there and create the Button object with the derive class. If you don't want to derive it then override WindowProc and when WM_LBUTTONDOWN()  WM_LBUTTONUP() are encountered then check the window handle with the button handle, if they equal then user has clicken on the button.

-Surya
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this article, I'll describe -- and show pictures of -- some of the significant additions that have been made available to programmers in the MFC Feature Pack for Visual C++ 2008.  These same feature are in the MFC libraries that come with Visual …
If you use Adobe Reader X it is possible you can't open OLE PDF documents in the standard. The reason is the 'save box mode' in adobe reader X. Many people think the protected Mode of adobe reader x is only to stop the write access. But this fe…
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …
Suggested Courses

618 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