Solved

Form on top but ignores events?

Posted on 2002-05-09
4
144 Views
Last Modified: 2010-05-02
This is a followup to my question "Pop up dialog in system tray"

Basically I have created an app that pops up a form occasionally when an event occurs. It's all well and good except I notice that when it does this it takes focus away from the current window (e.g. Microsoft Word) so when I'm typing Word will lose my keystrokes until I reselect the application.

Is there anyway to get the form to display above all applications but not take the focus away from the current application?

Cheers
0
Comment
Question by:deal051298
[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
  • 2
4 Comments
 
LVL 3

Expert Comment

by:SirNick
ID: 6998304
Hi deal

Try using

AppActivate "Microsoft Word"

Hope this helps...
0
 

Author Comment

by:deal051298
ID: 6998308
Errr. The application that loses the focus to my popup could be *any* application. I want my form to popup above all apps but not actually take the focus. I want it to cause as little distubance to the user as possible while still making sure it is seen. Same functionality as popups that appear by MSN Messenger.
0
 
LVL 1

Accepted Solution

by:
Wildi earned 150 total points
ID: 6998442
Instead of showing your form with the .show method or by setting the .Visible property to true you could send an appropriate windows message to your form window where a little bit more flexibility is given. Try sending the message SW_SHOWNOACTIVE method.

Try this code in a form's code having one command button, which works here on a NT workstation (Win2K already supports window flashing so I am not sure if you need the manually window flashing there). However, for manually flashing the window your form window has to be minimized.

----------------------Begin Code Snippet
Option Explicit

Private Declare Function ShowWindow Lib "user32" (ByVal hWnd As Long, ByVal nCmdShow As Long) As Long
Private Declare Function ShowWindowAsync Lib "user32" (ByVal hWnd As Long, ByVal nCmdShow As Long) As Long
Private Declare Sub k32Sleep Lib "kernel32" Alias "Sleep" (ByVal dwMilliseconds As Long)
Private Declare Function FlashWindow Lib "user32" (ByVal hWnd As Long, ByVal bInvert As Long) As Long

Public Enum eWinStyle
  SW_HIDE = 0
  SW_NORMAL = 1
  SW_SHOWNORMAL = 1
  SW_SHOWMINIMIZED = 2
  SW_SHOWMAXIMIZED = 3
  SW_MAXIMIZE = 3
  SW_SHOWNOACTIVATE = 4
  SW_SHOW = 5
  SW_MINIMIZE = 6
  SW_SHOWMINNOACTIVE = 7
  SW_SHOWNA = 8
  SW_RESTORE = 9
  SW_SHOWDEFAULT = 10
End Enum


Public Sub ShowWnd(ByVal hWnd As Long, Optional ByVal Modal As Integer = 0, Optional ByVal aCmd As eWinStyle = SW_SHOWDEFAULT)
  If Modal = 1 Then
    ShowWindow hWnd, aCmd
  Else
    ShowWindowAsync hWnd, aCmd
  End If
End Sub

Public Sub FlashWin(ByVal ahWnd As Long, Optional ByVal duration As Long = 250)
  FlashWindow ahWnd, 1
  k32Sleep duration
  FlashWindow ahWnd, 0
  k32Sleep duration
  'FlashWindow aHWnd, 0
End Sub


Private Sub Command1_Click()
  Dim i As Long
  On Error Resume Next
  Me.Visible = False
  For i = 1 To 100000
    DoEvents
  Next
  ShowWnd Me.hWnd, 0, SW_SHOWNOACTIVATE
  Me.WindowState = vbMinimized
  For i = 1 To 10
    FlashWin Me.hWnd, 500
    DoEvents
  Next
End Sub

----------------------End Code Snippet
0
 

Author Comment

by:deal051298
ID: 7632611
Found this open question Wildi so the points are use - can't remeber if it worked or not
0

Featured Post

PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

Question has a verified solution.

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

I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
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…
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…
Suggested Courses
Course of the Month5 days, 5 hours left to enroll

635 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