C # calls Google Earth Com API Development (II)

Source: Internet
Author: User

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:}

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.