View Single Post

  #1 (permalink)  
Old 03-30-2004
Dazzer 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.
Reply With Quote