首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
您现在的位置: 程式碼之家 >> 編程語言 >  >> C語言 >> 關於C語言

C# 呼叫 Google Earth COM API 開發(二):Win32 API 封裝與視窗嵌入

     編輯:關於C語言

為了將 Google Earth 視窗嵌入自訂表單,需要呼叫 Win32 API 操作視窗父子關係、位置大小。本文定義 NativeMethods 封裝常用 API。

NativeMethods 關鍵定義

public class NativeMethods {
    [DllImport("user32.dll")] public static extern bool SetWindowPos(IntPtr hWnd, IntPtr hWndInsertAfter, int x, int y, int cx, int cy, uint uFlags);
    [DllImport("user32.dll")] public static extern IntPtr SetParent(IntPtr hWndChild, IntPtr hWndNewParent);
    [DllImport("user32.dll")] public static extern bool MoveWindow(IntPtr hWnd, int X, int Y, int nWidth, int nHeight, bool bRepaint);
    // 常數定義:HWND_TOP, SWP_NOSIZE, SWP_NOZORDER 等...
}

嵌入效果圖

此類別為後續視窗嵌入、調整大小、截圖等操作提供底層支援。

  1. 上一篇文章:
  2. 下一篇文章:
Copyright © 程式碼之家 All Rights Reserved