Using Windows Forms, I wanted to put the window at specific coordinates. I thought this could be done in a simple way, but the following code does not work at all:
public Form1() { InitializeComponent(); this.Top = 0; this.Left = 0; }
However, when you get only a handle to this window, it works well:
public Form1() { InitializeComponent(); IntPtr hwnd = this.Handle; this.Top = 0; this.Left = 0; }
You can see that I do not work with this pointer at all. I found the following statement on MSDN:
The value of the Handle property is Windows HWND. If the handle has not yet been created, a reference to this property will force the handle to be created.
Does this mean that we can set the position of the window only after creating its handle? Do the upper / left setters set with this handle inside? Thank you for your clarification.
source share