Community of VE/MapPoint Users and Developers
This is a discussion on Mappoint in VB.NET MDI within the MapPoint 2006/2009 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 ...
| |||||||
| Register | Blogs | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| |||
| Mappoint in VB.NET MDI 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
If any one has any ideas I would really appriciate hearing them. |
| |||
|
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. |
| |||
|
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
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()
|
| |||
| 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 |
| |||
| 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.
__________________ rgds, Wilfried Mestdagh www.mestdagh.biz MapPoint coding demo Order MapPoint 2009 with Routing and User Tools Spreadsheet |