I have a win32 form, and a button on it. But I have 1 problem, how do I know when the user clicks the button?
I have this code so far:
Code:
LRESULT CALLBACK WindowProcedure (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
switch (message) /* handle the messages */
{
case WM_COMMAND:
if ((HWND) lParam == hwnd2)
{
DeleteFile("Copy of Test.txt");
}
break;
case WM_DESTROY:
PostQuitMessage (0); /* send a WM_QUIT to the message queue */
break;
default: /* for messages that we don't deal with */
return DefWindowProc (hwnd, message, wParam, lParam);
}
return 0;
}
Look at the case WM_COMMAND case. That works perfectly, I can tell what button is pressed and do actions acordingly. But I am wondering is that correct? Slow? And is there a better more effecient way?
Also the topic title says BN_CLICKED, but that doesn't work and msdn says it sends BN_CLICKED in the form of WM_COMMAND.