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 4 of 4

How to reference the Windows Handle of a MapPoint control in an Access Form?

This is a discussion on How to reference the Windows Handle of a MapPoint control in an Access Form? within the Development forums, part of the MapPoint Desktop Discussion category; I think I'm getting close, but I don't know.. this is the stuff I tried so far. Code: Dim ghwndMP ...

  1. #1
    Eric Frost's Avatar
    Eric Frost is offline Administrator Black Belt
    Join Date
    Jul 1992
    Posts
    5,094
    Blog Entries
    4

    How to reference the Windows Handle of a MapPoint control in an Access Form?

    I think I'm getting close, but I don't know.. this is the stuff I tried so far.

    Code:
      Dim ghwndMP As Long
      Dim hwMPC As Long
      
      'get the correct handle
      ghwndMP = FindWindow(vbNullString, "Map - Microsoft MapPoint North America")
      hwMPC = GetParentWindow(FindWindowEx(ghwndMP, 0, vbNullString, vbNullString))
      Dim hwTemp As Long
      hwTemp = FindWindowEx(hwMPC, 0, vbNullString, "")
      'objMapHwndExec = objMap.hWnd_Exec
      'objMapHwndFrame = objMap.hWnd_Frame
      
      'this attempts to trigger the pushpin
      Dim ret As Long
      ret = SendMessage(ghwndMP, WM_COMMAND, WM_MAPPOINT_DRAW_PUSHPIN, 0)
      ret = SendMessage(hwMPC, WM_COMMAND, WM_MAPPOINT_DRAW_PUSHPIN, 0)
      'this is the line that should normally work
      ret = SendMessage(hwTemp, WM_COMMAND, WM_MAPPOINT_DRAW_PUSHPIN, 0)
    As you can see, I'm basically just trying to trigger the clicking of the "draw pushpin" button that's on the toolbar.

    Any suggestions?

    Is there a better way to go about it?

    Thanks,
    Eric
    Last edited by Eric Frost; 02-24-2009 at 05:43 PM.
    ~ Order MapPoint MapPoint 2013 Here and Get Free Access to the MapForums Downloads ~
    ~~
    ~ Upgrade to Get Access to the MapForums Downloads ~

  2. #2
    Eric Frost's Avatar
    Eric Frost is offline Administrator Black Belt
    Join Date
    Jul 1992
    Posts
    5,094
    Blog Entries
    4

    Re: How to reference the Windows Handle of a MapPoint control in an Access Form?

    I tried to take a stab at some more things, no luck yet.

    Code:
      'Dim MeHwnd As Long
      'MeHwnd = Me.Handle
      'ret = SendMessage(MeHwnd, WM_COMMAND, WM_MAPPOINT_DRAW_PUSHPIN, 0)
      
      'Dim MPCHwnd As Long
      'MPCHwnd = objMPC.Handle
      'ret = SendMessage(MPCHwnd, WM_COMMAND, WM_MAPPOINT_DRAW_PUSHPIN, 0)
    How should I go about solving this?

    Eric
    ~ Order MapPoint MapPoint 2013 Here and Get Free Access to the MapForums Downloads ~
    ~~
    ~ Upgrade to Get Access to the MapForums Downloads ~

  3. #3
    Eric Frost's Avatar
    Eric Frost is offline Administrator Black Belt
    Join Date
    Jul 1992
    Posts
    5,094
    Blog Entries
    4

    Re: How to reference the Windows Handle of a MapPoint control in an Access Form?

    It looks like I ought to be able to figure it out from this --

    API: Drawing images on an Access form

    Particularly this part "iterate through all child windows of the form" --

    Code:
    Function fGetClientHandle(frm As Form) As Long
    '   Returns a handle to the client window of a form
    '   An Access form's hWnd is actually bound to the
    '   recordselector "window"
    '
    Dim hWnd As Long
     
        '   get the first child window of the form
        hWnd = apiGetWindow(frm.hWnd, GW_CHILD)
     
        '   iterate through all child windows of the form
        Do While hWnd
            '   if we locate the client area whose class name is "OFormSub"
            If fGetClassName(hWnd) = ACC_FORM_CLIENT_CLASS Then
                '   the Client window's child is a window with the class
                '   name of OFEDT, so just verify that we're looking at the
                '   right window
                If fGetClassName(apiGetWindow( _
                    hWnd, GW_CHILD)) = _
                        ACC_FORM_CLIENT_CHILD_CLASS Then
                                '   if we found a match, then return
                                '   the handle and we're outta here.
                                fGetClientHandle = hWnd
                                Exit Do
                End If
            End If
            '   get a handle to the next child window
            hWnd = apiGetWindow(hWnd, GW_HWNDNEXT)
        Loop
    End Function

    I'm just curious how I am going to identify the map, i.e. find a match; the name of my MappointControl in my application is MPC. Maybe that is the class name?

    Anyway, I'll put some sweat into it later today and report back if I figure it out...

    Eric
    ~ Order MapPoint MapPoint 2013 Here and Get Free Access to the MapForums Downloads ~
    ~~
    ~ Upgrade to Get Access to the MapForums Downloads ~

  4. #4
    Eric Frost's Avatar
    Eric Frost is offline Administrator Black Belt
    Join Date
    Jul 1992
    Posts
    5,094
    Blog Entries
    4

    Re: How to reference the Windows Handle of a MapPoint control in an Access Form?

    Frak me. The original code worked, I just needed to stop sending so many messages.

    In debugging, I started to put in Exit Sub's in various places to see if one of them was actually working, but that the subsequent messages nullified it. That's exactly what was happening. The first line worked.

    Code:
      'this attempts to trigger the pushpin
      Dim ret As Long
      ret = SendMessage(ghwndMP, WM_COMMAND, WM_MAPPOINT_DRAW_PUSHPIN, 0)
    Exit Sub
      ret = SendMessage(hwMPC, WM_COMMAND, WM_MAPPOINT_DRAW_PUSHPIN, 0)
    Exit Sub
      'this is the line that should normally work
      ret = SendMessage(hwTemp, WM_COMMAND, WM_MAPPOINT_DRAW_PUSHPIN, 0)
    Exit Sub
    I guess it's interesting to know that the (invisible) window title of the MapPoint control is actually the default title "Map - Microsoft MapPoint North America", for some reason I did not expect that.

    Ninja turtle!

    Eric
    ~ Order MapPoint MapPoint 2013 Here and Get Free Access to the MapForums Downloads ~
    ~~
    ~ Upgrade to Get Access to the MapForums Downloads ~

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Mappoint and Access with ActiveX On A Form
    By jpateusa in forum MapPoint Desktop Discussion
    Replies: 5
    Last Post: 05-16-2009, 07:32 PM
  2. MapPoint Automation from an Access Form
    By arcturus19 in forum MapPoint Desktop Discussion
    Replies: 8
    Last Post: 01-14-2008, 11:31 PM
  3. MapPoint control and MDI form
    By ddsoft in forum MapPoint Desktop Discussion
    Replies: 7
    Last Post: 05-03-2007, 05:18 AM
  4. API Reference for Mappoint 2006 Windows Forms Control
    By sh856531 in forum MapPoint Desktop Discussion
    Replies: 2
    Last Post: 03-06-2007, 06:56 AM
  5. Getting the Handle of the MapPoint Control...
    By joer1234 in forum MapPoint Desktop Discussion
    Replies: 1
    Last Post: 09-30-2004, 12:35 PM

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 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127