@bobnoordam

Category: VB.NET

Reading screen pixels from the main screen, and specific other application windows

Reading from the full screen This code sample reads the pixel of the screen that the mouse points to, and changes the form’s background color to match that pixel’s color. Note that this code attaches to the main screen, and not to the window of a specific application. If you want to attach to a […]

Making a form transparant

This code sample displays a method to seemingly draw anywhere freely on the screen. The key to this technique is the TransparanceKey offered by the .net framework, which makes this a fairly straightforward task. To make the background of a form transparant, the *only* thing we need to do is this; oDrawform.AllowTransparency = True oDrawform.TransparencyKey […]

Creating a superimposed centered watermarked image at runtime

”’ <summary> ”’ Watermarks the file sOrinignalfilehandle with the content of sWatermarkfilehandle. The resulting ”’ watermarked picture is written to sOriginalfilehandle. ”’ ”’ Returns 1 for success, -1 if the operation can not be performed because of size mismatches ”’ </summary> ”’ <param name=”sOriginalfilehandle”></param> ”’ <param name=”sWatermarkfilehandle”></param> ”’ <remarks></remarks> Private Function WaterMarkFile(ByVal sOriginalfilehandle As String, […]

Static class implementing a filecopy function while showing a progress bar

Imports System.IO ”’ <summary> ”’ Copy a file from the source to the target location, and shows a progressbar to the user ”’ ”’ Call: ”’ ”’ CopyFileWithBar.DoCopy(“c:\somesource.bin”,”c:\sometarget.bin”) ”’ ”’ Returns FALSE if the source file does not exists ”’ Returns TRUE if the copy succeeded ”’ You need to trap exceptions for e.g. non […]

Determine response time from an ip ping

‘ — ping the ip adress in the string s_ipaddr, and get ‘ the response time in the int32 n_response ‘ imports system.net.networkinformation Dim ping As New System.Net.NetworkInformation.Ping Dim reply As System.Net.NetworkInformation.PingReply reply = ping.Send(s_ipaddr) If reply.Status = IPStatus.Success Then ‘ — handle reachable here MsgBox(“ping time ” & reply.RoundtripTime) Else ‘ — handle non […]

Enumerating the active forms within an application

VB.NET Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click ‘ — Build a list of all active forms, and display it to the user Dim activeforms As String = String.Empty For Each item As Form In Application.OpenForms activeforms = String.Format(“{0}{1}{2}”, activeforms, item.Name, vbCrLf) Next MsgBox(String.Format(“The names of the active forms are:{0}”, […]

Monitoring the file system for changes

This code sample sets up a handler to monitor the c:\ disk for changes in any file’s size, and report those changes to the console. Imports System.IO Module Module1 ”’ <summary> ”’ Display the change events detected by the file system watcher on the console ”’ </summary> ”’ <param name=”sender”></param> ”’ <param name=”e”></param> ”’ <remarks></remarks> […]

« Previous Page