Select to view content in your preferred language

Forms appearing below Arcmap window

1166
10
03-31-2011 07:07 AM
DanielSheehan1
New Contributor
Hi,

I am running Arcgis 10, coding in VB.Net with VS 2008.  One form that I try to show always comes to the front then the Arcmap window appears above it.  The Arcmap window disappears during processing time.  The form is called with Show().  ShowDialog() brings the form to the front but we need to give users access to the Arcmap window while the form is open.  I've tried the BringToFront() function but to no avail.  Any help will be appreciated.

Daniel
0 Kudos
10 Replies
RichardWatson
Frequent Contributor
When you display your form/dialog you need to tell Windows that the ArcMap window is the parent, i.e. IApplication.hWnd.
0 Kudos
MichaelRobb
Regular Contributor II
Or another option is to set the FORM properties to TopMost = True
Obviously the reults two methods are a tad different.
0 Kudos
DanielSheehan1
New Contributor
When you display your form/dialog you need to tell Windows that the ArcMap window is the parent, i.e. IApplication.hWnd.


Do you do this in the show function?  The argument can't be hWnd, instead it is looking for a form.  Can you give me an example of how you do this?

Daniel
0 Kudos
DanielSheehan1
New Contributor
Or another option is to set the FORM properties to TopMost = True
Obviously the reults two methods are a tad different.


These are different. I want the results form to appear above when it first appears and ever after but I want the users to be able to bring the Arcmap window to the front once they interact with the form.

Daniel
0 Kudos
RichardWatson
Frequent Contributor
System.Windows.Forms.Form has members ShowDialog and Show which take IWin32Window as an argument.

Google on "hWnd IWin32Window".
0 Kudos
MichaelRobb
Regular Contributor II
Yes, I publish tools all the time that allow arcmap interaction while forms are up.  (Downfall is user can alter TOC and other stuff while in the middle of your processes if your program involves counts etc, it can get messy, but thats besides the point.

FormWindowState.Normal
and do a [Your]form.show()
0 Kudos
DanielSheehan1
New Contributor
System.Windows.Forms.Form has members ShowDialog and Show which take IWin32Window as an argument.

Google on "hWnd IWin32Window".


I was hoping for an example.  I've tried web searches using those terms and can't see anything that actually works for me.  I use something from this forum found using your suggested search terms yesterday that using IntPtr (which most of the results use) and it functions as a topmost = true statement, which remains undesirable.

So, do you have an example.  By that I mean, do you have the lines of code that you have used that works?
0 Kudos
KenBuja
MVP Esteemed Contributor
Here's an example.

First is the Window Wrapper class

Public Class Win32HWNDWrapper

    Implements System.Windows.Forms.IWin32Window
    Private _hwnd As System.IntPtr

    Public ReadOnly Property Handle As System.IntPtr Implements System.Windows.Forms.IWin32Window.Handle
        Get
            Return _hwnd
        End Get
    End Property

    Public Sub New(ByVal Handle As System.IntPtr)
        _hwnd = Handle
    End Sub

End Class


and the code to open a form

MyForm.Show(New Win32HWNDWrapper(m_application.hWnd))
0 Kudos
DanielSheehan1
New Contributor
Hi Ken,

Thanks.  This is similar to a solution I tried yesterday but yields the same results: it has the effect of form.topmost = true.  I want the form to appear above the Arcmap window but then bring the Arcmap window to the front, when the user desires.  The app searches metadata for our SDE collection then adds selected layers to the map or brings up the metadata in a browser.  Our experience in the VB version is that people like to add data, look at the map, then add more data.  It works best as a non modal form that can be put behind the Arcmap window.

BTW your name sounds familiar.  Are you with NMFS?

Daniel
0 Kudos