Click here to Skip to main content
15,913,854 members
Home / Discussions / Visual Basic
   

Visual Basic

 
QuestionK8055 USB Experimental Interface Board Pin
CocaColaBoy15-Mar-08 6:35
CocaColaBoy15-Mar-08 6:35 
GeneralRe: K8055 USB Experimental Interface Board Pin
Dave Kreskowiak17-Mar-08 7:15
mveDave Kreskowiak17-Mar-08 7:15 
GeneralContinuous file monitoring problem Pin
arp_05915-Mar-08 4:09
arp_05915-Mar-08 4:09 
GeneralRe: Continuous file monitoring problem Pin
Mycroft Holmes15-Mar-08 21:41
professionalMycroft Holmes15-Mar-08 21:41 
GeneralRe: Continuous file monitoring problem Pin
Dave Kreskowiak17-Mar-08 7:12
mveDave Kreskowiak17-Mar-08 7:12 
Generalhelp required with a stock system Pin
mickstar15-Mar-08 3:08
mickstar15-Mar-08 3:08 
GeneralRe: help required with a stock system Pin
Christian Graus16-Mar-08 11:15
protectorChristian Graus16-Mar-08 11:15 
GeneralDraw lines on picture in background Pin
patrik.michnac15-Mar-08 3:07
patrik.michnac15-Mar-08 3:07 
I found nice example how to draw lines by mouse on form. I want to have picture as background and write lines on this picture. Is there anyone who can show me how can I put picture as background?

Imports System.Windows.Forms

Public Class frmIceTimeShots
' True while we are drawing the new line.
Private m_Drawing As Boolean

' Buffer for erasing rubberband lines.
Private m_BufferBitmap As Bitmap
Private m_BufferGraphics As Graphics

' The mouse position.
Private m_X1 As Integer
Private m_Y1 As Integer
Private m_X2 As Integer
Private m_Y2 As Integer

Private Sub SaveSnapshot()
Dim new_bitmap As Bitmap

' Make a new bitmap that fits the form.
new_bitmap = New Bitmap(Me.Width, Me.Height)

m_BufferGraphics = Graphics.FromImage(new_bitmap)

' Clear the new bitmap.
m_BufferGraphics.Clear(Me.BackColor)
m_BufferGraphics.DrawImage(new_bitmap, 0, 0)

' Copy the existing bitmap's contents into
' the new bitmap.
If Not (m_BufferBitmap Is Nothing) Then
m_BufferGraphics.DrawImage(m_BufferBitmap, 0, 0)
End If

' Save the new bitmap and graphics objects.
m_BufferBitmap = new_bitmap
End Sub

' Continue drawing the rubberband line.
Private Sub Form1_MouseMove(ByVal sender As Object, ByVal e _
As System.Windows.Forms.MouseEventArgs) Handles _
MyBase.MouseMove
' Do nothing if we're not drawing.
If Not m_Drawing Then Exit Sub

' Save the new point.
m_X2 = e.X
m_Y2 = e.Y

' Erase the previous line.
DrawForm(Me.CreateGraphics())

' Draw the new line directly on the form.
Me.CreateGraphics().DrawLine( _
Pens.Gray, m_X1, m_Y1, m_X2, m_Y2)
End Sub
' Redraw the saved buffer.
Private Sub DrawForm(ByVal gr As Graphics)
If Not (m_BufferBitmap Is Nothing) Then _
gr.DrawImage(m_BufferBitmap, 0, 0)
End Sub

Private Sub frmIceTimeShots_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Me.MouseDown
' Do nothing if this isn't the left mouse button.
If e.Button <> MouseButtons.Left Then Exit Sub
m_Drawing = True

' Save a snapshot of the form.
SaveSnapshot()

' Save the current mouse position.
m_X1 = e.X
m_X2 = e.X
m_Y1 = e.Y
m_Y2 = e.Y
End Sub
' Finish drawing the new line.
Private Sub Form1_MouseUp(ByVal sender As Object, ByVal e _
As System.Windows.Forms.MouseEventArgs) Handles _
MyBase.MouseUp
' Do nothing if we're not drawing.
If Not m_Drawing Then Exit Sub
m_Drawing = False

' Save the new point.
m_X2 = e.X
m_Y2 = e.Y

' Draw the new line permanently on the buffer.
m_BufferGraphics.DrawLine( _
Pens.Blue, m_X1, m_Y1, m_X2, m_Y2)

' Redraw to show the new line.
DrawForm(Me.CreateGraphics())
End Sub
' Redraw the form.
Private Sub Form1_Paint(ByVal sender As Object, ByVal e As _
System.Windows.Forms.PaintEventArgs) Handles _
MyBase.Paint
DrawForm(e.Graphics)
End Sub

End Class
GeneralRe: Draw lines on picture in background Pin
Dave Kreskowiak17-Mar-08 6:58
mveDave Kreskowiak17-Mar-08 6:58 
QuestionHow to convert a value to a string with decimal point instead of comma Pin
DCAUB15-Mar-08 0:57
DCAUB15-Mar-08 0:57 
GeneralRe: How to convert a value to a string with decimal point instead of comma Pin
Colin Angus Mackay15-Mar-08 1:13
Colin Angus Mackay15-Mar-08 1:13 
GeneralRe: How to convert a value to a string with decimal point instead of comma Pin
DCAUB15-Mar-08 1:28
DCAUB15-Mar-08 1:28 
GeneralRe: How to convert a value to a string with decimal point instead of comma Pin
Colin Angus Mackay15-Mar-08 4:08
Colin Angus Mackay15-Mar-08 4:08 
QuestionHow to send a string over the internet to another pc Pin
softwarejaeger15-Mar-08 0:17
softwarejaeger15-Mar-08 0:17 
GeneralRe: How to send a string over the internet to another pc Pin
Dave Kreskowiak17-Mar-08 5:32
mveDave Kreskowiak17-Mar-08 5:32 
QuestionUsing System.windows.forms.datagrid Pin
shaeron14-Mar-08 22:36
shaeron14-Mar-08 22:36 
GeneralRe: Using System.windows.forms.datagrid Pin
Mycroft Holmes15-Mar-08 21:50
professionalMycroft Holmes15-Mar-08 21:50 
GeneralHowTo Refresh Data Bound Controls in VB.NET Compact Edition Pin
swdev.bali14-Mar-08 18:37
swdev.bali14-Mar-08 18:37 
QuestionConverting Excel VBA module code to VB 2005/VB.NET Pin
Graham Latto14-Mar-08 14:39
Graham Latto14-Mar-08 14:39 
GeneralRe: Converting Excel VBA module code to VB 2005/VB.NET Pin
Paul Conrad14-Mar-08 14:59
professionalPaul Conrad14-Mar-08 14:59 
QuestionRe: Converting Excel VBA module code to VB 2005/VB.NET Pin
Graham Latto14-Mar-08 15:26
Graham Latto14-Mar-08 15:26 
GeneralRe: Converting Excel VBA module code to VB 2005/VB.NET Pin
ChandraRam16-Mar-08 23:29
ChandraRam16-Mar-08 23:29 
QuestionCheck for a foder or a file Pin
Assaf8214-Mar-08 10:50
Assaf8214-Mar-08 10:50 
GeneralRe: Check for a foder or a file Pin
Dave Kreskowiak14-Mar-08 10:55
mveDave Kreskowiak14-Mar-08 10:55 
GeneralRe: Check for a foder or a file Pin
Assaf8214-Mar-08 10:57
Assaf8214-Mar-08 10:57 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.