I have a program I'm writing for Win64 in C++ that is executed from a parent program, and needs to set its parent window to the parent program's window. The parent program passes in it's HWND in as a command line argument, and I'm parsing the argument as an int (using stoi()) before it is cast to an HWND. A simplified version of my code is shown below:
int parentHwnd = stoi(args[HWND_INDEX]);
SetParent(childHwnd, (HWND) parentHwnd);
However, I'm getting the following error when compiling:
warning C4312: 'type cast': conversion from 'int' to 'HWND' of greater size
Is there safe way to cast an int to a HWNDand eliminate this error? Or should I be parsing the given command line arg to something other than an int that will safely be able to be cast to a HWND?