|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
The below snippet does not work...anyone know how to reference a procedure?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 wrote:
> The below snippet does not work...anyone know how to reference the Every time you call DrawCross(), you're generating a new instance of a > procedure 'DrawCross()'? 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 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 Marc wrote:
Show quoteHide quote > Andrew Morton wrote: [Please bottom-post in this newsgroup.]>> 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!!! 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???
Show quoteHide quote "Andrew Morton" <a**@in-press.co.uk.invalid> wrote in message what about middle posting??? is this excepted or frowned upon?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.) >>> Show quoteHide quote > Does it make it easier for you or is it a generally excepted rule ...>> 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 > 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??? 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??? > >
Manipulating controls created by another thread
Estimates on money lost because of VB.NET Connection string in app.config for class library Re: Great Reasons Not To Learn VB.NET - PART 1 time difference DateTime Help referencing control backgorund image Can't maximize COM error in vb.net2 Great Reasons To Learn VB.NET - PART 1 |
|||||||||||||||||||||||