110,566
社区成员
发帖
与我相关
我的任务
分享
[DllImport("User32.dll", EntryPoint = "CreateWindowEx")]
public static extern IntPtr CreateWindowEx(
ExWindowStyle dwExStyle,
string lpClassName,
string lpWindowName,
WindowStyle dwStyle,
int x,
int y,
uint nWidth,
uint nherght,
IntPtr hWndParent,
IntPtr hMenu,
IntPtr hlnstance,
int lpParam);
[DllImport("user32.dll", EntryPoint = "RegisterClassEx")]
public static extern int RegisterClassEx(
[In] ref WNDCLASSEX Ipwcx
);
WNDCLASSEX aWNDCLASSEX = new WNDCLASSEX();
aWNDCLASSEX.cbSize = (int)Marshal.SizeOf(aWNDCLASSEX);
aWNDCLASSEX.style = 0;
aWNDCLASSEX.lpfnWndProc = new IntPtr();
aWNDCLASSEX.cbClsExtra = 0;
aWNDCLASSEX.cbWndExtra = 0;
aWNDCLASSEX.hIcon = new IntPtr();
aWNDCLASSEX.hCursor = new IntPtr();
aWNDCLASSEX.hbrBackground = new IntPtr();
aWNDCLASSEX.lpszMenuName = null;
aWNDCLASSEX.lpszClassName = "WinClass";
aWNDCLASSEX.hIconSm = new IntPtr();
RegisterClassEx(ref aWNDCLASSEX);
int lpParam = 0;
IntPtr hWndParent = new IntPtr();
IntPtr hMenu = new IntPtr();
IntPtr i = CreateWindowEx (ExWindowStyle.WS_EX_CLIENTEDGE, "lpClassName", "lpWindowName", WindowStyle.WS_BORDER, 100, 100, 100, 100, hWndParent, hMenu, aWNDCLASSEX.hInstance, lpParam);
ShowWindow(i, 1);
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)]
public struct WNDCLASSEX
{
[MarshalAs(UnmanagedType.U4)]
public int cbSize;
[MarshalAs(UnmanagedType.U4)]
public int style;
public IntPtr lpfnWndProc; // not WndProc
public int cbClsExtra;
public int cbWndExtra;
public IntPtr hInstance;
public IntPtr hIcon;
public IntPtr hCursor;
public IntPtr hbrBackground;
public string lpszMenuName;
public string lpszClassName;
public IntPtr hIconSm;
}
[DllImport("user32.dll")]
[return: MarshalAs(UnmanagedType.U2)]
static extern short RegisterClassEx([In] ref WNDCLASSEX lpwcx);