Actually made radiobutton clicking work now.

This commit is contained in:
Pietro Gagliardi 2015-05-21 15:52:59 -04:00
parent 09d1a5e5db
commit 0cade42c6d
1 changed files with 13 additions and 1 deletions

View File

@ -7,12 +7,23 @@ struct radiobuttons {
uiControl *parent;
};
static BOOL onWM_COMMAND(uiControl *c, HWND hwnd, WORD code, LRESULT *lResult)
// TODO make sure this is the correct way to check radiobuttons
static BOOL onWM_COMMAND(uiControl *c, HWND clicked, WORD code, LRESULT *lResult)
{
struct radiobuttons *r = (struct radiobuttons *) c;
WPARAM check;
uintmax_t i;
HWND hwnd;
if (code != BN_CLICKED)
return FALSE;
for (i = 0; i < r->hwnds->len; i++) {
hwnd = ptrArrayIndex(r->hwnds, HWND, i);
check = BST_UNCHECKED;
if (clicked == hwnd)
check = BST_CHECKED;
SendMessage(hwnd, BM_SETCHECK, check, 0);
}
*lResult = 0;
return TRUE;
}
@ -143,6 +154,7 @@ static void radiobuttonsAppend(uiRadioButtons *rr, const char *text)
parent, NULL, hInstance, NULL);
if (hwnd == NULL)
logLastError("error creating radio button in radiobuttonsAppend()");
uiWindowsRegisterWM_COMMANDHandler(hwnd, onWM_COMMAND, uiControl(r));
ptrArrayAppend(r->hwnds, hwnd);
uiControlQueueResize(uiControl(r));
}