창 을 설정 하면 마우스 드래그 크기 로 통과 할 수 있 습 니 다.
4985 단어 쓰다
private void Window_Loaded(object sender, RoutedEventArgs e)
{
//
IntPtr hwnd = new System.Windows.Interop.WindowInteropHelper(this).Handle;
//
int oldstyle = NativeMethods.GetWindowLong(hwnd, NativeMethods.GWL_STYLE);
//
NativeMethods.SetWindowLong(hwnd, NativeMethods.GWL_STYLE, oldstyle & ~NativeMethods.WS_CAPTION);
// SetWindowLong(hwnd, GWL_EXSTYLE, oldstyle & ~WS_EX_LAYERED);
// 1 | 2 << 8 | 3 << 16 r=1,g=2,b=3 winuse.h
//
NativeMethods.SetLayeredWindowAttributes(hwnd, 1 | 2 << 8 | 3 << 16, 0, NativeMethods.LWA_ALPHA);
// 12
NativeMethods.SetWindowRgn(hwnd, NativeMethods.CreateRoundRectRgn(0, 0, Convert.ToInt32(this.ActualWidth), Convert.ToInt32(this.ActualHeight), 12, 12), true);
}
NativeMethods.cs :
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace SEsoft
{
public class NativeMethods
{
/// <summary>
/// windows
/// </summary>
public const int WS_CAPTION = 0X00C0000;
/// <summary>
/// window
/// </summary>
public const int WS_EX_LAYERED = 0x00080000;
/// <summary>
/// alpha
/// </summary>
public const int LWA_ALPHA = 0x00000002;
/// <summary>
///
/// </summary>
public const int LWA_COLORKEY = 0x00000001;
/// <summary>
/// window
/// </summary>
public const int GWL_STYLE = -16;
/// <summary>
/// window
/// </summary>
public const int GWL_EXSTYLE = -20;
/// <summary>
///
/// </summary>
/// <param name="handle"> </param>
/// <param name="oldStyle"> .</param>
/// <param name="newStyle"> </param>
[System.Runtime.InteropServices.DllImport("User32.dll")]
public static extern void SetWindowLong(IntPtr handle, int oldStyle, int newStyle);
/// <summary>
/// .
/// </summary>
/// <param name="handle"> </param>
/// <param name="style"> </param>
/// <returns> window </returns>
[System.Runtime.InteropServices.DllImport("User32.dll")]
public static extern int GetWindowLong(IntPtr handle, int style);
/// <summary>
/// .
/// </summary>
/// <param name="handle"> .</param>
/// <param name="handleRegion"> .</param>
/// <param name="regraw">if set to <c>true</c> [regraw].</param>
/// <returns> </returns>
[System.Runtime.InteropServices.DllImport("User32.dll")]
public static extern int SetWindowRgn(IntPtr handle, IntPtr handleRegion, bool regraw);
/// <summary>
/// .
/// </summary>
/// <param name="x1"> X .</param>
/// <param name="y1"> Y .</param>
/// <param name="x2"> X .</param>
/// <param name="y2"> Y .</param>
/// <param name="width"> width.</param>
/// <param name="height"> height.</param>
/// <returns>hRgn </returns>
[System.Runtime.InteropServices.DllImport("gdi32.dll")]
public static extern IntPtr CreateRoundRectRgn(int x1, int y1, int x2, int y2, int width, int height);
/// <summary>
/// Sets the layered window attributes.
/// </summary>
/// <param name="handle"> </param>
/// <param name="colorKey">RGB </param>
/// <param name="alpha">Alpha , </param>
/// <param name="flags"> </param>
/// <returns>true or false</returns>
[System.Runtime.InteropServices.DllImport("User32.dll")]
public static extern bool SetLayeredWindowAttributes(IntPtr handle, uint colorKey, byte alpha, int flags);
}
}
이 내용에 흥미가 있습니까?
현재 기사가 여러분의 문제를 해결하지 못하는 경우 AI 엔진은 머신러닝 분석(스마트 모델이 방금 만들어져 부정확한 경우가 있을 수 있음)을 통해 가장 유사한 기사를 추천합니다:
페이지에 한마디 쓰기helloworld! innerHTML 메서드 appendChild(),createTextNode() 메서드 쓰기 좀 더 복잡한 This is mycontent....
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
CC BY-SA 2.5, CC BY-SA 3.0 및 CC BY-SA 4.0에 따라 라이센스가 부여됩니다.