In general, this function usually uses the switch to check the message event, but what you did is equivalent. Regarding what should be returned, when everything happens fine but the event is not in the switch's conditions (or in this case the if's), it returns "DefWindowProc (hWnd, message, wParam, lParam)" in default only by returning the message, or it returns 0 at the end of the function after being accepted in a case and having passed the break, when returning 0 you are simply returning nothing, as if the event had already been resolved.
Actually I do not know the return of this function to report error and I do not know if it exists, but usually, when a serious error occurs, or the program stops working, or you show a MessageBox informing the error and it returns message in the loop asking for close the program, usually this is done using the "PostQuitMessage (0);" which basically returns the WM_CLOSE message to the loop, it's basically like doing "return SendMessage (hwnd, WM_CLOSE, 0, 0);".
LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) {
if (message == WM_CREATE) {
// Ações durante o carregamento
} else if (message == WM_COMMAND) {
// Ações ao clicar em algo
} else if (message == WM_CLOSE) {
// Ações ao fechar a janela
} else if (message == WM_DESTROY) {
PostQuitMessage(0); // MSG para fechar o programa, manda a mensagem WM_CLOSE
} else {
return(DefWindowProc(hWnd, message, wParam, lParam)); // Devolve a mensagem
}
return 0; // Se o evento foi resolvido retorna 0
}
Yes, the "return (DefWindowProc (hWnd, message, wParam, lParam));" is placed in the right place, because this is called whenever none of the conditions were accepted, ie it is the last case so it is in the default block of the switch, but when passing an event returns 0 at the end of the function to inform that the event has already been resolved.
I hope I have helped