Your syntax seems to check out, even though it is perhaps a bit unreadable, and the LPCREATESTRUCT cast is obviously unnecessary.
Your syntax seems to check out, even though it is perhaps a bit unreadable, and the LPCREATESTRUCT cast is obviously unnecessary. You mentioned that you get invalid values for x, perhaps lParam is not really a pointer to a CBT_CREATEWND structure? Are you checking that nCode of the callback function is equal to HCBT_CREATEWND before casting lParam?
I suppose I am sort of making this into a Win32 question rather than about pointers, but it's clear this is not a dereferencing issue. – Skyler Jan 18 '11 at 18:18 OK, for expample I get -2147483648 (or something similar) every time a window is created! – alex Jan 18 '11 at 18:21 #define CW_USEDEFAULT 0x80000000, which is -2147483648 when the type is LPARAM (long, 32-bit).
The value is correct, and your code is fine. Reference CreateWindowEx documentation on parameter x. – Skyler Jan 18 '11 at 18:25 what does "usedefault" mean?
So I should read the lParam in c# as an UIntPtr? But then I have CW_USEDEFAULT, but what is the window position then? – alex Jan 18 '11 at 18:31.
Well I can't really speak towards the fine details of why you get invalid x values, but I would likely write this code differently: // the way you had it, it was making a copy of the CREATESTRUCT and storing it in str // this just uses a pointer LPCREATESTRUCT str = ((LPCBT_CREATEWND)lParam)->lpcs; // when you have a pointer, use -> to use a member int normal = str->x; Since you said you are new to pointers, I'll explain -> a bit. When you write x->y, it is really the same as (*x). Y but with nicer syntax.
Also a note of advice, while the casts in this code seem reasonable. In general, if you find that you are casting a lot, you probably are doing it either the hard way, or the wrong way. So make sure you take the time to understand any casts that you do.
See my edits. Maybe the last line causes a wrong value being sent to my c# program? – alex Jan 18 '11 at 18:16 Is the HWND you are trying to get info about in another process or something?
– Evan Teran Jan 18 '11 at 18:19.
I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.