程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
 程式師世界 >> 編程語言 >> C語言 >> 關於C語言 >> C#調用Google Earth Com API開發(二)(2)

C#調用Google Earth Com API開發(二)(2)

編輯:關於C語言

2、NativeMethods類定義:

1: // 功能:Windows API調用
2: // 描述:大家可以參照MSDN
3: // 作者:溫偉鵬
4: // 日期:2009-02-08
5:
6: using System;
7: using System.Collections.Generic;
8: using System.Text;
9: using System.Runtime.InteropServices;
10:
11: namespace GEDemo
12: {
13:   public class NativeMethods
14:   {
15:     [DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError =  true)]
16:     public static extern bool SetWindowPos(IntPtr hWnd, IntPtr  hWndInsertAfter, int x, int y, int cx, int cy, UInt32 uflags);
17:
18:     [DllImport("user32.dll", CharSet = CharSet.Auto)]
19:     public static extern IntPtr PostMessage(int hWnd, int msg, int  wParam, int lParam);
20:
21:     #region 預定義
22:
23:     public static readonly IntPtr HWND_BOTTOM = new IntPtr(1);
24:     public static readonly IntPtr HWND_NOTOPMOST = new IntPtr(-2);
25:     public static readonly IntPtr HWND_TOP = new IntPtr(0);
26:     public static readonly IntPtr HWND_TOPMOST = new IntPtr(-1);
27:     public static readonly UInt32 SWP_NOSIZE = 1;
28:     public static readonly UInt32 SWP_NOMOVE = 2;
29:     public static readonly UInt32 SWP_NOZORDER = 4;
30:     public static readonly UInt32 SWP_NOREDRAW = 8;
31:     public static readonly UInt32 SWP_NOACTIVATE = 16;
32:     public static readonly UInt32 SWP_FRAMECHANGED = 32;
33:     public static readonly UInt32 SWP_SHOWWINDOW = 64;
34:     public static readonly UInt32 SWP_HIDEWINDOW = 128;
35:     public static readonly UInt32 SWP_NOCOPYBITS = 256;
36:     public static readonly UInt32 SWP_NOOWNERZORDER = 512;
37:     public static readonly UInt32 SWP_NOSENDCHANGING = 1024;
38:
39:     #endregion
40:
41:     public delegate int EnumWindowsProc(IntPtr hwnd, int lParam);
42:
43:     [DllImport("user32", CharSet = CharSet.Auto)]
44:     public extern static IntPtr GetParent(IntPtr hWnd);
45:
46:     [DllImport("user32", CharSet = CharSet.Auto)]
47:     public extern static bool MoveWindow(IntPtr hWnd, int X, int Y,  int nWidth, int nHeight, bool bRepaint);
48:
49:     [DllImport("user32", CharSet = CharSet.Auto)]
50:     public extern static IntPtr SetParent(IntPtr hWndChild, IntPtr  hWndNewParent);
51:
52:     [DllImport("user32.dll", ExactSpelling = true, CharSet =  CharSet.Auto)]
53:     public static extern IntPtr GetWindow(IntPtr hWnd, int uCmd);
54:
55:     public static int GW_CHILD = 5;
56:     public static int GW_HWNDNEXT = 2;
57:   }
58: }

3、執行效果:

  1. 上一頁:
  2. 下一頁:
Copyright © 程式師世界 All Rights Reserved