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

  • Thread starter Thread starter Marc
  • Start date Start date
M

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
 
Marc said:
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
 
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!!!
 
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
 
why do you have to bottom post???



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 ...
 
Ahhhhhhhh ... It all becomes clear. Bottom-posting is for those who suffer
from dyslexia.
 
Back
Top