Map control events in VBA

Mar 5, 2015 at 1:30 PM
MW Map control in a Microsoft Access 2003 form. The map control is in a Frame 2.0 on the main form surface, and it can open and display shapefiles and tiles. I can zoom and pan the map, but I am unable to get it to respond to a "mouse selection by box" even after I've changed the cursor type. The yellow selection box appears, but nothing happens when I release the mouse button.

The following two lines from SelectBox.cs appear to be crucial:
            axMap1.SendSelectBoxFinal = true;
            MapEvents.SelectBoxFinal += AxMap1SelectBoxFinal; // change MapEvents to axMap1
I've translated the first line into VBA, but what is the VBA equivalent for the send line?

My program also contains the following procedure.

Private Sub axMap_SelectBoxFinal(ByVal Left As Long, ByVal Right As Long, ByVal Bottom As Long, ByVal Top As Long)
MsgBox "here"
End Sub

I thought that setting SendSelectBoxFinal = true would enable the event handler, but that does not seem to be happening. Thanks in advance.
Mar 6, 2015 at 6:40 AM
Edited Mar 6, 2015 at 6:43 AM
Hi, first of all please check if you have handler for Map.ChooseLayer event anywhere in your code. In case you handle it, e.g.
private void MapChooseLayer(object sender, _DMapEvents_ChooseLayerEvent e)
    e.layerHandle = legend.SelectedLayer;    // or any other source of active layer
you won't have SelectBoxFinal event. To have the event in this case one needs:
private void MapChooseLayer(object sender, _DMapEvents_ChooseLayerEvent e)
    if (map.CursorMode != cmSelection)     // exclude selection cursor
        e.layerHandle = legend.SelectedLayer;
But generally if you just need to change Shapefile.ShapeSelected property, I'd recommend to use ChooseLayer event, it will select shapes just fine, i.e. do the job for you.

Other than that I believe there is no other preconditions to have the SelectBoxFinal event fired as you've already set SendSelectBoxFinal to true. It is also fired by our demo app after I changed ChooseLayer handler like described above.

Hope it helps,
Jun 26, 2015 at 4:13 PM

Just to tie up a loose end. I had posted the question while on the road and unable to devote enough time to implementation. Only got back to programming after returning home.

Your advice helped a lot, but I struggled for a long time to understand how to implement it in VBA. Bottom line is that I have always created event procedures using each object's properties sheet, but that technique does not work with the map control. Took me a long time to realize that I could choose the map object from the list of objects in the code editor, and find every available event. Once I passed that hurdle, I could follow your advice about the Choose Layer event. I've got the "selection" process working, and my program is nearing completion.

Thanks again for your excellent product and helpful advice.