Hello

I have a problem using .NET CF. If I open a new form with
"settings.showdialog" and I stay on the new form for 5-10 minutes, then the
old form disappears. If I close the settings-form, then I see the
Today-Screen instead of the old form.
Must be something with timeout...

I now tried to use this:

<DllImport("coredll.dll", EntryPoint:="SetForegroundWindow",
SetLastError:=True)> _
Public Shared Function SetForegroundWindow( _
ByVal hwnd As IntPtr) As Boolean
End Function
<DllImport("Coredll", CallingConvention:=CallingConvention.Winapi,
CharSet:=CharSet.Auto)> _
Public Shared Function FindWindow(ByVal lpClassName As String, ByVal
lpWindowName As String) As IntPtr
End Function
Public Shared Function BringFormToFront(ByVal FormName As String) As Boolean
Dim hwnd As IntPtr
hwnd = (FindWindow(Nothing, FormName))
SetForegroundWindow(hwnd)
End Function

after settings.showdialog I use:
BringFormToFront(me.text)

But this doesnt work either?!
Any solution to this problem?
Thanks
Kenny

Re: Closing one form: Bring old form to front? by TJ

TJ
Mon Mar 27 18:00:38 CST 2006

It sounds more like a memory leak that is closing your other window. If
you show your settings window and then close it does your other window
still close after a few minutes? Have you tried running the program with
just the first window open for a few minutes to make sure it isn't
anything to do with the settings window?

Kenny Rymes wrote:
> Hello
>
> I have a problem using .NET CF. If I open a new form with
> "settings.showdialog" and I stay on the new form for 5-10 minutes, then the
> old form disappears. If I close the settings-form, then I see the
> Today-Screen instead of the old form.
> Must be something with timeout...
>
> I now tried to use this:
>
> <DllImport("coredll.dll", EntryPoint:="SetForegroundWindow",
> SetLastError:=True)> _
> Public Shared Function SetForegroundWindow( _
> ByVal hwnd As IntPtr) As Boolean
> End Function
> <DllImport("Coredll", CallingConvention:=CallingConvention.Winapi,
> CharSet:=CharSet.Auto)> _
> Public Shared Function FindWindow(ByVal lpClassName As String, ByVal
> lpWindowName As String) As IntPtr
> End Function
> Public Shared Function BringFormToFront(ByVal FormName As String) As Boolean
> Dim hwnd As IntPtr
> hwnd = (FindWindow(Nothing, FormName))
> SetForegroundWindow(hwnd)
> End Function
>
> after settings.showdialog I use:
> BringFormToFront(me.text)
>
> But this doesnt work either?!
> Any solution to this problem?
> Thanks
> Kenny
>
>