how to use/extract identity of a control inside an activex control

假如想象 提交于 2020-01-02 12:19:11

问题


I have yet another problem..

Consider looking at THIS first..

on my early problems, I needed to drag a button, and a form in relation to how I drag/move the pictureBox.. All controls are inside .NET

Now I am working on this great Control, GMaps in which adapts the google's API in .NET framework.
My goal is to create something like the infoWindow on google's API. so I resorted on customizing it by creating a new form (acting as the infoWindow) on the first link above. If you've seen Gmaps.net, it really is a map. Draggable, pan to zoom, can add markers/polygons.. one thing that it lacks is its documentation + the infoWindow tool that I want with the marker..
it only has its "tooltip" that can only have string in it.
e.g marker.ToolTipText="Blah Blah"
on codeplex' discussions, it is said that you must create your own tooltip for it not to only display a string. but I can't find a good example except THIS in which inherits a contextMenu which I cannot particularly use because whenever I click again, it disappears.

back to my question, if you've checked the first link above, you'll know what I want to achieve, the only problem now is, I can't use this code as it is :

Point p = Button1.PointToScreen(Point.Empty);
p.Offset(0, (-1 * Form2.Height) - 15);
Form2.Location = p;

this code makes Form2 follow Button1 wherever it goes.. Unfortunately, on my gMap control, there is no button. there is only the marker inside.
Remember : this map is a control

so, how can I use the marker as a parent of the form, so if I try to drag the map, it follows.. something like this :

Point p = marker.PointToScreen(Point.Empty);
p.Offset(0, (-1 * Form2.Height) - 15);
Form2.Location = p;

UPDATE I used this code, no errors, does not work..

 void mainMap_MouseDown(object sender, MouseEventArgs e)
    {

        Point p = (marker.LocalPosition = PointToScreen(Point.Empty));
        //Point p = button1.PointToScreen(Point.Empty); --> this gives the error that it cannot be converted
        p.Offset(0, (-1 * f2.Height) - 15);
        f2.Location = p;
    }

回答1:


 void mainMap_OnMapDrag()
    {

        f2.Show();
        f2.Location = marker.LocalPosition;
        //No offsetting..
    }

the LocalPosition property gets the position of the marker in relative to the screen. Only problem is the Dispose function in C#, if you only create one instance, you can't recreate it, if you add an instance, it will create Form2 every pixel moved. It'll be better in VB.



来源:https://stackoverflow.com/questions/20256176/how-to-use-extract-identity-of-a-control-inside-an-activex-control

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!