84 lines
4.7 KiB
C#
84 lines
4.7 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Runtime.InteropServices;
|
|
|
|
namespace StgSharp.Graphics
|
|
{
|
|
/// <summary>
|
|
/// windows系统API类
|
|
/// </summary>
|
|
public partial class winapi
|
|
{
|
|
/// <summary>
|
|
/// The ChoosePixelFormat function attempts to match an appropriate pixel format supported by a device context to a given pixel format specification.
|
|
/// </summary>
|
|
/// <param name="hdc">
|
|
/// Specifies the device context that the function examines to determine the best match for the pixel format descriptor pointed to by ppfd.
|
|
/// </param>
|
|
/// <param name="ppfd">
|
|
/// Pointer to a PIXELFORMATDESCRIPTOR structure that specifies the requested pixel format.
|
|
/// </param>
|
|
/// <returns>
|
|
/// <para>If the function succeeds, the return value is a pixel format index (one-based) that is the closest match to the given pixel format descriptor.</para>
|
|
/// <para>If the function fails, the return value is zero.</para>
|
|
/// </returns>
|
|
[DllImport("gdi32.dll", ExactSpelling = false, EntryPoint = "ChoosePixelFormat", CharSet = CharSet.Auto, CallingConvention = CallingConvention.StdCall)]
|
|
public static extern int ChoosePixelFormat(IntPtr hdc, IntPtr ppfd);
|
|
|
|
/// <summary>
|
|
/// The SetPixelFormat function sets the pixel format of the specified device context to the format specified by the iPixelFormat index.
|
|
/// </summary>
|
|
/// <param name="hdc">
|
|
/// Specifies the device context whose pixel format the function attempts to set.</param>
|
|
/// <param name="format">
|
|
/// <para>Index that identifies the pixel format to set. </para>
|
|
/// <para>The various pixel formats supported by a device context are identified by one-based indexes.</para>
|
|
/// </param>
|
|
/// <param name="ppfd">
|
|
/// <para>Pointer to a PIXELFORMATDESCRIPTOR structure that contains the logical pixel format specification.</para>
|
|
/// <para>The system's metafile component uses this structure to record the logical pixel format specification.</para>
|
|
/// </param>
|
|
/// <returns>
|
|
/// If the function succeeds, the return value is TRUE.If the function fails, the return value is FALSE.
|
|
/// </returns>
|
|
[DllImport("gdi32.dll", ExactSpelling = false, EntryPoint = "SetPixelFormat", CharSet = CharSet.Auto, CallingConvention = CallingConvention.StdCall)]
|
|
public static extern bool SetPixelFormat(IntPtr hdc, int format, IntPtr ppfd);
|
|
|
|
/// <summary>
|
|
/// <para>The GetDC function retrieves a handle to a device context (DC) for the client area of a specified window or for the entire screen.</para>
|
|
/// <para>You can use the returned handle in subsequent GDI functions to draw in the DC.</para>
|
|
/// </summary>
|
|
/// <param name="hwnd">
|
|
/// A handle to the window whose DC is to be retrieved. If this value is NULL, GetDC retrieves the DC for the entire screen.
|
|
/// </param>
|
|
/// <returns>
|
|
/// <para>If the function succeeds, the return value is a handle to the DC for the specified window's client area.</para>
|
|
/// <para>If the function fails, the return value is NULL.</para>
|
|
/// </returns>
|
|
[DllImport("user32.dll", ExactSpelling = false, EntryPoint = "GetDC", CharSet = CharSet.Auto, CallingConvention = CallingConvention.StdCall)]
|
|
public static extern IntPtr GetDC(IntPtr hwnd);
|
|
|
|
/// <summary>
|
|
/// The SwapBuffers function exchanges the front and back buffers if the current pixel format for the window referenced by the specified device context includes a back buffer.
|
|
/// </summary>
|
|
/// <param name="hdc">
|
|
/// <para>Specifies a device context.</para>
|
|
/// <para> If the current pixel format for the window referenced by this device context includes a back buffer,</para>
|
|
/// <para>the function exchanges the front and back buffers.</para>
|
|
/// </param>
|
|
/// <returns>
|
|
/// If the function succeeds, the return value is TRUE.If the function fails, the return value is FALSE.
|
|
/// </returns>
|
|
[DllImport("gdi32.dll", ExactSpelling = false, EntryPoint = "SwapBuffers", CharSet = CharSet.Auto, CallingConvention = CallingConvention.StdCall)]
|
|
public static extern bool SwapBuffers(IntPtr hdc);
|
|
/// <summary>
|
|
/// 获取当前线程的控制台窗口句柄
|
|
/// </summary>
|
|
/// <returns>当前线程控制台句柄</returns>
|
|
[DllImport("kernel32.dll", ExactSpelling = false, EntryPoint = "GetConsoleWindow", CharSet = CharSet.Auto, CallingConvention = CallingConvention.StdCall)]
|
|
public static extern IntPtr GetConsoleWindow();
|
|
}
|
|
}
|