Show / Hide Table of Contents

Method WndUtil.CreateWindow(+ 1 overload)


Overload

Creates native/unmanaged window (API CreateWindowEx) and sets its window procedure.

public static wnd CreateWindow(WNDPROC wndProc, bool keepAlive, string className, string name = null, WS style = 0, WSE exStyle = 0, int x = 0, int y = 0, int width = 0, int height = 0, wnd parent = default, nint controlId = 0, nint hInstance = 0, nint param = 0)
Parameters
wndProc  (WNDPROC)

Window procedure.

keepAlive  (bool)

Protect wndProc from GC (garbage collector) until the window is destroyed (message WM_NCDESTROY received or thread ended).

important

In some cases it may prevent destroying the window until thread ends, and it can be a big memory leak. For example WPF then does not destroy HwndHost-ed controls. Then let keepAlive=false and manually manage wndProc lifetime, for example keep it as a field of the wrapper class.

className  (string)
name  (string)
style  (WS)
exStyle  (WSE)
x  (int)
y  (int)
width  (int)
height  (int)
parent  (wnd)
controlId  (nint)
hInstance  (nint)
param  (nint)
Returns
wnd
Exceptions
AuException

Failed to create window. Unlikely.

Remarks

If the class was registered with WndUtil.RegisterWindowClass with nullwndProc, the wndProc function will receive all messages. Else will not receive messages sent before CreateWindowEx returns (WM_CREATE etc).

To destroy the window can be used any function, including API DestroyWindow, WndUtil.DestroyWindow, wnd.Close, API WM_CLOSE.


Overload(top)

Creates native/unmanaged window.

public static wnd CreateWindow(string className, string name = null, WS style = 0, WSE exStyle = 0, int x = 0, int y = 0, int width = 0, int height = 0, wnd parent = default, nint controlId = 0, nint hInstance = 0, nint param = 0)
Parameters
className  (string)
name  (string)
style  (WS)
exStyle  (WSE)
x  (int)
y  (int)
width  (int)
height  (int)
parent  (wnd)
controlId  (nint)
hInstance  (nint)
param  (nint)
Returns
wnd
Exceptions
AuException

Failed to create window. Unlikely.

Remarks

Calls API CreateWindowEx. To destroy the window can be used any function, including API DestroyWindow, WndUtil.DestroyWindow, wnd.Close, API WM_CLOSE.

See Also

WndUtil.RegisterWindowClass