Application loses focus at startup
I'm having a problem giving my application the focus at startup. One of my aims is to not allow the user to see any part of windows in the background. As such my application runs first in the registry. However, following this explorer.exe runs and causes my app to lose the focus. Another part of my app is that the touch screen is disabled, meaning the user is stuck. I have tried me.focus after a nominal 10 seconds to no avail. What can I do?
Help!
Thanks,
Tim
Re: Application loses focus at startup
try in the form1_deactivated putting a me.focus, that might work.
or else try the code below, it looks for the text at the top of the form to find the window
Declare Function FindWindow Lib "coredll.dll" (ByVal className As Char(), ByVal WindowsName As Char()) As Integer
Declare Function SetForegroundWindow Lib "coredll.dll" (ByVal hwnd As Integer) As Boolean
Private Shared Function SearchForWindow(ByVal p_formCaptionText As String) As Boolean
Dim hWnd As Integer
hWnd = FindWindow(Nothing, p_formCaptionText.ToCharArray)
If hWnd <> 0 Then
SetForegroundWindow(hWnd)
Return True
Else : Return False
End If
End Function
Re: Application loses focus at startup
thanks for that. A combination of both was needed. me.focus and searchforwindow in form1.deactivate.
Tim