Solved

Flash Vb 6 Form On Top Of Screen

Posted on 2009-04-12
8
370 Views
Last Modified: 2012-05-06
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
0
Comment
Question by:Showkatdar
  • 3
  • 2
  • 2
  • +1
8 Comments
 
LVL 18

Expert Comment

by:Sethi
ID: 24124915
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
 

Author Comment

by:Showkatdar
ID: 24124925
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
 
LVL 76

Expert Comment

by:GrahamSkan
ID: 24124980
Simply setting the Top property to 0 should do that:

Form1.Top = 0
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 18

Expert Comment

by:Sethi
ID: 24125024
I agree :)

You can also specify the Left position if you want to be more specific.
0
 
LVL 85

Expert Comment

by:Mike Tomlinson
ID: 24125803
0
 

Author Comment

by:Showkatdar
ID: 24126439
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
 
LVL 85

Accepted Solution

by:
Mike Tomlinson earned 500 total points
ID: 24127345
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
 

Author Closing Comment

by:Showkatdar
ID: 31569287
Great Great Work Done.Thank you Mr.Idle Mind
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

680 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question