I use static controls or read only edit controls to display simple text info like this.
Code:
//button's BN_CLICKED handler
//clear previous result
SetDlgItemText(hWnd, IDC_RESULT_EDIT, "Processing....");
//do processing and report success/failure
if(SomeFunction() == SUCCESS)
{
SetDlgItemText(hWnd, IDC_RESULT_EDIT, "Success!");
}
else SetDlgItemText(hWnd, IDC_RESULT_EDIT, "Failure!");
Originally Posted by
Niara
By default a button click event sends a WM_COMMAND message to the button parent's window and the button identifier as the loworder value of wParam; you just have to search for that message and check if it comes from the desired button:
You should also check the TYPE of incomming msg is a BN_CLICKED (not one of the other button msgs send thru WM_COMMAND).
ie (HIWORD(wParam) == BN_CLICKED)
For example, you probably do not want to run that code if a user is using the TAB key to select a control / cycle thru the controls (generatating both a BN_SETFOCUS msg and a BN_KILLFOCUS msg).