Reputation: 10643
I have a hex value to a window i found using Spy++.
the value is: 00010010
Thanks to an answer to a question i asked earlier, i have this code:
IntPtr hwndf = this.Handle;
IntPtr hwndParent = FindWindow("WINDOW HERE", null); ;
SetParent(hwndf, hwndParent);
this.TopMost = false;
Now, as far as i understand it, IntPtr hwndParent will contain the handle to the window WINDOW HERE. How can i rewrite that line to use my hex handle? I tried:
IntPtr hwndParent = (IntPtr) 0x00010010
But it didnt work. Any ideas?
Upvotes: 2
Views: 8482
Reputation: 60912
Well, the hex equivalent of 00010010 is 0x12. So you could theoretically use
IntPtr hwndParent = (IntPtr) 0x12
The Windows calculator can do that conversion. That value doesn't sound correct, though. Can you explain in more detail how you got that value?
EDIT: Your comment mentions that you're trying to get a handle to the desktop window. There's a function for that: GetDesktopWindow, which returns an IntPtr. If all you're ever interested in is the desktop window, use that.
Here's the P/Invoke for that function:
[DllImport("user32.dll", CharSet=CharSet.Auto, ExactSpelling=true)]
public static extern IntPtr GetDesktopWindow();
Upvotes: 1
Reputation: 9827
Since you're talking about this question: It seems you don't want to create a widget/window on top of the desktop but on top of another window instead? If that's the case, why don't you use FindWindow() to - find that window?
Why a constant value?
Upvotes: 0
Reputation: 42227
The constructor of IntPtr accepts an initialization parameter:
IntPtr hwndParent = new IntPtr(0x00010010);
Upvotes: 1
Reputation: 7889
This should work
var hwnd = new IntPtr(Convert.ToInt32({HexNumber}, 16));
Upvotes: 0