Click here to Skip to main content
15,917,538 members
Please Sign up or sign in to vote.
4.71/5 (6 votes)
See more:
Hi,

I am working on a windows application where the user should be able to move,resize and drag and drop a control (a Textbox in my case).


I am pretty much ok with the moving and drag and drop except that I cant differentiate between MouseDown and Click events, because everytime I press the mouse button on the control the MouseDown event fires up and I cant really use the click event. Is there a way that i can differentiate between MouseDown and Single Click.

Second: I am trying to highlight the control when the user selects the objects so that I highlight the control or get that resizing rectangle around the control so that user can drag it to resize the object. Something we do while creating a application (we add a control on the form and then resize it) . Can any one please help me out with this.


Thanks

Posted

As for differentiating MouseDown from Click, you can start a timer when MouseDown is fired. If you get a MouseUp before the timer expires, then it's a Click, otherwise it's starting a drag-and-drop.

Highlighting the control can be done for example by using the OnPaint event and adding GDI+ code to draw your highlighting depending on the component status (drag-and-drop active or inactive).

 
Share this answer
 
v2
eg_Anubhava wrote:
user should be able to move,resize and drag and drop a control (a Textbox in my case).


I'll leave it to others to help you with most of this, but you might find it difficult to resize a TextBox, depending on what properties are set. AFAIK you can only resize a non-multiline TextBox horizontally, so you will need to consider this when implementing your drag-handles. :)

 
Share this answer
 
v2


CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900