Home All Groups Group Topic Archive Search About

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

Author
13 Dec 2006 3:10 PM
Marc
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

Author
13 Dec 2006 3:24 PM
Andrew Morton
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

Show quoteHide quote
> 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
Author
13 Dec 2006 3:33 PM
Marc
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:
Show quoteHide quote
> 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
Author
13 Dec 2006 3:48 PM
Andrew Morton
Marc wrote:
Show quoteHide quote
> 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
Author
13 Dec 2006 5:47 PM
jeff
why do you have to bottom post???


Show quoteHide quote
"Andrew Morton" <a**@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?

Show quoteHide quote
>
>> 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 ...
Author
14 Dec 2006 9:17 AM
Andrew Morton
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:
Show quoteHide quote
> why do you have to bottom post???
Author
14 Dec 2006 10:35 AM
Stephany Young
Ahhhhhhhh ... It all becomes clear. Bottom-posting is for those who suffer
from dyslexia.


Show quoteHide quote
"Andrew Morton" <a**@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???
>
>