|
-
Sep 14th, 2006, 05:03 AM
#1
Thread Starter
New Member
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
-
Sep 14th, 2006, 05:58 AM
#2
Fanatic Member
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
Barry
Visual Studio .NET 2008/Visual Studio .NET 2005/Visual Studio .NET 2003
.NET Framework 3.0 2.0 1.1/ASP.Net 3.0 2.0 1.1/Compact Framework 1.0
SQL Server 2005/2000/SQL Server CE 2.0
If you like, rate this post
Compact Framework for Beginners
-
Sep 14th, 2006, 07:01 AM
#3
Thread Starter
New Member
Re: Application loses focus at startup
thanks for that. A combination of both was needed. me.focus and searchforwindow in form1.deactivate.
Tim
Last edited by tim_rutter; Sep 14th, 2006 at 07:06 AM.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|