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

Got Mappoint ActiveX working in Delphi 5

This is a discussion on Got Mappoint ActiveX working in Delphi 5 within the MapPoint Desktop Discussion forums, part of the Map Forums category; I noticed that a lot of people are having this problem (as was I) but I now have the mappoint ...

  1. #1
    lynx is offline Junior Member White Belt
    Join Date
    Oct 2003
    Posts
    5

    Got Mappoint ActiveX working in Delphi 5

    I noticed that a lot of people are having this problem (as was I) but I now have the mappoint activex control working w/in delphi.

    It turns out that the mappoint ocx does not support the IPersistStreamInit interface, which delphi uses to store the activex in the dfm.
    That is why you get the error... "Interface not supported".
    Mappoint does not support (or from what I can tell... need) this. As long as you are loading your maps programmatically then this will not be a problem.

    I can't post the source code due to the fact that I had to modify Borland code and posting it would be illegal. I will however... tell you how to modify the code yourself.

    I basically had to copy the whole OleCtrls.pas file into a new file I call OleCtrlNoPersist.pas and inside of there removed the following methods/variables from the TOleControl.

    - FPersistStream variable (and all references in the Create, Destroy, CreateControl and DoObjectVerb methods)
    - FObjectData variable (and the "if" block it's referenced in from CreateControl (which will have to be gone for FPersistStream anyways))
    - Stream variable of the CreateControl method (not needed anymore due to the "if" block above being removed)
    - DefineProperties method (which does the actual storage)
    - CreateStorage method
    - DestroyStorage method (and its reference in the Destroy method. The reference in CreateControl should be gone if you removed the "if" block described above)
    - WriteData method (used by DefineProperties)
    - ReadData method (used by DefineProperties)

    You can then change all references of TOleControl to TOleControlNoPersist throughout the whole unit.

    Once that is done and I have imported the MapPoint Activex control all I have to do is change the TMappointControl object to descend from TOleControlNoPersist (including changing the uses from OleCtrls to OleCtrlNoPersist).

    Recompile your package and drop the TMappointControl on a form... call the NewMap(geoMapNorthAmerica) on it... and there you have it.

    I did all this in the last little bit so I'm not totally sure that there are no other problems as of yet. I will know soon enough tho, since the project I'm working on has to be done in a few days.

    If you have any other questions then please go ahead and e-mail me.
    Please don't ask for the source code because I have no way of verifying that I'm not breaking the law by giving it to you. Everything you need should be above.

    FWI... I have not even checked to see if this works in D6 or D7 or if it's even a problem cause the current project I'm working on is in D5

    Enjoy,
    Chris Menser (cmenser@phatrock.com)

  2. #2
    Eric Frost's Avatar
    Eric Frost is offline Administrator Black Belt
    Join Date
    Jul 1992
    Posts
    5,094
    Blog Entries
    4
    Very cool, thanks Chris.
    ~ Order MapPoint MapPoint 2013 Here and Get Free Access to the MapForums Downloads ~
    ~~
    ~ Upgrade to Get Access to the MapForums Downloads ~

  3. #3
    Gauloisid is offline Junior Member White Belt
    Join Date
    Oct 2003
    Posts
    4
    I've not seen this post before this morning, but today will be a great day !!
    I've made change like you tell and it's work very well on Delphi 7 !
    Just a little problem in design time, i can't resize control with my mouse, i must write pos and size in the object inspector directly.
    But it's not very disturbing...

    Many thanks for your post !!

  4. #4
    lynx is offline Junior Member White Belt
    Join Date
    Oct 2003
    Posts
    5
    Quote Originally Posted by Gauloisid
    I've not seen this post before this morning, but today will be a great day !!
    I've made change like you tell and it's work very well on Delphi 7 !
    Just a little problem in design time, i can't resize control with my mouse, i must write pos and size in the object inspector directly.
    But it's not very disturbing...

    Many thanks for your post !!
    I also noticed that you can't select it in design time. I had it on a panel set to alclient so I hadn't noticed it until the other day. I might look into that but I doubt it.... just not a pressing issue to me

    Good to know about the D7 thing tho... thanks. I was writing an addon to an existing app that was done in D5 but I will be converting it to D7 here shortly so I'm glad it works

    If you have any more questions don't hesitate to e-mail me.

    Thanks,
    Chris Menser (cmenser@phatrock.com)

  5. #5
    Anonymous is offline Senior Member Black Belt
    Join Date
    Jul 2002
    Posts
    5,137
    Upon following the directions in order to allow MapPoint to be used in Delphi. I find that it works up to a point!

    I can now not use any APPLICATION type functions. i.e Application.ProcessMessages etc.

    Delphi gives an error stating that an object or class is required.

    Upon removing the MapPoint_TLB item from the USES list, Application is recognised and compiles correctly, but of course without mappoint.

    Any ideas as to what's causing this, and how I can continue using Application. etc.

    I'm using Delphi 6 Enterprise.

    Regards
    Les

  6. #6
    Guido_J is offline Junior Member White Belt
    Join Date
    Apr 2004
    Posts
    2

    It works, but I still have problems

    Great solution! Now I can indeed place the TMapPointControl on a form.

    I can call
    MappointControl1.DoObjectVerb(1);
    Caption:=MappointControl1.Build;
    any many other methods/properties.

    but creating a new map always fails
    MyMap:=MappointControl1.NewMap(geoMapEurope);

    The error message is (translated from german) "Error loading mappoint: Unknown error"

    If I try
    MyMap:=MappointControl1.NewMap(geoMapNorthAmerica) ;
    I get the correct message "Map not registered".

    Using Mappoint 2004 in an OLEContainer does work fine, but of course there I can't get the events (MouseDown, RouteAfterCalculate).

    Any suggestions what I should change?

  7. #7
    Guido_J is offline Junior Member White Belt
    Join Date
    Apr 2004
    Posts
    2

    Heureka

    Simple mistake: Don't call NewMap() in CreateForm! After that it works perfectly! I use Delphi 7.

    Thanks again, Guido

  8. #8
    Anonymous is offline Senior Member Black Belt
    Join Date
    Jul 2002
    Posts
    5,137
    What I did was to copy the OleCtrl.pas file in my sourcedirectory and included it in my project.
    Then I created the Mappoint control in the on form create event with as parent a panel.
    Set a breakpoint in the "constructor TOleControl.Create(AOwner:
    TComponent);" routine from the OleCtrl.pas file
    you have to debug it twice and there are two lines you have to gray out as comment
    1) OleCheck(FOleObject.QueryInterface(IPersistStreamI nit,FPersistStream));
    2) OleCheck(FPersistStream.Load(Stream));

    Now the application will compile correctly.

    Load your map in the on Form.Activate event and there you go...

    HTH
    Regards,
    Peter

  9. #9
    micheln is offline Junior Member Yellow Belt
    Join Date
    Jan 2007
    Posts
    16

    Re: Got Mappoint ActiveX working in Delphi 5

    Thanks a lot : it works perfectly on Delphi 7 fr

  10. #10
    Yukon is offline Junior Member White Belt
    Join Date
    Apr 2010
    Posts
    1

    Re: Got Mappoint ActiveX working in Delphi 5

    I found that your solution also works for CodeGear2007 and MapPoint2009. Great workaround. Thank you for this!

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Mappoint 2004 ActiveX Delphi 2005 How to add a Polyline
    By it-fraggel in forum MapPoint Desktop Discussion
    Replies: 3
    Last Post: 04-04-2006, 02:23 PM
  2. MapPoint ActiveX Wrapper for Delphi 5/7
    By Anonymous in forum News and Announcements
    Replies: 4
    Last Post: 11-18-2003, 10:15 AM
  3. Hi there. Working with MapPoint 2002, Is it pos....
    By Anonymous in forum MapPoint Desktop Discussion
    Replies: 1
    Last Post: 06-25-2002, 10:36 AM
  4. I am working with Mappoint in Pakistan and I want ....
    By Anonymous in forum MapPoint Desktop Discussion
    Replies: 1
    Last Post: 06-22-2002, 10:02 AM
  5. i have added the activeX component(s) to delphi. ....
    By Anonymous in forum MapPoint Desktop Discussion
    Replies: 1
    Last Post: 02-01-2002, 05:35 AM

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