Hello
I have a HWND variable that I want to point to an hardcoded value, just for testing purposes. I guess that HWND is a typedef of (int*) so that is causing some kind of indirection. What should the correct code be like?
Hello
I have a HWND variable that I want to point to an hardcoded value, just for testing purposes. I guess that HWND is a typedef of (int*) so that is causing some kind of indirection. What should the correct code be like?
HWND abc = (HWND)(0x100);
Anyway, bad idea, but you already know that.
You can't hard code an HWND value. At best, it would not refer to an existing window. At worst, it would refer to some random window in the system.
Edit: To be clear, any tests you run using the hardcoded value will be meaningless. Your program uses that HWND for something. As soon as it passes the hardcoded HWND to an API function, either that function will fail (best case) or it will cause random, unpredictable effects in random processes (worst case).
You can do: HWND hWnd = reintrepret_cast<HWND>(0x100);
. Use explicit cast so that it is easy to find in the code.