Solved

Form on top but ignores events?

Posted on 2002-05-09
4
143 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

Suggested Solutions

Title # Comments Views Activity
How to make an ADE file by code? 11 111
fso.FolderExists("\\server\HiddenFolder$") 4 98
Advice in Xamarin 21 121
Macro problems with Excel file 6 53
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…
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…
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 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…

752 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