Home All Groups Group Topic Archive Search About

Don't understand this warning message

Author
10 Jul 2006 2:05 PM
Terry
Hi,
I copied the following code segment from the VS2005 Help on the MouseDown
event.
Private Sub panel1_MouseDown(ByVal sender As Object, ByVal e As
System.Windows.Forms.MouseEventArgs) Handles panel1.MouseDown
.....
Select Case e.Button
   Case MouseButtons.Left               <-Warning
      eventString = "L"
   Case MouseButtons.Right             <-Warning
      eventString = "R"
   Case MouseButtons.Middle            <-Warning
      eventString = "M"
.....etc.
the warning message is: Warning Access of shared member, constant member,
enum member or nested type through an instance; qualifying expression will
not be evaluated.   
I just don't see how MouseButtons.Right (etc) is refering to an instance. 
The recomended fix is to replace MouseButtons with Windows.Forms.MouseButtons.
--
Terry

Author
10 Jul 2006 2:24 PM
Claes Bergefall
MouseButtons is also a property in the Control class and since your code is
(I assume) inside a Form or similar it thinks you're refering to that
property instead of the enum. Hence the warning.

   /claes

Show quoteHide quote
"Terry" <Terry@nospam.nospam> wrote in message
news:5A7DBED8-B7F8-492D-AC01-EF715E2D5233@microsoft.com...
> Hi,
> I copied the following code segment from the VS2005 Help on the MouseDown
> event.
> Private Sub panel1_MouseDown(ByVal sender As Object, ByVal e As
> System.Windows.Forms.MouseEventArgs) Handles panel1.MouseDown
> ....
> Select Case e.Button
>   Case MouseButtons.Left               <-Warning
>      eventString = "L"
>   Case MouseButtons.Right             <-Warning
>      eventString = "R"
>   Case MouseButtons.Middle            <-Warning
>      eventString = "M"
> ....etc.
> the warning message is: Warning Access of shared member, constant member,
> enum member or nested type through an instance; qualifying expression will
> not be evaluated.
> I just don't see how MouseButtons.Right (etc) is refering to an instance.
> The recomended fix is to replace MouseButtons with
> Windows.Forms.MouseButtons.
> --
> Terry
Author
10 Jul 2006 2:32 PM
Terry
Hi Claes,
   Thanks - I was just getting there myself.  'MouseButtons' is a property
of System.Windows.Forms.Form, which of course, this form inherits.
Thanks,
--
Terry


Show quoteHide quote
"Claes Bergefall" wrote:

> MouseButtons is also a property in the Control class and since your code is
> (I assume) inside a Form or similar it thinks you're refering to that
> property instead of the enum. Hence the warning.
>
>    /claes
>
> "Terry" <Terry@nospam.nospam> wrote in message
> news:5A7DBED8-B7F8-492D-AC01-EF715E2D5233@microsoft.com...
> > Hi,
> > I copied the following code segment from the VS2005 Help on the MouseDown
> > event.
> > Private Sub panel1_MouseDown(ByVal sender As Object, ByVal e As
> > System.Windows.Forms.MouseEventArgs) Handles panel1.MouseDown
> > ....
> > Select Case e.Button
> >   Case MouseButtons.Left               <-Warning
> >      eventString = "L"
> >   Case MouseButtons.Right             <-Warning
> >      eventString = "R"
> >   Case MouseButtons.Middle            <-Warning
> >      eventString = "M"
> > ....etc.
> > the warning message is: Warning Access of shared member, constant member,
> > enum member or nested type through an instance; qualifying expression will
> > not be evaluated.
> > I just don't see how MouseButtons.Right (etc) is refering to an instance.
> > The recomended fix is to replace MouseButtons with
> > Windows.Forms.MouseButtons.
> > --
> > Terry
>
>
>