Hello
this is the click event method of a radio button
private void radioButton1_Cl ick(object sender, EventArgs e)
{
}
what i want to do is Within this event method check is the left mouse
button has been pressed.
I cant seem to derive MouseEventArgs from this methods EventArgs.
Is there a way to cast it ?
I dont want to use onmousedown event, i want to have all my code in
this specific event method.
thanks for any help
Peted 4 9586
On May 10, 11:14 am, Peted wrote:
Hello
this is the click event method of a radio button
private void radioButton1_Cl ick(object sender, EventArgs e)
{
}
what i want to do is Within this event method check is the left mouse
button has been pressed.
I cant seem to derive MouseEventArgs from this methods EventArgs.
Is there a way to cast it ?
I dont want to use onmousedown event, i want to have all my code in
this specific event method.
thanks for any help
Peted
On May 10, 11:14 am, Peted wrote:
Hello
this is the click event method of a radio button
private void radioButton1_Cl ick(object sender, EventArgs e)
{
}
what i want to do is Within this event method check is the left mouse
button has been pressed.
I cant seem to derive MouseEventArgs from this methods EventArgs.
Is there a way to cast it ?
I dont want to use onmousedown event, i want to have all my code in
this specific event method.
thanks for any help
Peted
Peted,
Casting the event args to MouseEventArgs will do no good. Who said the
type of EventArgs given in the Click event is MouseEventArgs?
To accomplish your needs I would suggest using the MouseDown or
MouseUp Events or get the mouse state in the Click event handler using
P/Invoke like this:
using System.Runtime. InteropServices ;
class KeyInfo
{
[DllImport("user 32")]
private static extern short GetKeyState(int vKey);
private const int VK_LBUTTON = 0x1;
private const int VK_RBUTTON = 0x2;
public static short IsLButtonDown() {
short keyState = GetKeyState((in t)VK_LBUTTON);
return (keyState 0 ? keyState >0x10
: (keyState >0x10) & 0x1) == 1;
}
}
of course you can adjust the code for your needs...
Hope this helps.
I think that going the interop route is a bit much.
Rather, what the OP should do is move his code out to a separate method
(so he can contain it all in one place) and parameterize it so that it can
take which mouse button was clicked.
The OP also has to subscribe to the MouseDown and MouseUp events (for a
click, you want the MouseUp event) to determine which button was clicked.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard. caspershouse.co m
"Moty Michaely" <Mo*****@gmail. comwrote in message
news:11******** **************@ e51g2000hsg.goo glegroups.com.. .
On May 10, 11:14 am, Peted wrote:
>Hello
this is the click event method of a radio button
private void radioButton1_Cl ick(object sender, EventArgs e) {
}
what i want to do is Within this event method check is the left mouse button has been pressed.
I cant seem to derive MouseEventArgs from this methods EventArgs.
Is there a way to cast it ?
I dont want to use onmousedown event, i want to have all my code in this specific event method.
thanks for any help
Peted
On May 10, 11:14 am, Peted wrote:
>Hello
this is the click event method of a radio button
private void radioButton1_Cl ick(object sender, EventArgs e) {
}
what i want to do is Within this event method check is the left mouse button has been pressed.
I cant seem to derive MouseEventArgs from this methods EventArgs.
Is there a way to cast it ?
I dont want to use onmousedown event, i want to have all my code in this specific event method.
thanks for any help
Peted
Peted,
Casting the event args to MouseEventArgs will do no good. Who said the
type of EventArgs given in the Click event is MouseEventArgs?
To accomplish your needs I would suggest using the MouseDown or
MouseUp Events or get the mouse state in the Click event handler using
P/Invoke like this:
using System.Runtime. InteropServices ;
class KeyInfo
{
[DllImport("user 32")]
private static extern short GetKeyState(int vKey);
private const int VK_LBUTTON = 0x1;
private const int VK_RBUTTON = 0x2;
public static short IsLButtonDown() {
short keyState = GetKeyState((in t)VK_LBUTTON);
return (keyState 0 ? keyState >0x10
: (keyState >0x10) & 0x1) == 1;
}
}
of course you can adjust the code for your needs...
Hope this helps.
You can also try the static Form.MouseButto ns property to find out which
buttons are already pressed.
Note that this will tell you which buttons are currently pressed at the time
you check it; it will not notify you when a button becomes pressed as
MouseDown will, but if I read your post right, you are only wanting to check
the current state of the left button. Form.MouseButto nsn will tell you.
--
Brian Schwartz
FishNet Components http://www.fishnetcomponents.com
Fish Grid .NET Light: Powerful Layouts for Small Datasets
<Petedwrote in message news:lr******** *************** *********@4ax.c om...
Hello
this is the click event method of a radio button
private void radioButton1_Cl ick(object sender, EventArgs e)
{
}
what i want to do is Within this event method check is the left mouse
button has been pressed.
I cant seem to derive MouseEventArgs from this methods EventArgs.
Is there a way to cast it ?
I dont want to use onmousedown event, i want to have all my code in
this specific event method.
thanks for any help
Peted
thanks
all
On Thu, 10 May 2007 16:14:56 +0800, Peted wrote:
>Hello
this is the click event method of a radio button
private void radioButton1_Cl ick(object sender, EventArgs e)
{
}
what i want to do is Within this event method check is the left mouse button has been pressed.
I cant seem to derive MouseEventArgs from this methods EventArgs.
Is there a way to cast it ?
I dont want to use onmousedown event, i want to have all my code in this specific event method.
thanks for any help
Peted
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Sujith Jagini |
last post by:
Hi,
When we create customEventArgs, we derive the classes from
eventArgs( ) and I dont understand the advantage of this inheritance.
This is neither an interface nor applied as attribute.
I have seen similar stuff in remoting also where we derive from
marshallByRef object in SAO to create transparent proxy. How it
creates transparent...
|
by: Gates72 |
last post by:
Hello All,
I am looking for an example showing a custom EventArgs
class that derives from CancelEventsArgs, and a form or
control using that class in a custom event.
The simpler, the better, but I'll take anything...
Thanks,
G72
|
by: Yangtsi River |
last post by:
Hi,
in any event procudure,there is two paras:sender As Object, e As EventArgs,
i copied them-not know what they are about, and my ASPX works.
I guess the sender is the control by which I triggered this sub, and what is
EventArgs then?
I am passing a third para to the sub, that is mysub("jim",sender As Object,
e As EventArgs),
the sub...
|
by: rom |
last post by:
i want to call a sub in vb.net like:
Private Sub X(ByVal sender As Object, ByVal e As
System.Web.UI.WebControls.RepeaterItemEventArgs)
where the second argument can sometimes be
RepeaterCommandEventArgs or any other kind of this
eventargs thing......
is there a way that I can call the function by myself? i
can send as first parameter the...
|
by: Sujith Jagini |
last post by:
Hi,
When we create customEventArgs, we also derive the classes from
eventArgs( ) and I dont understand the advantage of this inheritance.
This is neither an interface nor applied as attribute.
I have seen similar stuff in remoting also where we derive from
marshallByRef object in SAO to create transparent proxy. I don't know
how it...
| |
by: Sujith Jagini |
last post by:
Hi,
When we create customEventArgs, we derive the classes from
eventArgs( ) and I dont understand the advantage of this inheritance.
This is neither an interface nor applied as attribute.
I have seen similar stuff in remoting also where we derive from
marshallByRef object in SAO to create transparent proxy. How it
creates transparent...
|
by: Sujith Jagini |
last post by:
Hi,
When we create customEventArgs, we also derive the classes from
eventArgs( ) and I dont understand the advantage of this inheritance.
This is neither an interface nor applied as attribute.
I have seen similar stuff in remoting also where we derive from
marshallByRef object in SAO to create transparent proxy. I don't know
how it...
|
by: Sam |
last post by:
Hi,
Protected Overrides Sub OnControlAdded(ByVal e As
System.Windows.Forms.ControlEventArgs)
AddHandler e.Control.MouseMove, DirectCast(CheckCursor(),
System.Windows.Forms.MouseEventHandler)
End Sub
The above code is to redirect the MouseMove event of any controls added
to my panel to the method CheckCursor. This works except that
|
by: Michael.Suarez |
last post by:
Consider the TextBox Control. It has a KeyPress event of type
KeyPressEventHandler which passes a KeyPressEventArgs to whatever
method is assigned to the event.
When you set e.Handled = false within the assigned method, it disallows
the keypress.
Suppose I have a usercontrol consisting of a textbox, a button, and a
listview. When the...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language...
| |
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it. ...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |