Hi I've got a vb form that pulls a microsoft mappoint window into a subform using API, i've also then used some further API to remove the caption bar of the MapPoint window, however I cant seem to work out how to remove the menu items from the Mappoint Window.
Does anyone have any ideas?
The code is posted below
General Declerations-
Public gappmp As New MapPoint.Application
'Handle to MapPoint Window
Public ghwndMP As Long
'Used to get window style bits.
Public Const GWL_EXSTYLE = -20
Public Const GWL_STYLE = -16
'Force total redraw that shows new styles.
Public Const SWP_FRAMECHANGED = &H20
Public Const SWP_NOMOVE = &H2
Public Const SWP_NOZORDER = &H4
Public Const SWP_NOSIZE = &H1
'********************************************************
'* Window's API Function Prototypes
'********************************************************
' Enter each of the following Declare statements as one, single line:
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
Public Declare Function GetWindowLong Lib "user32" Alias "GetWindowLongA" _
(ByVal hWnd As Long, ByVal nIndex As Long) As Long
Public Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" _
(ByVal hWnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long
Public Declare Function SetWindowPos Lib "user32" _
(ByVal hWnd As Long, ByVal hWndInsertAfter As Long, ByVal X As Long, ByVal Y As Long, ByVal cx As Long, ByVal cy As Long, ByVal wFlags As Long) As Long
Public Declare Function GetWindowThreadProcessId Lib "user32.dll" _
(ByVal hWnd As Long, lpdwProcessId As Long) As Long
Private Declare Function apiGetFocus Lib "user32" _
Alias "GetFocus" _
() As Long
Public Sub FlipBit(hWnd As Long, ByVal lngStyleBit As Long, ByVal bValue As Boolean)
'Windows Style Manipulation Function
Dim lngStyle As Long
'Retrieve current style bits
lngStyle = GetWindowLong(hWnd, GWL_STYLE)
'Set requested bit On or Off
If bValue Then
lngStyle = lngStyle Or lngStyleBit
Else
lngStyle = lngStyle And Not lngStyleBit
End If
SetWindowLong hWnd, GWL_STYLE, lngStyle
'Redraw the window
Redraw hWnd
End Sub
Public Sub Redraw(hWnd As Long)
'Redraw window with new style
Const swpFlags As Long = SWP_FRAMECHANGED Or SWP_NOMOVE Or SWP_NOZORDER Or SWP_NOSIZE
SetWindowPos hWnd, 0, 0, 0, 0, 0, swpFlags
End Sub
Code on SubForm -
Private Const WS_CAPTION = &HC00000
Private Sub Form_Open(Cancel As Integer)
Dim objMap As MapPoint.Map
Dim oToolbar As MapPoint.Toolbar
Set gappmp = CreateObject("MapPoint.Application")
gappmp.NewMap "c:\TestMap.ptt"
gappmp.Visible = False
gappmp.UserControl = True
gappmp.PaneState = geoPaneNone
For Each oToolbar In gappmp.Toolbars
If oToolbar.Name = "Navigation" Then
oToolbar.Visible = True
MsgBox "True"
Else
oToolbar.Visible = False
MsgBox "False"
End If
Next
'Get the handle of the MapPoint Window
ghwndMP = FindWindow(vbNullString, "Map - Microsoft MapPoint Europe")
'Remove MapPoint Title Bar
FlipBit ghwndMP, WS_CAPTION, False
'Pull in Window
SetParent ghwndMP, Me.hWnd
Does anyone have any ideas?
The code is posted below
General Declerations-
Public gappmp As New MapPoint.Application
'Handle to MapPoint Window
Public ghwndMP As Long
'Used to get window style bits.
Public Const GWL_EXSTYLE = -20
Public Const GWL_STYLE = -16
'Force total redraw that shows new styles.
Public Const SWP_FRAMECHANGED = &H20
Public Const SWP_NOMOVE = &H2
Public Const SWP_NOZORDER = &H4
Public Const SWP_NOSIZE = &H1
'********************************************************
'* Window's API Function Prototypes
'********************************************************
' Enter each of the following Declare statements as one, single line:
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
Public Declare Function GetWindowLong Lib "user32" Alias "GetWindowLongA" _
(ByVal hWnd As Long, ByVal nIndex As Long) As Long
Public Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" _
(ByVal hWnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long
Public Declare Function SetWindowPos Lib "user32" _
(ByVal hWnd As Long, ByVal hWndInsertAfter As Long, ByVal X As Long, ByVal Y As Long, ByVal cx As Long, ByVal cy As Long, ByVal wFlags As Long) As Long
Public Declare Function GetWindowThreadProcessId Lib "user32.dll" _
(ByVal hWnd As Long, lpdwProcessId As Long) As Long
Private Declare Function apiGetFocus Lib "user32" _
Alias "GetFocus" _
() As Long
Public Sub FlipBit(hWnd As Long, ByVal lngStyleBit As Long, ByVal bValue As Boolean)
'Windows Style Manipulation Function
Dim lngStyle As Long
'Retrieve current style bits
lngStyle = GetWindowLong(hWnd, GWL_STYLE)
'Set requested bit On or Off
If bValue Then
lngStyle = lngStyle Or lngStyleBit
Else
lngStyle = lngStyle And Not lngStyleBit
End If
SetWindowLong hWnd, GWL_STYLE, lngStyle
'Redraw the window
Redraw hWnd
End Sub
Public Sub Redraw(hWnd As Long)
'Redraw window with new style
Const swpFlags As Long = SWP_FRAMECHANGED Or SWP_NOMOVE Or SWP_NOZORDER Or SWP_NOSIZE
SetWindowPos hWnd, 0, 0, 0, 0, 0, swpFlags
End Sub
Code on SubForm -
Private Const WS_CAPTION = &HC00000
Private Sub Form_Open(Cancel As Integer)
Dim objMap As MapPoint.Map
Dim oToolbar As MapPoint.Toolbar
Set gappmp = CreateObject("MapPoint.Application")
gappmp.NewMap "c:\TestMap.ptt"
gappmp.Visible = False
gappmp.UserControl = True
gappmp.PaneState = geoPaneNone
For Each oToolbar In gappmp.Toolbars
If oToolbar.Name = "Navigation" Then
oToolbar.Visible = True
MsgBox "True"
Else
oToolbar.Visible = False
MsgBox "False"
End If
Next
'Get the handle of the MapPoint Window
ghwndMP = FindWindow(vbNullString, "Map - Microsoft MapPoint Europe")
'Remove MapPoint Title Bar
FlipBit ghwndMP, WS_CAPTION, False
'Pull in Window
SetParent ghwndMP, Me.hWnd