Solved

Flash Vb 6 Form On Top Of Screen

Posted on 2009-04-12
8
373 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Industry Leaders: 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 86

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 86

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

Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

Question has a verified solution.

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

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…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
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…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

751 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