I was playing with visual studio’s windows forms and the example code had this:
INT_PTR CALLBACK About(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
/*code cut*/
case WM_INITDIALOG:
return (INT_PTR)TRUE;
break;
While my other handler function looks like this:
LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
/*code cut*/
return 0; // no magical casting or anything, just plain int
I have a clue that in WndProc() when i do a return 0; it means the message wont get handled by the default message handler? but if you do return 1; it would handle with default handler?
But what is the point of return (INT_PTR)TRUE; ? and is it safe to use plain return 0; style there? i tried to compile and it works with just plain integer values too.
Also, im not sure when i should use which of the values, the example code had this:
EndDialog(hDlg, LOWORD(wParam));
return (INT_PTR)TRUE;
But what is the point of the return (INT_PTR)TRUE; there? I changed it to FALSE but couldnt see any difference in functionality.
So, im not sure what this is doing, could anyone clear my mind on this, when should i use return 1 and when should i use return 0, and when should i use something else (if i should) ?
The first piece of code is a DialogProc — quoting the relevant docs:
The second piece of code is a WindowProc — quoting the relevant docs:
So, that
/*code cut*/part is critically relevant, because which return value you want depends entirely on which message is being handled.