1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91
|
' form 4 : ' flash
Option Explicit On
Public Class Form4
'
'---Début API SetWindowPos
Private Declare Function SetWindowPos Lib "User32" _
(ByVal hWnd As Int32, _
ByVal hWndInsertAfter As Int32, _
ByVal X As Long, ByVal Y As Int32, _
ByVal cx As Long, ByVal cy As Int32, _
ByVal wFlags As Long) As Int32
Private Const HWND_TOPMOST = -1
Private Const SWP_NOSIZE = &H1
Private Const SWP_NOMOVE = &H2
Private Const SWP_SHOWWINDOW = &H40
Const Flags = &H2 Or &H1 Or &H40 Or &H10
'---fin API SetWindowsPos
'
Dim passe As Long
Dim deplace As Boolean
Dim r As Long
Sub Form4_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
deplace = False
passe = 1
Timer1.Interval = 30
Timer1.Enabled = True
r = SetWindowPos(Me.Handle, -1, 0, 0, 0, 0, Flags) ' toujours visible
My.Application.DoEvents()
Me.StartPosition = FormStartPosition.CenterScreen
End Sub
Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
Select Case passe Mod 2
Case 0, 2, 4, 6, 8, 10, 12, 14, 15, 18, 20, 22, 24 : Me.BackColor = Color.Black
Case 26, 28, 30, 32, 34, 36, 38, 40, 42, 44, 46, 48, 50 : Me.BackColor = Color.Black
Case 1, 3, 5, 7, 9 : Me.BackColor = Color.Red
Case 11, 13, 15, 17, 19 : Me.BackColor = Color.Green
Case 21, 23, 25, 27, 29 : Me.BackColor = Color.Blue
Case 31, 33, 35, 37, 39 : Me.BackColor = Color.Yellow
Case 41, 43, 45, 47, 49 : Me.BackColor = Color.White
End Select
passe = passe + 1
If passe > 50 Then passe = 0
End Sub
Sub Form4_DoubleClick(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.DoubleClick
deplace = False
Timer1.Enabled = False ' fin
Me.Close()
End Sub
Sub Form4_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Me.MouseDown
deplace = True
End Sub
Sub Form4_MouseMove(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Me.MouseMove
If e.Button <> Windows.Forms.MouseButtons.Left Or deplace = False Then Exit Sub
deplace = True
My.Application.DoEvents()
Me.Left = e.X - 5 ' form = 10 * 10 pixels
Me.Top = e.Y - 5
Me.Refresh()
End Sub
Sub Form4_MouseUp(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Me.MouseUp
If deplace = True Then
My.Application.DoEvents()
Me.Left = e.X - 5
Me.Top = e.Y - 5
Me.Refresh()
End If
deplace = False
End Sub
Sub Form4_FormClosing(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing
r = SetWindowPos(Me.Handle, -2, 0, 0, 0, 0, Flags) ' n'est plus toujours visible
Form1.laform(2) = False
Form1.laform(3) = False
Form1.laform(4) = False
End Sub
End Class |
Partager