My question : How does the program know if the button is pushed, and how can I use that in code? (I know the button must have a value like null/int depending on its state, but how do I check this variable, and use it in code?
I'm assuming it's something like - Example :
1 2 3 4
//Then run this code
The WM_LBUTTONDOWN message is sent to the button window. It then sends its parent a WM_COMMAND message.
So your main window's WndProc needs to handle WM_COMMAND looking for an ID value of BUTTON_ID (the ID is the low word of wParam, the high word the notifcation code, which will be BN_CLICK.) As follows:
(Here the IDs are for menu items. All basic controls (like Button, ComboBox, and ListBox), menu items, and accelerators are handled via the WM_COMMAND message. The only difference being that neither menu items nor accelerators use notification codes. But the newer controls in COMCTL32.DLL (like the List View, Rebar, and Tab) use a different message: WM_NOTIFY.)
int wmId, wmEvent;
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
wmId = LOWORD(wParam);
wmEvent = HIWORD(wParam);
// Parse the menu selections:
DialogBox(hInst, MAKEINTRESOURCE(IDD_ABOUTBOX), hWnd, About);
return DefWindowProc(hWnd, message, wParam, lParam);