PC Review Forums Newsgroups Microsoft DotNet Microsoft VB .NET The below snippet does not work...anyone know how to reference a procedure?

Reply

The below snippet does not work...anyone know how to reference a procedure?

 
Thread Tools Rate Thread
Old 13-12-2006, 03:10 PM   #1
Marc
Guest
 
Posts: n/a
Default The below snippet does not work...anyone know how to reference a procedure?



The below snippet does not work...anyone know how to reference the
procedure 'DrawCross()'?



Private Sub MarkVORToolStripMenuItem_Click(ByVal sender As
System.Object, ByVal e As System.EventArgs) Handles
MarkVORToolStripMenuItem.Click
If ContextMenuStrip1.SourceControl.BackgroundImage Is
DrawCross() Then
msgbocx("test")
End If
End Sub


Friend Function DrawCross() As Bitmap
Dim sampleBitmap As New Bitmap(32, 32)
Dim g As Graphics = Graphics.FromImage(sampleBitmap)
Dim p As New Pen(ProfessionalColors.ButtonPressedBorder)
p.Color = Color.Red
Try
p.Width = 2
g.DrawLine(p, -35, 65, 80, -45)
g.DrawLine(p, 200, 200, 0, 0)
Finally
p.Dispose()
End Try
Return sampleBitmap
End Function

  Reply With Quote
Old 13-12-2006, 03:24 PM   #2
Andrew Morton
Guest
 
Posts: n/a
Default Re: The below snippet does not work...anyone know how to reference a procedure?

Marc wrote:
> The below snippet does not work...anyone know how to reference the
> procedure 'DrawCross()'?


Every time you call DrawCross(), you're generating a new instance of a
bitmap. That will never be the same instance you assigned to the
BackgroundImage.

The "is" operator is not a bitmap comparison operator. (Unless you were to
overload it.)

How about making your own extended MyContextMenuStrip inherits from
ContextMenuStrip and has a String property you can set to change the
BackgroundImage? (My nomenclature may be wrong.)

Andrew

> Private Sub MarkVORToolStripMenuItem_Click(ByVal sender As
> System.Object, ByVal e As System.EventArgs) Handles
> MarkVORToolStripMenuItem.Click
> If ContextMenuStrip1.SourceControl.BackgroundImage Is
> DrawCross() Then
> msgbocx("test")
> End If
> End Sub
>
>
> Friend Function DrawCross() As Bitmap
> Dim sampleBitmap As New Bitmap(32, 32)
> Dim g As Graphics = Graphics.FromImage(sampleBitmap)
> Dim p As New Pen(ProfessionalColors.ButtonPressedBorder)
> p.Color = Color.Red
> Try
> p.Width = 2
> g.DrawLine(p, -35, 65, 80, -45)
> g.DrawLine(p, 200, 200, 0, 0)
> Finally
> p.Dispose()
> End Try
> Return sampleBitmap
> End Function



  Reply With Quote
Old 13-12-2006, 03:33 PM   #3
Marc
Guest
 
Posts: n/a
Default Re: The below snippet does not work...anyone know how to reference a procedure?

Hi Andrew,

Could you give me an example of how i would do that?

Im sorry but im really a transport manager pretending to be a
programmer so my knowledge is basic!!!


Andrew Morton wrote:
> Marc wrote:
> > The below snippet does not work...anyone know how to reference the
> > procedure 'DrawCross()'?

>
> Every time you call DrawCross(), you're generating a new instance of a
> bitmap. That will never be the same instance you assigned to the
> BackgroundImage.
>
> The "is" operator is not a bitmap comparison operator. (Unless you were to
> overload it.)
>
> How about making your own extended MyContextMenuStrip inherits from
> ContextMenuStrip and has a String property you can set to change the
> BackgroundImage? (My nomenclature may be wrong.)
>
> Andrew
>
> > Private Sub MarkVORToolStripMenuItem_Click(ByVal sender As
> > System.Object, ByVal e As System.EventArgs) Handles
> > MarkVORToolStripMenuItem.Click
> > If ContextMenuStrip1.SourceControl.BackgroundImage Is
> > DrawCross() Then
> > msgbocx("test")
> > End If
> > End Sub
> >
> >
> > Friend Function DrawCross() As Bitmap
> > Dim sampleBitmap As New Bitmap(32, 32)
> > Dim g As Graphics = Graphics.FromImage(sampleBitmap)
> > Dim p As New Pen(ProfessionalColors.ButtonPressedBorder)
> > p.Color = Color.Red
> > Try
> > p.Width = 2
> > g.DrawLine(p, -35, 65, 80, -45)
> > g.DrawLine(p, 200, 200, 0, 0)
> > Finally
> > p.Dispose()
> > End Try
> > Return sampleBitmap
> > End Function


  Reply With Quote
Old 13-12-2006, 03:48 PM   #4
Andrew Morton
Guest
 
Posts: n/a
Default Re: The below snippet does not work...anyone know how to reference a procedure?

Marc wrote:
> Andrew Morton wrote:
>> Marc wrote:
>>> The below snippet does not work...anyone know how to reference the
>>> procedure 'DrawCross()'?

>>
>> Every time you call DrawCross(), you're generating a new instance of
>> a bitmap. That will never be the same instance you assigned to the
>> BackgroundImage.
>>
>> The "is" operator is not a bitmap comparison operator. (Unless you
>> were to overload it.)
>>
>> How about making your own extended MyContextMenuStrip inherits from
>> ContextMenuStrip and has a String property you can set to change the
>> BackgroundImage? (My nomenclature may be wrong.)
>>


> Hi Andrew,
>
> Could you give me an example of how i would do that?
>
> Im sorry but im really a transport manager pretending to be a
> programmer so my knowledge is basic!!!


[Please bottom-post in this newsgroup.]

You'll have to wait for someone who knows about ContextMenuStrip as it isn't
in the VS2003/.NET1.1 I have. And anyway, I have to admit to only knowing
the principle of this Inherits thing; I've never needed to use it, other
than what VS sticks in the code for me.

Andrew


  Reply With Quote
Old 13-12-2006, 05:47 PM   #5
jeff
Guest
 
Posts: n/a
Default Re: The below snippet does not work...anyone know how to reference a procedure?


why do you have to bottom post???


"Andrew Morton" <akm@in-press.co.uk.invalid> wrote in message
news:u5J2U5sHHHA.924@TK2MSFTNGP02.phx.gbl...
> Marc wrote:
>> Andrew Morton wrote:
>>> Marc wrote:
>>>> The below snippet does not work...anyone know how to reference the
>>>> procedure 'DrawCross()'?
>>>
>>> Every time you call DrawCross(), you're generating a new instance of
>>> a bitmap. That will never be the same instance you assigned to the
>>> BackgroundImage.
>>>
>>> The "is" operator is not a bitmap comparison operator. (Unless you
>>> were to overload it.)
>>>
>>> How about making your own extended MyContextMenuStrip inherits from
>>> ContextMenuStrip and has a String property you can set to change the
>>> BackgroundImage? (My nomenclature may be wrong.)
>>>


what about middle posting??? is this excepted or frowned upon?

>
>> Hi Andrew,
>>
>> Could you give me an example of how i would do that?
>>
>> Im sorry but im really a transport manager pretending to be a
>> programmer so my knowledge is basic!!!

>
> [Please bottom-post in this newsgroup.]
>
> You'll have to wait for someone who knows about ContextMenuStrip as it
> isn't in the VS2003/.NET1.1 I have. And anyway, I have to admit to only
> knowing the principle of this Inherits thing; I've never needed to use it,
> other than what VS sticks in the code for me.
>
> Andrew
>


Does it make it easier for you or is it a generally excepted rule ...


  Reply With Quote
Old 14-12-2006, 09:17 AM   #6
Andrew Morton
Guest
 
Posts: n/a
Default Re: The below snippet does not work...anyone know how to reference a procedure?

X-No-Archive: Yes

conversation.
of
order
normal
the
in
as
questions
the
follow
answers
the
if
follow
to
easier
it
makes
it
but
to,
have
don't
You

http://www.caliburn.nl/topposting.html

Andrew

jeff wrote:
> why do you have to bottom post???



  Reply With Quote
Old 14-12-2006, 10:35 AM   #7
Stephany Young
Guest
 
Posts: n/a
Default Re: The below snippet does not work...anyone know how to reference a procedure?

Ahhhhhhhh ... It all becomes clear. Bottom-posting is for those who suffer
from dyslexia.


"Andrew Morton" <akm@in-press.co.uk.invalid> wrote in message
news:OP3GRD2HHHA.3780@TK2MSFTNGP02.phx.gbl...
> X-No-Archive: Yes
>
> conversation.
> of
> order
> normal
> the
> in
> as
> questions
> the
> follow
> answers
> the
> if
> follow
> to
> easier
> it
> makes
> it
> but
> to,
> have
> don't
> You
>
> http://www.caliburn.nl/topposting.html
>
> Andrew
>
> jeff wrote:
>> why do you have to bottom post???

>
>



  Reply With Quote
Reply



Thread Tools
Rate This Thread
Rate This Thread:

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

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