Hi there.
I am trying to make a certain symbol to appear upon every mouseclick. However, the symbol is a cross and an arrow head. This is how I tried to do it. - Private Sub Form1_Paint(ByVal sender As Object, ByVal e As _
-
System.Windows.Forms.PaintEventArgs) Handles _
-
MyBase.Paint
-
-
Dim bluePen As New Pen(Color.Blue, 1.5)
-
Dim G As Graphics = e.Graphics
-
-
For Each p As Point In mypts
-
G.DrawLine(bluePen, (p.X - 5), (p.Y - 5), (p.X + 5), (p.Y+ 5))
-
G.DrawLine(bluePen, (p.X + 5), (p.Y - 5), (p.X - 5), (p.Y + 5))
-
Dim end_path As New Drawing2D.GraphicsPath
-
end_path.AddLine(0, 0, -4, -4)
-
end_path.AddLine(0, 0, 4, -4)
-
Dim end_cap As New Drawing2D.CustomLineCap(Nothing, end_path)
-
bluePen.CustomEndCap = end_cap
-
G.SmoothingMode = Drawing2D.SmoothingMode.AntiAlias
-
G.DrawLine(bluePen, (p.X - 4), p.Y, (p.X - 12), (p.Y + 7))
-
end_path.Dispose()
-
end_cap.Dispose()
-
Next
-
End Sub
-
-
Private Sub Form1_MouseClick(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Me.MouseClick
-
Me.mypts.Add(New Point(e.X, e.Y))
-
Me.Invalidate()
-
End Sub
However, the problem is, even the lines not suppose to have the arrow heads are having the end cap after the second click onwards. Advice please.
Thanks.
6 1901
You never reset the customendcap on the bluepen object.
You never reset the customendcap on the bluepen object.
how do i reset the customendcap? i thought the .dispose would do it, wouldnt it?
You dispose the one you created, but not the one you assigned to the pen
But I thought the one I created is the one I assigned to the pen. i do not understand . Because bluePen.CustomEndCap.Dispose() is the same as end_cap.dispose(), right?
Because bluePen.CustomEndCap.Dispose() is the same as end_cap.dispose(), right?
"sometimes" But not in this situation. In this situtation you are creating a copy of that object when you assign it to the pen. You will probably need to assign the pen a default endcap of some sort (and not just dispose() of it)
Thank you very much Plater. It works! I declared a different pen, specially assigned to endcap. It works. thanks again . =)
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Hans |
last post by:
Hi!
In my windowsformapplication I have a DataGrid where the rowheader is not
visible, and readOnly = true. The grid is bound to a DataView where
AllowEdit, AllowNew and AllowDelete is set to...
|
by: zoneal |
last post by:
I have a little question. How can I make that when I click on Button1
that my cursor go to ex. 10,750 and if the position of my cursor is
10,750, than let my mouse click. I know how I got let the...
|
by: Peter Rilling |
last post by:
What is the difference between the MouseClick and Click events?
|
by: Chris Dunaway |
last post by:
I added a MouseClick event to a Button control. It responds properly
to the Left click of the button, but not a middle click or right click.
Is it possible to get a right click and/or middle...
|
by: Kristian Frost |
last post by:
Hi,
I'm trying to add, as you might guess, mouseclick listeners to the shapes
I am drawing using the GDI+ commands in a similar sort of way as could be
done with the old VB "shapes".
Problem is,...
|
by: JimBob |
last post by:
Ok so i added this line of code to a dynamic PictureBox. (i dim it p)
AddHandler p.MouseClick, AddressOf Hand.Canvas_Click
what it would do is change the pic on the picbox but every time you
click...
|
by: GS |
last post by:
how can I tell if it is right mouse click from left mouseclick?
I would also to test if a key like control is being held down at the same
time.
what I would really like to is to capture control...
|
by: daveyand |
last post by:
Is there a way in javascript to trigger the clicking of the left mouse
button.
Basically i have a floating div that is translucent (40% opacity) this
div covers the whole screen. when a user...
|
by: tbrown |
last post by:
I have a listbox on my form and I set it to invisible. When a particular
button on the form is pressed, I make the listbox visible and allow the
user to select from it. When the selection occurs,...
|
by: DolphinDB |
last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation.
Take...
|
by: DolphinDB |
last post by:
Tired of spending countless mintues downsampling your data? Look no further!
In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
|
by: ryjfgjl |
last post by:
ExcelToDatabase: batch import excel into database automatically...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: Vimpel783 |
last post by:
Hello!
Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
|
by: jfyes |
last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
|
by: Defcon1945 |
last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
|
by: Shællîpôpï 09 |
last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
|
by: af34tf |
last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
| |