Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: VB
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 10-Aug-09 19:17pm
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

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).

  Permalink  
v2
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

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. Smile | :)

  Permalink  
v2
  Print Answers RSS
0 OriginalGriff 410
1 Jochen Arndt 200
2 Richard MacCutchan 135
3 DamithSL 105
4 PIEBALDconsult 90
0 OriginalGriff 6,045
1 DamithSL 4,601
2 Maciej Los 4,032
3 Kornfeld Eliyahu Peter 3,480
4 Sergey Alexandrovich Kryukov 3,220


Advertise | Privacy | Mobile
Web01 | 2.8.141220.1 | Last Updated 31 Jan 2011
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100