?
Solved

Focus issue

Posted on 2006-05-17
7
Medium Priority
?
238 Views
Last Modified: 2010-05-01
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?
0
Comment
Question by:rovi
  • 2
4 Comments
 
LVL 86

Expert Comment

by:Mike Tomlinson
ID: 16701021
How are you "updating" the information in your form?
0
 
LVL 6

Accepted Solution

by:
junglerover77 earned 2000 total points
ID: 16706063
Totally agree with Idel_Mind, if you show your received information in a normal way, this is not gonna happen. Just put a timer and a textbox in a form and try the following code:

Private Sub Form_Load()
    Timer1.Interval = 1000
    Timer1.Enabled = True
End Sub

Private Sub Timer1_Timer()
    Text1.Text = Now
End Sub

The text of the textbox will change every second, but this application will never grab the focus.

If your application keep grabbing the focus, there must be some special code in your code. Please show your code so that we can help you.

Regards,
Jungle
0
 
LVL 14

Expert Comment

by:Shiju Sasidharan
ID: 16706598
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

0
 
LVL 14

Expert Comment

by:Shiju Sasidharan
ID: 16706604
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
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
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…

850 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