Following the "C # call GoogleEarth Com API Development (i)", Neil also brings you to the second article. This article, based on the first article, shows how to invoke the Windows API to hide the GoogleEarth interface and display the GoogleEarth map on a custom form. Less nonsense, directly on the code.
1, the main window code:
1://function: GE instance (ii)
2://Description: GE COM API URL: http://earth.google.com/comapi/index.html
3://Author: Wen Weipeng
4://Date: 2009-02-08
5:
6:using System;
7:using System.Collections.Generic;
8:using System.ComponentModel;
9:using System.Data;
10:using System.Drawing;
11:using System.Text;
12:using System.Windows.Forms;
13:using Earthlib;
14:
15:namespace Gedemo
16: {
17:public Partial class Form2:form
18: {
:///<summary>
20: Message definition used by///to turn off GoogleEarth
:///</summary>
22:static readonly Int32 wm_quit = 0x0012;
23:
24:private IntPtr Gehwnd = (IntPtr) 5;
25:private IntPtr Gehrender = (IntPtr) 5;
26:private IntPtr Geparenthrender = (IntPtr) 5;
:///<summary>
28:///Define GE application classes
:///</summary>
30:private Applicationgeclass Geapp;
31:
32:public Form2 ()
33: {
34:initializecomponent ();
35:}
36:
37:protected override void OnLoad (EventArgs e)
38: {
39:base. OnLoad (e);
40:
41:if (!this. DesignMode)
42: {
43:geapp = new Applicationgeclass ();
44:
45:gehwnd = (INTPTR) Geapp.getmainhwnd ();
46:
47:nativemethods.setwindowpos (Gehwnd, nativemethods.hwnd_bottom, 0, 0, 0, 0,
48:nativemethods.swp_nosize + Nativemethods.swp_hidewindow);
49:
50:gehrender = (INTPTR) Geapp.getrenderhwnd ();
51:geparenthrender = (IntPtr) nativemethods.getparent (Gehrender);
52:
53:nativemethods.movewindow (gehrender, 0, 0, this.) Width, this. Height, True);
54:
55:nativemethods.setparent (Gehrender, this. Handle);
56:}
57:}
58:
59:protected override void OnClosing (CancelEventArgs e)
60: {
61:base. OnClosing (e);
62:
63:nativemethods.postmessage (Geapp.getmainhwnd (), wm_quit, 0, 0);
64:}
65:}
66:}