
Visual Basic Code Snippets #2
In this next update I'll continue to re-post my Visual Basic code snippets (which are older than five years by the way) that pertain to Forms.
Make a Form Cover the Entire Screen
Compatibility: Win. 98-XP
Add the following code into a module within your project...
Public Declare Function SetWindowPos Lib "user32" (ByVal hwnd As Long, ByVal hWndInsertAfter As Long, ByVal x As Long, ByVal y As Long, ByVal cx As Long, ByVal cy As Long, ByVal wFlags As Long) As Long
Public Declare Function GetSystemMetrics Lib "user32" (ByVal nIndex As Long) As Long
Public Const SM_CXSCREEN = 0
Public Const SM_CYSCREEN = 1
Public Const HWND_TOP = 0
Public Const SWP_SHOWWINDOW = &H40
Add the following code wherever you want the code to execute...
Dim cx As Long
Dim cy As Long
Dim RetVal As Long
If Me.WindowState = vbMaximized Then
Me.WindowState = vbNormal
End If
cx = GetSystemMetrics(SM_CXSCREEN)
cy = GetSystemMetrics(SM_CYSCREEN)
RetVal = SetWindowPos(Me.hwnd, HWND_TOP, 0, 0, cx, cy, SWP_SHOWWINDOW)
Flash a Forms Border
Compatibility: Win. 98-XP
Add the following code into a module within your project...
Public Declare Function FlashWindow Lib "User32" (ByVal hWnd As Long, ByVal bInvert As Long) As Long
Add a Timer to a form named Timer1 with an interval of 220 then add the following code into Timer1_Timer...
Dim nReturnValue As Long
nReturnValue = FlashWindow(Form1.hWnd, True)
