WM_LBUTTONDOWN for edit controls?

In summary, the conversation discusses setting focus to edit control boxes using the WM_LBUTTONDOWN message, with the speaker having successfully implemented setfocus events and the OnOK override event with the "Enter" key. They are seeking advice on how to set focus to the edit control when clicked with the mouse and are recommended to post their question on codeguru.com or codeproject.com.
  • #1
sweetjones
44
0
Hi, I have 4 edit control boxes that I need to except the WM_LBUTTONDOWN message to set focus to them when clicked with the mouse. I have the setfocus events working perfectly. I even manipulated the OnOK override event with the "Enter" key to go to the next edit control box when pressed and send the SetFocus() to them. I just need to know how to set the focus to the edit control when the edit control is clicked with the mouse? If you need a scenario of the problem I would be more than happy to give one. I am using VS2005 C++ and MFC. Thanx In Advance!
 
Technology news on Phys.org
  • #2
I suggest
you can go to the codeguru.com or codeproject.com to post these question on their forums.
 
  • #3


I am not an expert in programming or computer science. However, based on my understanding, it seems like you are trying to set the focus to an edit control when it is clicked with the mouse. In this case, you can use the WM_LBUTTONDOWN message to handle the mouse click event and then use the SetFocus() function to set the focus to the desired edit control.

It is also worth mentioning that the OnOK override event and the "Enter" key may not be the best approach to handle mouse clicks. It would be more efficient to use the WM_LBUTTONDOWN message directly.

I hope this helps and if you need a specific scenario for further assistance, please feel free to provide one.
 

1. What is WM_LBUTTONDOWN for edit controls?

WM_LBUTTONDOWN is a message that is sent to an edit control when the left mouse button is clicked within the control's client area.

2. How do I handle WM_LBUTTONDOWN for edit controls?

To handle WM_LBUTTONDOWN for edit controls, you must first create a window procedure for the edit control and then use the SetWindowLongPtr function to set the new window procedure. Within the window procedure, you can handle the WM_LBUTTONDOWN message by using the GetCursorPos and ScreenToClient functions to get the coordinates of the mouse click and determine if it falls within the edit control's client area.

3. Can I customize the behavior of WM_LBUTTONDOWN for edit controls?

Yes, you can customize the behavior of WM_LBUTTONDOWN for edit controls by handling the message in your window procedure. You can perform different actions based on the coordinates of the mouse click, such as selecting text or inserting new text at that location.

4. Are there any other messages related to WM_LBUTTONDOWN for edit controls?

Yes, there are several other mouse-related messages that can be sent to an edit control, including WM_LBUTTONUP, WM_MOUSEMOVE, and WM_MOUSEWHEEL. These messages can be handled in the same window procedure as WM_LBUTTONDOWN to create more complex mouse interactions within the edit control.

5. Can I use WM_LBUTTONDOWN for edit controls in any programming language?

Yes, WM_LBUTTONDOWN is a standard Windows message and can be used in any programming language that supports Windows API programming, such as C++, C#, or Visual Basic. However, the specific implementation may vary slightly depending on the language and its associated libraries or frameworks.

Similar threads

  • Programming and Computer Science
Replies
11
Views
2K
  • Programming and Computer Science
Replies
1
Views
1K
Replies
21
Views
3K
  • Programming and Computer Science
Replies
5
Views
1K
  • Programming and Computer Science
Replies
1
Views
2K
  • Electrical Engineering
Replies
12
Views
2K
Replies
4
Views
1K
  • Programming and Computer Science
Replies
1
Views
1K
  • Feedback and Announcements
Replies
3
Views
858
Replies
37
Views
3K
Back
Top