473,804 Members | 2,132 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to "form1.line (x1,y2)-(x2,y2)" in VB.NET

Dear All,
I think you all knew my problem.

I don't know how to draw line @@ in VB.NET (2005 beta) , very sad.

Coudl you please help me?

Best regards,
Boki.
Nov 21 '05 #1
3 2920
Boki

http://communities.microsoft.com/new...idbey&slcid=us

Maybe a better place for this question?

Cor
Nov 21 '05 #2

"Boki" <bo******@ms21. hinet.net> wrote
I think you all knew my problem.

I don't know how to draw line @@ in VB.NET (2005 beta) , very sad.

Coudl you please help me?

Here is a simple scribble demo. Paste the code below into a new
form, under the Designer code (section). I've used white to draw
the lines on the form. But, if you want that picture to stay after
resizing, or after minimizing (ect.) then you need to keep a bitmap
in memory to redraw the image. I've used black to draw to that
so you can see when that takes effect....

Have fun!
LFS

Private Page As Bitmap
Private Mouse As Point
Private Drawing As Boolean
Private PageGrx As Graphics
Private FormGrx As Graphics
Private BlackInk As Pen = New Pen(Color.Black , 2)
Private WhiteInk As Pen = New Pen(Color.White , 2)
Private MyPen As Pen

Private Sub Form1_Load(ByVa l sender As System.Object, ByVal e As System.EventArg s) Handles MyBase.Load
Page = New Bitmap(Me.Clien tSize.Width, Me.ClientSize.H eight)
ResetGraphics()
End Sub

Private Sub ResetGraphics()
If Not PageGrx Is Nothing Then PageGrx.Dispose ()
PageGrx = Graphics.FromIm age(Page)
PageGrx.Smoothi ngMode = Drawing2D.Smoot hingMode.AntiAl ias
If Not FormGrx Is Nothing Then FormGrx.Dispose ()
FormGrx = Me.CreateGraphi cs
FormGrx.Smoothi ngMode = Drawing2D.Smoot hingMode.AntiAl ias
End Sub

Private Sub Form1_SizeChang ed(ByVal sender As Object, ByVal e As System.EventArg s) Handles MyBase.SizeChan ged
' Bail if minimized / downsizing
If Me.WindowState = FormWindowState .Minimized Then Exit Sub
If (Me.Width * Me.Height) < (Page.Width * Page.Height) Then Exit Sub

' Copy old image to new
Dim tmp As Bitmap = New Bitmap(Me.Clien tSize.Width, Me.ClientSize.H eight)
Dim grx As Graphics = Graphics.FromIm age(tmp)
grx.DrawImageUn scaled(Page, 0, 0)
grx.Dispose()
Page.Dispose()
' Start using new image
Page = tmp
ResetGraphics()

End Sub

Private Sub Form1_Paint(ByV al sender As Object, ByVal e As System.Windows. Forms.PaintEven tArgs) Handles MyBase.Paint
If Not FormGrx Is Nothing Then
FormGrx.DrawIma geUnscaled(Page , 0, 0)
End If
End Sub

Private Sub Form1_MouseDown (ByVal sender As Object, ByVal e As System.Windows. Forms.MouseEven tArgs) Handles MyBase.MouseDow n
Mouse.X = e.X
Mouse.Y = e.Y
Drawing = True
If e.Button = MouseButtons.Le ft Then
MyPen = BlackInk
Else
MyPen = WhiteInk
End If

End Sub

Private Sub Form1_MouseMove (ByVal sender As Object, ByVal e As System.Windows. Forms.MouseEven tArgs) Handles MyBase.MouseMov e
If Drawing Then
' Use MyPen as both ink pens for normal use
FormGrx.DrawLin e(WhiteInk, Mouse.X, Mouse.Y, e.X, e.Y)
PageGrx.DrawLin e(BlackInk, Mouse.X, Mouse.Y, e.X, e.Y)
Mouse.X = e.X
Mouse.Y = e.Y
End If
End Sub

Private Sub Form1_MouseUp(B yVal sender As Object, ByVal e As System.Windows. Forms.MouseEven tArgs) Handles MyBase.MouseUp
Drawing = False
End Sub
Nov 21 '05 #3
"Cor Ligthert" <no************ @planet.nl> wrote in message news:<#n******* *******@TK2MSFT NGP09.phx.gbl>. ..
Boki

http://communities.microsoft.com/new...idbey&slcid=us

Maybe a better place for this question?

Cor


Got it, thank you for information. : )

Best regards,
Boki.
Nov 21 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

19
10649
by: les_ander | last post by:
Hi, suppose I am reading lines from a file or stdin. I want to just "peek" in to the next line, and if it starts with a special character I want to break out of a for loop, other wise I want to do readline(). Is there a way to do this? for example: while 1: line=stdin.peek_nextline()
7
2815
by: jamait | last post by:
Hi all, I m trying to read in a text file into a datatable... Not sure on how to split up the information though, regex or substrings...? sample: Col1 Col2 Col3 Col4 A0012430 REKAL TVÄTTMEDEL EKOMAX 0,5L ST 75.9000
6
4402
by: mary | last post by:
When we use string line; while (getline(in,line)) { out.write(line.c_str(),line.size()); out.put('\n'); } in.close();
8
3218
by: Peter A. Schott | last post by:
Per subject - I realize I can copy/paste a line at a time into an interactive session when I'm trying to debug, but was wondering if there is any tool out there that allows me to copy sections of working Python scripts to paste into my interactive console and let those run so I don't have to copy line-by-line. Not sure if iPython would meet that criteria or not or even if such a beast exists. It would be helpful for debugging some of my...
65
12635
by: Skybuck Flying | last post by:
Hi, I needed a method to determine if a point was on a line segment in 2D. So I googled for some help and so far I have evaluated two methods. The first method was only a formula, the second method was a piece of C code which turned out to be incorrect and incomplete but by modifieing it would still be usuable. The first method was this piece of text:
22
4549
by: DraguVaso | last post by:
Hi, For my application I need the following behavior: When I press F4 the cursor has to move to the next line in my multiline textbox which begins with "0". Finding lines starting with 0 isn't that difficult, but to find the next line is more difficult. For exemple: if my cursor is on line 200, it has to start searching on line 201, and not on line 1. Anybody has any ideas?
8
7520
by: Frost | last post by:
Hi All, I am a newbie i have written a c program on unix for line by line comparison for two files now could some one help on how i could do word by word comparison in case both lines have the same words but in jumbled order they should match and print only the dissimilar lines.The program also checks for multiple entries of the same line. Here file 2 converts to file 3 which is in the format of file1 and i compare file1 with file3.
3
3040
by: Double Echo | last post by:
Hi all, I'm using PHP 4.4.2, and use PHP on both the command-line and the web. I am running PHP on SuSE 10 Linux , in a VMware 5.5 workstation, using Apache 2.0.55 , on my Dell laptop. Everything has been running flawlessly without problems. Very amazing to use VMware, it has worked beautifully. uname -a
9
5215
by: Adi | last post by:
Hello eveyone, I wanna ask a very simple question here (as it was quite disturbing me for a long time.) My problem is to read a file line by line. I've tried following implementations but still facing problems: Assume that FILE* filePointer; unsigned char lineBuffer;
6
5791
by: magix | last post by:
Hi, when I read entries in file i.e text file, how can I determine the first line and the last line ? I know the first line of entry can be filtered using counter, but how about the last line of entry in EOF while loop ? while (! file.eof() ) { ....
0
9715
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9595
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10353
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10356
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
7643
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6869
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5675
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4314
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
3003
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.