Solved

Flash Vb 6 Form On Top Of Screen

Posted on 2009-04-12
8
363 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
 
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
Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

 
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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
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…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

746 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now