Detecting the Mouse-Click
Detecting the Mouse-Click
Detecting the Mouse-Click
Detecting the Mouse-Click
Detecting the Mouse-Click
Detecting the Mouse-Click Detecting the Mouse-Click Detecting the Mouse-Click Detecting the Mouse-Click Detecting the Mouse-Click Detecting the Mouse-Click Detecting the Mouse-Click Detecting the Mouse-Click
Detecting the Mouse-Click Detecting the Mouse-Click
Detecting the Mouse-Click
Go Back  Xtreme Visual Basic Talk > > > Detecting the Mouse-Click


Reply
 
Thread Tools Display Modes
  #21  
Old 06-29-2004, 03:29 PM
Omnibus Omnibus is offline
Regular
 
Join Date: Jun 2004
Posts: 85
Default


Quote:
Originally Posted by bear24rw
i dont understand....
Let me post again the structure of the from in which I want this done:

Code:
Imports System.Drawing.Drawing2D
Imports System.IO

Public Class Form3
Inherits System.Windows.Forms.Form

<various Dim statements …>

[Windows Form Designer generated code]

Protected Overrides Sub OnPaint(ByVal e As System.Windows.Forms.PaintEventArgs)

<some code plotting a curve from a data-file>
Right here further execution of the code should be interrupted until the mouse is clicked twice so that the X1 and X2 acquire values.

Once X1 and X2 have acquired values through clicking twice on the mouse-button, the procedure can continue:

Code:
<here’s some more code using the above-obtained values of X1 and X2>

End Sub
End Class
Reply With Quote
  #22  
Old 06-29-2004, 03:39 PM
Omnibus Omnibus is offline
Regular
 
Join Date: Jun 2004
Posts: 85
Default

Quote:
Originally Posted by bear24rw
i dont understand....

EDIT: i think i get it.... put everything inside the sub into a boolean

Code:
Dim allowed As Boolean Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click If allowed = True Then 'do you stuff here end If End sub

and set the boolean to false until you are ready to execute it then set boolean to true and click the button and everything will work....
I tried that but it is in conflict with the Protected Overrides somehow ... The whole thing has to be done within the Protected Overrides Sub-End Sub structure, it seems ...

EDIT: Tried it also with calling a separate sub which I named valueX1 ... didn't work ... Also, with a separate Function ... didn't work either ...
Reply With Quote
  #23  
Old 06-29-2004, 03:41 PM
bear24rw's Avatar
bear24rw bear24rw is offline
Contributor
 
Join Date: May 2004
Location: NJ
Posts: 477
Default

hmmm.... the only thing right now that i can think of is putting a boolean around every other event and set it to false once the mouse is clikced and then after X = 2 set them all to true and the button click event boolean to false.... but i dont think that is really the best way to do it....
Reply With Quote
  #24  
Old 06-29-2004, 03:46 PM
Omnibus Omnibus is offline
Regular
 
Join Date: Jun 2004
Posts: 85
Default

Quote:
Originally Posted by bear24rw
hmmm.... the only thing right now that i can think of is putting a boolean around every other event and set it to false once the mouse is clikced and then after X = 2 set them all to true and the button click event boolean to false.... but i dont think that is really the best way to do it....
Maybe somehow by starting a thread that loops forever until X = 2 becomes true. Then the main thread should handle the mouse click and should set the global variable. Something like that ... Can't figure out exactly how, though ...
Reply With Quote
  #25  
Old 06-29-2004, 04:39 PM
Iceplug's Avatar
IceplugDetecting the Mouse-Click Iceplug is offline
MetaCenturion

Retired Moderator
* Guru *
 
Join Date: Aug 2001
Location: Iowa, USA
Posts: 16,583
Default

What does your code look like now? I'm a little lost as to what the problem is now.

The case of the X shouldn't be a problem as you are accessing one from the pt.
To transfer information from one form to another, you need to add a reference to the other form.
__________________

Iceplug, USN
Quadrill 1 Quadrill 2 (full) Quadrill 3 JumpCross .NET Website is ALIVE! - DL Platform Tour for VB.NET! Posting Guidelines Hint: Specify your location in your user cp profile if you want compassion!
Reply With Quote
  #26  
Old 06-29-2004, 05:11 PM
Omnibus Omnibus is offline
Regular
 
Join Date: Jun 2004
Posts: 85
Default

Quote:
Originally Posted by Iceplug
What does your code look like now? I'm a little lost as to what the problem is now.

The case of the X shouldn't be a problem as you are accessing one from the pt.
To transfer information from one form to another, you need to add a reference to the other form.
I think I fixed the problem with the X by renaming my former x as x_. Also, for now I abandoned the idea with the additional transparent frame and am still back to the beginning -- how does one detect clicking of the mouse-button? If this event (the mouse-clicking) could be detected, the rest seems resolved -- once the mouse-click is detected the flag is raised and a subroutine is executed which places the value of the x-coordinate in X1. On second clicking, the subroutine invoked places the value of another x-coordinate into X2.
Reply With Quote
  #27  
Old 06-29-2004, 05:19 PM
Iceplug's Avatar
IceplugDetecting the Mouse-Click Iceplug is offline
MetaCenturion

Retired Moderator
* Guru *
 
Join Date: Aug 2001
Location: Iowa, USA
Posts: 16,583
Default

And neither the Click nor the MouseDown events are working because? A naming problem? Data coming too late?
__________________

Iceplug, USN
Quadrill 1 Quadrill 2 (full) Quadrill 3 JumpCross .NET Website is ALIVE! - DL Platform Tour for VB.NET! Posting Guidelines Hint: Specify your location in your user cp profile if you want compassion!
Reply With Quote
  #28  
Old 06-29-2004, 05:41 PM
Omnibus Omnibus is offline
Regular
 
Join Date: Jun 2004
Posts: 85
Default

Quote:
Originally Posted by Iceplug
And neither the Click nor the MouseDown events are working because? A naming problem? Data coming too late?
See, the problem is that the whole plot is completed up to this moment:

Code:
 Imports System.Drawing.Drawing2D
Imports System.IO

Public Class Form3
Inherits System.Windows.Forms.Form

<various Dim statements …>

[Windows Form Designer generated code]

Protected Overrides Sub OnPaint(ByVal e As System.Windows.Forms.PaintEventArgs)

<some code plotting a curve from a data-file>
Now, we have a plot on the screen from which two points are to be chosen (think as if we want to digitize the curve plottrd on the screen). To choose these two points one has to place the cursor and click the mouse button at their respective locations (this has to be done obviously twice). This will place values in X1 and X2 which will be used in the rest part of the code:

Code:
 <here’s some more code using the above-obtained values of X1 and X2>

End Sub
End Class
Now, here is the problem. How are these two mouse-clicks detected so that a special sub be invoked which is designed to place values in X1, respectively X2? If one doesn’t have a way to detect that mouse-clicks have occurred, the said subroutine will not be invoked and no values will be placed in X1 and X2. As you see, this is the problem I was having at the very beginning -- how is a mouse-click detected in VB.NET? I wonder what the corresponding code in VB.NET would be to the one presented here:

http://www.codeguru.com/vb/gen/vb_mi...cle.php/c2757/
Reply With Quote
  #29  
Old 06-29-2004, 06:12 PM
Iceplug's Avatar
IceplugDetecting the Mouse-Click Iceplug is offline
MetaCenturion

Retired Moderator
* Guru *
 
Join Date: Aug 2001
Location: Iowa, USA
Posts: 16,583
Default

So, you are trying to detect a mouse click anywhere?
You can use APIs in .NET, just remember that 16-bit Integers in VB6 are now 16-bit Short in VB.NET, and 32-bit Longs are 32-bit Integer.
__________________

Iceplug, USN
Quadrill 1 Quadrill 2 (full) Quadrill 3 JumpCross .NET Website is ALIVE! - DL Platform Tour for VB.NET! Posting Guidelines Hint: Specify your location in your user cp profile if you want compassion!
Reply With Quote
  #30  
Old 06-30-2004, 10:50 AM
Omnibus Omnibus is offline
Regular
 
Join Date: Jun 2004
Posts: 85
Default

bear24rw and Iceplug, thank you very much for your help. Now I have it working with the overlaid second transparent frame which I explained in one of my previous postings. In the future I may try to apply the API method Iceplug referred to but for now I’ll stay with this solution because it seems to work just fine.
Reply With Quote
  #31  
Old 06-30-2004, 11:54 AM
bear24rw's Avatar
bear24rw bear24rw is offline
Contributor
 
Join Date: May 2004
Location: NJ
Posts: 477
Default

np
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
Detecting the Mouse-Click
Detecting the Mouse-Click
Detecting the Mouse-Click Detecting the Mouse-Click
Detecting the Mouse-Click
Detecting the Mouse-Click
Detecting the Mouse-Click Detecting the Mouse-Click Detecting the Mouse-Click Detecting the Mouse-Click Detecting the Mouse-Click Detecting the Mouse-Click Detecting the Mouse-Click
Detecting the Mouse-Click
Detecting the Mouse-Click
 
Detecting the Mouse-Click
Detecting the Mouse-Click
 
-->