1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66
|
BOOL CALLBACK DlgMain(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
switch(uMsg)
{
case WM_INITDIALOG:
{
refreshListboxWithDataLogs(hwndDlg, LOGS_LISTBOX);
Misc::enableDlgItm(hwndDlg, DELETE_BTN, false);
}
return TRUE;
case WM_CLOSE:
{
EndDialog(hwndDlg, 0);
}
return TRUE;
case WM_COMMAND:
{
switch(LOWORD(wParam))
{
case MENU_NEW_ROYAL_PYTHON:
DialogBox(hInst, MAKEINTRESOURCE(NEW_PYTHON_DLG), NULL, (DLGPROC)DlgMain);
break;
case FED_TODAY_BTN:
refreshListboxWithDataLogs(hwndDlg, LOGS_LISTBOX);
Manager::snakeFed(30, time(NULL));
break;
case DELETE_BTN:
int a;
a = MessageBoxA(0, (LPCSTR)"Are you sure you want to delete this log?", "", MB_YESNO);
if (a == IDYES)
{
cout << "Deleting " << pythonFedId;
Misc::enableDlgItm(hwndDlg, DELETE_BTN, false);
}
break;
case LOGS_LISTBOX:
switch(HIWORD(wParam))
{
case LBN_SELCHANGE:
int lblItem, recordId;
Leaf::Record* selRecord;
Leaf::Column* pfid;
HWND listbox;
listbox = GetDlgItem(hwndDlg, LOGS_LISTBOX);
lblItem = (int)SendMessage(listbox, LB_GETCURSEL, 0, 0);
recordId = (int)SendMessage(listbox, LB_GETITEMDATA, lblItem, 0);
selRecord = records->getRecord(recordId);
pfid = selRecord->getColumn("PYTHON_FED_ID");
pythonFedId = pfid->data.datai;
Misc::enableDlgItm(hwndDlg, DELETE_BTN, true);
break;
}
break;
}
}
return TRUE;
}
return FALSE;
}
|