开发者

Drawing digits/graphics directly to the screen?

开发者 https://www.devze.com 2023-04-13 09:43 出处:网络
I\'m putting together a small program in Visual Basic Express 2010, and part of it is to take a delayed screen shot.

I'm putting together a small program in Visual Basic Express 2010, and part of it is to take a delayed screen shot.

I've got the main code working, I've got Visual Basic delaying taking the screen shot with System.Threading.Thread.CurrentThread.Sleep(5000), but what I'm looking for is a way to draw directly to the screen the number of seconds remaining.

You know how in Windows, in the Display Properties under Settings, when you click on Identify you get a huge number displayed on each monitor?

I'm trying to recreate that, with the number counting down until the screen shot is taken, giving the user plenty of notification to get their required applications in focus for the screen shot.

Is it possible to do this? Or is it something that will take a heck of a lot of coding?开发者_高级运维

Many thanks for any help you can offer


Create a Label control in a Form and use something like the following to make it transparent:

Me.TransparencyKey = Color.Gray ' or any other color.
Me.BackColor = TransparencyKey
Me.FormBorderStyle = FormBorderStyle.None

will make something like this:

Drawing digits/graphics directly to the screen?


To make your window transparent to mouse, PInvoke GetWindowLong and SetWindowLong:

<DllImport("user32.dll", SetLastError:=True)> _
Private Shared Function GetWindowLong( _
 ByVal hWnd As IntPtr, _
 ByVal nIndex As Integer) As Integer
End Function

<DllImport("user32.dll")> _
Private Shared Function SetWindowLong( _
 ByVal hWnd As IntPtr, _
 ByVal nIndex As Integer, _
 ByVal dwNewLong As IntPtr) As Integer
End Function

Then in your Form_Load() add the following:

Dim hwnd As IntPtr = Me.Handle
Dim extendedStyle As Integer = GetWindowLong(hwnd, GWL_EXSTYLE)
SetWindowLong(hwnd, GWL_EXSTYLE, extendedStyle Or WS_EX_TRANSPARENT)

Constants:

Const WS_EX_TRANSPARENT As Integer = &H20
Const GWL_EXSTYLE As Integer = -20
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号