Example #1
0
        /// <summary>Move the GoogleEarth's map control to the specified control
        /// Move the GoogleEarth's map control to the specified control
        /// </summary>
        /// <param name="parentControl">The specified control that GoogleEarth's map control will be moved to.</param>
        /// <param name="geApplication">The application which will be moved to the specified control. </param>
        public void SetGEHandlerToControl(System.Windows.Forms.Control parentControl, IApplicationGE geApplication)
        {
            this._parentControl = parentControl;
            this._googleEarth = geApplication;

            //Get the Handler of the application's MainForm to SetGEHandler._GEMainHandler.
            this._GEMainHandler = (IntPtr)this._googleEarth.GetMainHwnd();

            //Set the Hight of GoogleEarth's MainForm to 0, and hide the Height of GoogleEarth's MainForm.
            GetGEControl.SetWindowPos(this._GEMainHandler, GetGEControl.HWND_BOTTOM, 0, 0, 0, 0, GetGEControl.SWP_NOSIZE + GetGEControl.SWP_HIDEWINDOW);

            // Get the Handler of the application's map control.
            this._GEHandler = (IntPtr)_googleEarth.GetRenderHwnd();

            //Get the Handler of GoogleEarth's parentForm from GoogleEarth's map control.
            this._GEParentHandler = GetGEControl.GetParent(this._GEHandler);

            //将GE地图控件的父窗体设置为不可见
            //Hide the parentForm of GoogleEarth.
            GetGEControl.PostMessage((int)this._GEParentHandler, GetGEControl.WM_HIDE, 0, 0);

            //Set the Handler of GoogleEarth's parentForm to winform's control.
            GetGEControl.SetParent(this._GEHandler, parentControl.Handle);

            //
            ResizeGEControl();
        }
Example #2
0
        /// <summary>
        /// 加载GE地图
        /// </summary>
        /// <summary>
        /// 加载Google Earth
        /// </summary>
        private void LoadGE()
        {
            if (isGeStarted)
            {
                return;
            }
            try
            {
                GeApp = (ApplicationGEClass)Activator.CreateInstance(Type.GetTypeFromProgID("GoogleEarth.Application"));
                isGeStarted = true;
            }
            catch
            {
                GeApp = new ApplicationGEClass();
                // 30%;
                ///progress.WorkDown = 30;
                isGeStarted = true;
            }

            GEHWnd = (IntPtr)GeApp.GetMainHwnd();

            //隐藏主窗口
            //NativeMethods.SetWindowPos(GEHWnd, NativeMethods.HWND_BOTTOM, 0, 0, 0, 0, NativeMethods.SWP_HIDEWINDOW);

            NativeMethods.ShowWindowAsync((int)GEHWnd, 0);
            // 40%;
            //progress.WorkDown = 40;

            _GEHrender = (IntPtr)GeApp.GetRenderHwnd();
            _GEParentHrender = (IntPtr)NativeMethods.GetParent(_GEHrender);

            NativeMethods.SetParent(_GEHrender, this.Control.Handle);
            // 50%;
            //progress.WorkDown = 50;

            ResizeGoogleControl();
        }