I'm just lightly delving into windows programming.
Not exactly sure what the difference is between the windows aPI and MFC (Though I hear the MFC is quite old and it sounds to me like another layer on top of the WinAPI).
Anyway the problem is this I am testing for the result of a message box and executing a conditional statement depending on the result, problem is the condition always seems to result to true. Anyway here's the portion of code that does that. Is there anything wrong with the logic??
Code:
LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
int answer; //stores the result of the message box
switch(msg)
{
case WM_MBUTTONDOWN:
case WM_LBUTTONDOWN:
{
char szFileName[MAX_PATH];
HINSTANCE hInstance = GetModuleHandle(NULL);
GetModuleFileName(hInstance, szFileName, MAX_PATH);
FlashWindow(hwnd, TRUE);
answer = MessageBox(hwnd, "Exit Applications Test Zone??", "Quit", MB_YESNO | MB_ICONINFORMATION);
if (answer = IDYES) DestroyWindow(hwnd); //Always seems to result to IDYES.... Why??
};
break;
case WM_CLOSE:
DestroyWindow(hwnd);
break;
case WM_DESTROY:
PostQuitMessage(0);
break;
default:
return DefWindowProc(hwnd, msg, wParam, lParam);
}
return 0;
}