New problem - Now Forms doesn't show.

  • Thread starter Thread starter Eduardo S.E. de Castro
  • Start date Start date
E

Eduardo S.E. de Castro

Hi,
I have a new problem using multiple forms with Compact
Framework. I have two windows, when I call second window(It's
modal).Close(), the first window isn't visible, I discovered that the first
window is under another window like Explorer or any app that is open, I
tried to do call first.BringToFront(), first.Show() but it's doesn't show.
Can anyone help me?

Thank You
Eduardo Castro - MCSA
Computer Science Student.
 
BringToFront doesn't always seem to work, I found a good workaround is to
call SetForegroundWindow with the handle of your form - you can use
OpenNETCF Smart Device Framework (www.opennetcf.org/sdf/) for all the
P/Invokes:-

C#

public void SetForegroundWindow()
{
this.Capture = true;
IntPtr hwnd = OpenNETCF.Win32.Win32Window.GetCapture();
this.Capture = false;
OpenNETCF.Win32.Win32Window.SetForegroundWindow(hwnd);
}

or VB

Public Sub SetForegroundWindow
Me.Capture = True
Dim hwnd As IntPtr = OpenNETCF.Win32.Win32Window.GetCapture()
Me.Capture = False
OpenNETCF.Win32.Win32Window.SetForegroundWindow(hwnd)
End Sub

Peter

--
Peter Foot
Windows Embedded MVP
www.inthehand.com | www.opennetcf.org

Do have an opinion on the effectiveness of Microsoft Windows Mobile and
Embedded newsgroups? Let us know!
https://www.windowsembeddedeval.com/community/newsgroups
 
Hi,
It's works!

Thank You.

Peter Foot said:
BringToFront doesn't always seem to work, I found a good workaround is to
call SetForegroundWindow with the handle of your form - you can use
OpenNETCF Smart Device Framework (www.opennetcf.org/sdf/) for all the
P/Invokes:-

C#

public void SetForegroundWindow()
{
this.Capture = true;
IntPtr hwnd = OpenNETCF.Win32.Win32Window.GetCapture();
this.Capture = false;
OpenNETCF.Win32.Win32Window.SetForegroundWindow(hwnd);
}

or VB

Public Sub SetForegroundWindow
Me.Capture = True
Dim hwnd As IntPtr = OpenNETCF.Win32.Win32Window.GetCapture()
Me.Capture = False
OpenNETCF.Win32.Win32Window.SetForegroundWindow(hwnd)
End Sub

Peter

--
Peter Foot
Windows Embedded MVP
www.inthehand.com | www.opennetcf.org

Do have an opinion on the effectiveness of Microsoft Windows Mobile and
Embedded newsgroups? Let us know!
https://www.windowsembeddedeval.com/community/newsgroups
 
Back
Top