Open new Form: Old Form "goes to background"

K

Kenny Rymes

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
 
S

s_alexander04

I ran my application that also has form shown from main form by
ShowDialog(), and stayed on it more than 10 minutes and then I could
return to the old form.

if you in such situation open Sart->Settings->System->Memory->Running
Programs, do you see your "old form" in "Running Program List"?

Concerning your BringFormToFront I use this (in C#)

[DllImport("coredll.dll", SetLastError=true)]
private static extern IntPtr GetCapture();

[DllImport("coredll.dll", SetLastError=true)]
private static extern bool SetForegroundWindow(IntPtr hWnd);

void SetForegroundForm(Form f) {
f.Capture=true;
IntPtr hwnd=GetCapture();
f.Capture=false;
SetForegroundWindow(hwnd);
f.Show();
}

It realy set form as foreground but I'm not sure will it help you

Aleks S.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top