【问题标题】:Drawing digits/graphics directly to the screen?将数字/图形直接绘制到屏幕上?
【发布时间】:2011-12-09 11:13:50
【问题描述】:

我正在 Visual Basic Express 2010 中编写一个小程序,其中一部分是拍摄延迟的屏幕截图。

我的主代码可以正常工作,我的 Visual Basic 延迟使用 System.Threading.Thread.CurrentThread.Sleep(5000) 截屏,但我正在寻找一种直接绘制的方法到屏幕上的剩余秒数。

您知道如何在 Windows 中,在“设置”下的“显示属性”中,当您单击“识别”时,会在每台显示器上显示大量数字吗?

我正在尝试重新创建它,在截屏之前倒计时,为用户提供大量通知,让他们在截屏时获得所需应用程序的焦点。

可以这样做吗?还是需要大量编码?

非常感谢您提供的任何帮助

【问题讨论】:

    标签: windows vb.net gdi


    【解决方案1】:

    Form 中创建一个Label 控件,并使用以下内容使其透明:

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

    会做这样的事情:


    要使您的窗口对鼠标透明,请 PInvoke GetWindowLongSetWindowLong

    <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
    

    然后在您的Form_Load() 中添加以下内容:

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

    常量:

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

    【讨论】:

    • 这是否允许用户移动表单“下”的应用程序?还是表单会成为主动焦点?
    • 启用 Aero 时,无法在窗体下移动窗口。
    猜你喜欢
    • 2011-03-04
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-01-18
    • 1970-01-01
    • 2014-09-21
    相关资源
    最近更新 更多