Showing ZIP code divisions for territories programmatically

Fer
09-10-2003, 04:43 PM
Hello all,

I have been having some trouble handling territories using VB.Net (or VB6). My main issue is that I need to have the ability to show the Zip code divisions that appear when defining territories using ZIP Codes but I don't need to have the Territories Manager also appearing at the same time. I've noticed that the only way to make these divisions appear is if I also have the Territory Manager on the map, and I wish to avoid that.

I haven't actually been able to find out much about handling territories programmatically, so if anyone has done something like this then any suggestions are welcome.

I've also been hitting my head repeatedly trying to find out how to do in code the same simple stuff that one can do with the application like for example adding to a territory or deleting a territory. So far I can only end up with a dataset collection after using the ImportTerritories method but can't do a whole lot with it.
Anyone has done some territory programming that could give me a few pointers about it? All will be much appreciated.

Thanls again,

Fernando

Anonymous
09-10-2003, 06:51 PM
I found a way to do it, but it ain't clean! It basically has to do with using Sergiy Pavlov's article of 'Extending the MapPoint ActiveX Control'. I found out that I only have to use the
ShowWindow(hWnd, SW_NORMAL)
API call, where hWnd is the handle to the territory manager dialog obtained through Spy++ and SW_NORMAL is a const to indicate that the window is to be shown. this only shows the zip code divisions and doesn't show the territory manager dialog. BUT there's a trick to it: first, you gotta have a way to find out the hWnd of the TM dialog, since it changes from instance to instance, and you also must have previously loaded at least one territory before this works, or else MP won't know the type of division that you want to show.

It looks kind of complicated but it's the best I've got so far. If anyone comes up with a better idea please share it in the forum. I'm still trying to see how to achieve the other functions I need to carry out. I saw that maybe the LinkTerritories method might help a bit, because I would only be left with the data source to deal with, but at the expense of performance because all the territories will have to be refreshed everytime I make a small change in the data source.

As always, any ideas are appreciated.

 
Web mp2kmag.com
mapforums.com