By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
426,165 Members | 1,928 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 426,165 IT Pros & Developers. It's quick & easy.

Can u say how to enable a click event of the picture.

P: 52
HI All!

I am developing a V.B application. in this application, user is able to drag and drop a picture(user control) at run time also. for this purpose, i used form's "dragdrop" event. we know that to move a picture from one place to another place, it's property "dragmode" is set to automatic.

Now the problem started, as my picture's Dragmode is set to automatic, the picture's mouse click event is not working, of course mouse down event is working, but unfortunately, there also the left click event is not working(remaining middle button,right click are working).

and i am not interested to set the dragmode=manual, since i will lose the dragdrop property...
so can u suggest any way to achieve both the events, click and drag drop...?
if question is not clear.. pls let me know that..
Thanks in advance:
regards:
raghunadhs.
Aug 1 '07 #1
Share this Question
Share on Google+
14 Replies


Expert 5K+
P: 8,434
What version of VB are you using?

I think you might just have to sacrifice either the click or the drag functionality.

Hm...

Ok, I've been playing a little. I set the dragmode of a picturebox to manual, then placed this code in its MouseMove event procedure...
Expand|Select|Wrap|Line Numbers
  1. If Button And vbLeftButton Then
  2.   Picture1.Drag 1
  3. End If
It appears to work. Give it a try, and let us know how it goes. Note, I'm working in VB6 - the exact details may vary depending on the version you're using.
Aug 1 '07 #2

P: 52
Just a minute killer, i will look into it... ans will give u feed back..
Thanks:
ragards:
raghunadhs
What version of VB are you using?

I think you might just have to sacrifice either the click or the drag functionality.

Hm...

Ok, I've been playing a little. I set the dragmode of a picturebox to manual, then placed this code in its MouseMove event procedure...
Expand|Select|Wrap|Line Numbers
  1. If Button And vbLeftButton Then
  2.   Picture1.Drag 1
  3. End If
It appears to work. Give it a try, and let us know how it goes. Note, I'm working in VB6 - the exact details may vary depending on the version you're using.
Aug 1 '07 #3

P: 52
Killer, it is working for once only...
Actually, my application is to enable the user to develope his own GUI with my drag and droppable objects. so after dragging and dropping the objects into form once, then also he will be able to move from one place to another place. (like our controls in v.b application), and he also should be able to click the pictures.

As per your suggestion, i set the dragmode property to 1 in mouse movement event, and in form's dragdrop event i set that as 0. so user can click the picture. Now here is the problem, if this property is 0 it does not go to dragdrop event, even user wants to drag and drop the object.suppose if i again set that poperty to 1 in mouse's clik event, then user unable to clik that... (since we can't predict what user will do).
i think what u said is right, that is i should sacrifyone event...

Killer, if u get any other thoughts pls let me know that..

Thanks:
ragards:
raghunadhs
Aug 1 '07 #4

Expert 5K+
P: 8,434
I think you need to read my message agin. I did not touch the DragMode property in the MouseMove event.
Aug 1 '07 #5

P: 52
Hi killer,
I tried with that also but i could be able to work with that properly...of course, i made it liittle bit possible with a timer function. in picture's drag over event, i am using a counter variable whether picture was clicked once or, dragged it some distnce(i am incrementing the counter variable). in timer function every time i am reading the counter variable whether its is 1 or more.. if it is 1 meaning is it was cliked so in timer function i am calling the click event... the problem here is i don't have the mouse up event, so suppose if user press the left key and hold it 25milli seconds then also the the clik event is being occured irrespective of the mouse released. i will try it .. and let u know feed back.

thanks:
regards:
raghunadhs



I think you need to read my message agin. I did not touch the DragMode property in the MouseMove event.
Aug 3 '07 #6

Expert 5K+
P: 8,434
I'd suggest you try the same example that I did. Just create a new project, with a form. Put a picturebox on it. Set the picturebox's DragMode property to manual (actually, I think that's the default). Then bring up the MouseMove event procedure for the picturebox, and add those three lines to start the drag if the left button is down.

On my system, that works as one would normally expect of any normal object in Windows Explorer or wherever. You can click it, or if you hold the button down and start moving, it drags.

All you need then is to add some code to the form to handle when the picturebox is dropped on it, and you'd have a complete sample drag and drop application.
Aug 3 '07 #7

P: 52
Hi Killer,
i want to send my dummy application, what i have developed to you, is there any way to attach my code to this message,,, or else shall i copy and paste the code....

Thanks regrds:
raghunadhs.


I'd suggest you try the same example that I did. Just create a new project, with a form. Put a picturebox on it. Set the picturebox's DragMode property to manual (actually, I think that's the default). Then bring up the MouseMove event procedure for the picturebox, and add those three lines to start the drag if the left button is down.
Aug 6 '07 #8

Expert 5K+
P: 8,434
i want to send my dummy application, what i have developed to you, is there any way to attach my code to this message,,, or else shall i copy and paste the code....
If you want, you can zip it, then attach the zip file to a message. To do that, you have to post the message, then hit the Edit/Delete button to edit it, then use the "manage attachments" entry below the edit box. (You only have five minutes to do this after posting the message).
Aug 6 '07 #9

P: 52
Hi Killer,
now i am sending you a sample application. please have a look on it. here i used a timer function with 50ms. here the problem is if user pressed it and hold the left click button for more than 50ms it will treat it as click evnt evnthogh user releases the left button.
i also made the dragmode property to manual and used mouseup evnt then also it did not work.
if possible please suggest a remedy to it.

and u r saying me that "drag 1" if possible kindly implement it in my application what i am sending. i tried but could not do it successfully..

Thanks:
regards:
raghunadhs.


If you want, you can zip it, then attach the zip file to a message. To do that, you have to post the message, then hit the Edit/Delete button to edit it, then use the "manage attachments" entry below the edit box. (You only have five minutes to do this after posting the message).
Attached Files
File Type: zip DragDrop_own_6.zip (5.8 KB, 61 views)
Aug 7 '07 #10

P: 52
Hi Killer,
I am waiting for your reply. pls have a look on my application which is attached to previous thread, and suggest me, what to do? if possible send me the sample applicaton what u developed. i could not be able to achieve it thoug "drag" property....

Thanks:
regards:
raghunadhs

[quote=raghunadhs]Hi Killer,
now i am sending you a sample application. please have a look on it. here i used a timer function with 50ms. here the problem is if user pressed it and hold the left click button for more than 50ms it will treat it as click evnt evnthogh user releases the left button.
Aug 11 '07 #11

Expert 5K+
P: 8,434
Sorry for the delay, been very busy. I will have a look at it ASAP.
Aug 14 '07 #12

Expert 5K+
P: 8,434
I think I got it working properly.

I did the following...
  • Set DragMode of Picture1 to Manual.
  • In Timer1_Timer event procedure, commented out Call Picture1_Click(intIndex)
  • In Picture1_MouseMove event procedure, inserted (as I suggested earlier)...
    Expand|Select|Wrap|Line Numbers
    1. If Button And vbLeftButton Then
    2.   Picture1(Index).Drag 1
    3. End If
  • Um... I think that's it.
Aug 15 '07 #13

P: 52
Great Killer,
Its working. Thanks alot.
regards:
raghunadhs.


I think I got it working properly.

I did the following...
  • Set DragMode of Picture1 to Manual.
  • In Timer1_Timer event procedure, commented out Call Picture1_Click(intIndex)
  • In Picture1_MouseMove event procedure, inserted (as I suggested earlier)...
    Expand|Select|Wrap|Line Numbers
    1. If Button And vbLeftButton Then
    2.   Picture1(Index).Drag 1
    3. End If
  • Um... I think that's it.
Aug 17 '07 #14

Expert 5K+
P: 8,434
Its working.
Great! Glad to hear it.
Aug 17 '07 #15

Post your reply

Sign in to post your reply or Sign up for a free account.