Recent Forum Posts
From categories:
MyWikiMyWiki 10 Nov 2006 14:04
in discussion VB.Net / Algemeen » FTP

Not tested yet.

FTP by MyWikiMyWiki, 10 Nov 2006 14:04

Private _commaCharacter as String

Private ReadOnly Property CommaCharacter() As String

If _commaCharacter Is Nothing Then
Dim i As Double = 5 / 2
_commaCharacter = i.ToString().Substring(1, 1)
End If
Return _commaCharacter

End Get
End Property

Private Sub VKPJanusGridEX_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles MyBase.KeyDown

If e.KeyCode = Keys.Decimal Then
e.Handled = True
SendKeys.Send("{BACKSPACE}" & CommaCharacter)
End If

End Sub

To test this code, create a new form and past the code into the forms code-file.

Public Class Form1
Inherits System.Windows.Forms.Form

#Region " Windows Form Designer generated code "

Public Sub New()

'This call is required by the Windows Form Designer.

'Add any initialization after the InitializeComponent() call

End Sub

'Form overrides dispose to clean up the component list.
Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
If disposing Then
If Not (components Is Nothing) Then
End If
End If
End Sub

'Required by the Windows Form Designer
Private components As System.ComponentModel.IContainer

'NOTE: The following procedure is required by the Windows Form Designer
'It can be modified using the Windows Form Designer.
'Do not modify it using the code editor.
Friend WithEvents Button1 As System.Windows.Forms.Button
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
Me.Button1 = New System.Windows.Forms.Button
Me.Button1.Location = New System.Drawing.Point(80, 96)
Me.Button1.Name = "Button1"
Me.Button1.Size = New System.Drawing.Size(80, 40)
Me.Button1.TabIndex = 0
Me.Button1.Text = "Button1"
Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
Me.ClientSize = New System.Drawing.Size(292, 273)
Me.Name = "Form1"
Me.Text = "Form1"

End Sub

#End Region

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
End Sub

Public Class Screenshot

Public Declare Function BitBlt Lib "gdi32" Alias "BitBlt" (ByVal hDestDC As Integer, ByVal x As Integer, ByVal y As Integer, ByVal nWidth As Integer, ByVal nHeight As Integer, ByVal hSrcDC As Integer, ByVal xSrc As Integer, ByVal ySrc As Integer, ByVal dwRop As Integer) As Integer
Public Declare Function GetWindowDC Lib "user32" Alias "GetWindowDC" (ByVal hwnd As Integer) As Integer
Public Declare Function ReleaseDC Lib "user32" Alias "ReleaseDC" (ByVal hwnd As Integer, ByVal hdc As Integer) As Integer
Public Const SRCCOPY As Integer = &HCC0020

Public Shared Sub CreateBitmap()
Dim gDest As Graphics
Dim hdcDest As IntPtr
Dim hdcSrc As Integer
Dim hWnd As Integer '= Control.Handle.ToInt32
Dim bmp As Bitmap

hWnd = Process.GetCurrentProcess.MainWindowHandle.ToInt32
bmp = New Bitmap(Screen.PrimaryScreen.Bounds.Width, Screen.PrimaryScreen.Bounds.Height)
gDest = gDest.FromImage(bmp)
hdcSrc = GetWindowDC(hWnd)
hdcDest = gDest.GetHdc

BitBlt(hdcDest.ToInt32, 0, 0, Screen.PrimaryScreen.Bounds.Width, Screen.PrimaryScreen.Bounds.Height, hdcSrc, 0, 0, SRCCOPY)

ReleaseDC(hWnd, hdcSrc)
bmp.Save("C:\BITMAP" & DateTime.Now.ToString("yyyy-MM-dd_HH-mm-ss") & ".png")
End Sub
End Class
End Class

Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-Share Alike 2.5 License.