Welcome to MapForums!

Register, sign in, or use Facebook Connect above to join in and participate in the forum.

When you are signed in, this message, the ads in this row, and the red-underlined link ads all go away.

Subscribe to receive our newsletter.
Subscribe Unsubscribe
Results 1 to 7 of 7

Mappoint in VB.NET MDI

This is a discussion on Mappoint in VB.NET MDI within the MapPoint Desktop Discussion forums, part of the Map Forums category; We've been using an Access application for a while now which uses the SetParent API to pull a Mappoint window ...

  1. #1
    Dazzer is offline Senior Member Green Belt
    Join Date
    Sep 2003
    Posts
    103

    Mappoint in VB.NET MDI

    We've been using an Access application for a while now which uses the SetParent API to pull a Mappoint window into an Access form.

    I am now trying to recreate the program using VB.NET but I cant seem to get the Mappoint window into my .NET mdi parent window

    Here is the code we had in our Access app

    Code:
    Public gappmp As New MapPoint.Application
    
    Public ghwndMP As Long
    
    Public Declare Function FindWindow Lib "user32" Alias "FindWindowA" _
           (ByVal lpClassname As String, ByVal lpWindowName As String) As Long
            
    Public Declare Function SetParent Lib "user32" _
           (ByVal hWndChild As Long, ByVal hWndNewParent As Long) As Long
    Code:
      Set gappmp = CreateObject("MapPoint.Application")
      
    'Open map
        gappmp.NewMap "c:\Map\Map.ptt"
        gappmp.Visible = True
        gappmp.UserControl = True
        gappmp.PaneState = geoPaneNone
    
            For Each oToolbar In gappmp.Toolbars
                If oToolbar.Name = "Navigation" Or oToolbar.Name = "navigation" Then
                    oToolbar.Visible = True
                Else
                    oToolbar.Visible = False
                End If
            Next
            DoEvents
    
      'Get the handle of the MapPoint Window
      ghwndMP = FindWindow(vbNullString, "Map - Microsoft MapPoint Europe")
      
    'pull map into access window and lose unnecassary toolbars
        SetParent ghwndMP, Me.hwnd
    Does any one know how I can do a similar thing with vb.Net, i've tried it and by putting the code in the mdi's on load event and all it does is open the form and a mappoint window but it keeps them seperat (doesn't put the mappoint window in the mdi) clearly something is going wrong with the SetParent command but I have no idea what.

    If any one has any ideas I would really appriciate hearing them.

  2. #2
    Anonymous is offline Senior Member Black Belt
    Join Date
    Jul 2002
    Posts
    5,137
    Make sure that the ISMDIParent boolean property is set to True. This will make your main parent form for all MDI child forms. Be aware that it will turn the parent form to a dark grey color.

  3. #3
    Anonymous is offline Senior Member Black Belt
    Join Date
    Jul 2002
    Posts
    5,137
    Sorry. the property you need is the ISMDIContainer of the main form

  4. #4
    Dazzer is offline Senior Member Green Belt
    Join Date
    Sep 2003
    Posts
    103
    Thanks for you help, I've tried this put I seem to be having some trouble returning the handle of my MDIContainer form and setting it to be the parent of the Mappoint application.

    It appears that Me.hwnd is different in .Net but i'm unsure of what it should be instead.

    Have you any ideas where I could be going wrong.

  5. #5
    Dazzer is offline Senior Member Green Belt
    Join Date
    Sep 2003
    Posts
    103
    Done it

    If any one else needs to do anything similar what you need to do is first declare the following in your module

    Code:
        Public Declare Function SetParent Lib "user32" (ByVal hWndChild As Integer, ByVal hWndNewParent As Integer) As Long
        Public Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" (ByVal hwnd As Integer, ByVal nIndex As Integer, ByVal dwNewLong As Integer) As Integer
        Public Declare Function GetWindowLong Lib "user32" Alias "GetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long) As Long
        Public Declare Auto Function FindWindowNullClassName Lib "user32.dll" Alias "FindWindow" (ByVal lpClassName As Integer,  ByVal lpWindowName As String) As Integer
    
        Public Const WS_CHILD = &H40000000
        Public Const GWL_STYLE = (-16)
        Public Const WS_VISIBLE = &H10000000
    
         Public gappmp As New MapPoint.Application
    Then in the mdi containers on load event put
    Code:
    gappmp = CreateObject("MapPoint.Application")
    gappmp.Visible = True
    gappmp.UserControl = True
    gappmp.PaneState = MapPoint.GeoPaneState.geoPaneNone
    
    MpOpen = FindWindowNullClassName(0, "Map - Microsoft Mappoint Europe")
    
            Dim retval, retval2 As Long
            Dim formHandle As Integer
            formHandle = Me.Handle.ToInt32
            retVal = SetWindowLong(MpOpen, GWL_STYLE, WS_CHILD Or WS_VISIBLE)
            retval2 = SetParent(MpOpen, formHandle)
            
            Application.DoEvents()

  6. #6
    smramesh is offline Junior Member White Belt
    Join Date
    Mar 2008
    Posts
    1

    Re: Mappoint in VB.NET MDI

    Hi,

    Suppose I have applications named "App1.exe" & "App2.exe" and they are running in my windows desktop. I am developing a VB.NET application named "App3.exe".

    Is it possible for me to get windows that are displayed by App1.exe and App2.exe inside App3.exe window? I mean, i want to take control of how they are displayed on desktop. Also, i would like them to be inside my App3.exe windows. Is it possible?

    Any clue? Pls!

    Thanks
    MR

  7. #7
    Wilfried is offline Senior Member Black Belt
    Join Date
    Nov 2004
    Location
    Belgium
    Posts
    2,433

    Re: Mappoint in VB.NET MDI

    Hi,

    This has nothing to do with mappoint. I suggest you repost in one of the various .net newsgroups or forums. I think what you try to do is possible but not very easy to do.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96