Link to home
Start Free TrialLog in
Avatar of rovi
rovi

asked on

Focus issue

I created an application that displays a form with information sent to it by another computer. This form is alwas active and sits on a small part of the bottom of the screeen. The problem is that at times the app receives and displays informaton it takes focus from the active program. So if i was typing in Word i can loose focus while i am typing.

How can i prevent this problem from happening?
Avatar of Mike Tomlinson
Mike Tomlinson
Flag of United States of America image

How are you "updating" the information in your form?
ASKER CERTIFIED SOLUTION
Avatar of junglerover77
junglerover77

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
make ur window always on top

Private Declare Function SetWindowPos Lib "user32" (ByVal hwnd As Long, ByVal hWndInsertAfter As Long, ByVal x As Long, y, ByVal cx As Long, ByVal cy As Long, ByVal wFlags As Long) As Long

Private Const HWND_TOPMOST = -1
Private Const HWND_NOTOPMOST = -2
Private Const SWP_NOMOVE = &H2
Private Const SWP_NOSIZE = &H1
Private Const TOPMOST_FLAGS = SWP_NOMOVE Or SWP_NOSIZE

Public Sub MakeNormal(hwnd As Long)
    SetWindowPos hwnd, HWND_NOTOPMOST, 0, 0, 0, 0, TOPMOST_FLAGS
End Sub
Public Sub MakeTopMost(hwnd As Long)
    SetWindowPos hwnd, HWND_TOPMOST, 0, 0, 0, 0, TOPMOST_FLAGS
End Sub

'usage
Private Sub Form _Load()
     Call  MakeTopMost(Me.hwnd)
End Sub

also it is better to remove control boxes from ur form so that user cannot minimize it
provided ur screen will be small enough to be positioned at bottom of the screen