Solved

Flash Vb 6 Form On Top Of Screen

Posted on 2009-04-12
8
366 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
3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

 
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

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

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

There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…

777 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