Flash Vb 6 Form On Top Of Screen

Dear,
How Can i Flash a Vb 6 Form On Top Of Screen, not on top of Windows but on top of Screen, with half of its size. and if possible please also give me some code to give some Graphical/Interactive touch to this form.
I hope i will get with a good answer soon.
Thank you Dear
With Regards
ShowkatdarAsked:
Who is Participating?
 
Mike TomlinsonConnect With a Mentor Middle School Assistant TeacherCommented:
Ok...it might look something like:
Option Explicit
 
Private Type RECT
    Left As Long
    Top As Long
    Right As Long
    Bottom As Long
End Type
 
Private Declare Function SystemParametersInfo Lib "user32" _
    Alias "SystemParametersInfoA" (ByVal uAction As Long, _
    ByVal uParam As Long, ByRef lpvParam As Any, _
    ByVal fuWinIni As Long) As Long
Private 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
 
Private Const SPI_GETWORKAREA = 48
Private Const HWND_TOPMOST = -1
Private Const HWND_NOTOPMOST = -2
Private Const SWP_NOSIZE = &H1
Private Const SWP_NOACTIVATE = &H10
Private Const SWP_SHOWWINDOW = &H40
Private Const SWP_NOMOVE = &H2
Private Const SWP_HIDEWINDOW = &H80
Private Const SWP_NOZORDER = &H4
 
Private desktopRect As RECT
Private formHeight As Single ' (In Pixels) adjust to your liking
Private formWidth As Single ' (In Pixels) adjust to your liking
Private steps As Integer
Private maxStep As Integer
 
Private Sub Form_Load()
    formWidth = 300 ' width of popup form (in pixels)
    formHeight = 150 ' height of popup form (in pixels)
    Timer1.Interval = 25 ' adjust to your liking
    Timer1.Enabled = False
    maxStep = 10 ' adjust to your liking
End Sub
 
Private Sub Command1_Click()
    ' get current desktop area taking into account the taskbar and any appbars
    Call SystemParametersInfo(SPI_GETWORKAREA, vbNull, desktopRect, 0)
    steps = 0
    Call Timer1_Timer
End Sub
 
Private Sub Timer1_Timer()
    Dim curHeight As Single
    
    If steps = 0 Then
        ' pop up topmost form without stealing the focous
        SetWindowPos Form2.hwnd, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOACTIVATE Or SWP_SHOWWINDOW
        Timer1.Enabled = True
    End If
    steps = steps + 1
    Dim leftEdge As Integer
    leftEdge = desktopRect.Left + ((desktopRect.Right - desktopRect.Left) / 2) - (formWidth / 2)
    Select Case steps
        Case 1 To (maxStep - 1)
            ' window is moving...
            curHeight = steps / maxStep * formHeight
            Call SetWindowPos(Form2.hwnd, 0, _
                leftEdge, desktopRect.Top, _
                formWidth, curHeight, SWP_NOACTIVATE)
            
        Case maxStep
            ' window in final position
            Timer1.Enabled = False
            Call SetWindowPos(Form2.hwnd, 0, _
                leftEdge, desktopRect.Top, _
                formWidth, formHeight, SWP_NOACTIVATE)
        
    End Select
End Sub

Open in new window

0
 
SethiCommented:
Option Explicit

Private Const HWND_BOTTOM = 1
Private Const HWND_NOTOPMOST = -2
Private Const HWND_TOP = 0
Private Const HWND_TOPMOST = -1
Private Const SWP_NOMOVE = &H2
Private Const SWP_NOSIZE = &H1

Private Declare Function GetActiveWindow Lib "user32" () As Long

Private 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

'Pass the form's hwnd.  The first routine ensures the form will
'always be on top.  The second reverts back to the normal state


Public Sub MakeWindowAlwaysTop(hwnd As Long)
 SetWindowPos hwnd, HWND_TOPMOST, 0, 0, 0, 0, _
   SWP_NOMOVE + SWP_NOSIZE
End Sub

Public Sub MakeWindowNotTop(hwnd As Long)
  SetWindowPos hwnd, HWND_NOTOPMOST, 0, 0, 0, 0, _
     SWP_NOMOVE + SWP_NOSIZE
End Sub

Then in the form load event of the form that has to be on Top write the following code:
MakeWindowAlwaysTop Me.hwnd
0
 
ShowkatdarAuthor Commented:
Dear Sethi,
I never mean on Top of Screen as u suggested me. What i mean is On top Screen by On Top of your moniter Screen.I m attaching one Snap Shot to Clear My Point.
Thank you and Regards
View.JPG
0
Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

 
GrahamSkanRetiredCommented:
Simply setting the Top property to 0 should do that:

Form1.Top = 0
0
 
SethiCommented:
I agree :)

You can also specify the Left position if you want to be more specific.
0
 
Mike TomlinsonMiddle School Assistant TeacherCommented:
0
 
ShowkatdarAuthor Commented:
Dear Idle Mind
It is really what i want, Great Dear, Great! Thank you for your reply.
I will give u all points but can u help me to put it on top if possible.
Thank you and Regards
0
 
ShowkatdarAuthor Commented:
Great Great Work Done.Thank you Mr.Idle Mind
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.