void Columns_OnInsert (HWND hDlg) { LPVIEWINFO lpvi = (LPVIEWINFO)CB_GetSelectedData (GetDlgItem (hDlg, IDC_COLUMNS)); HWND hAvail = GetDlgItem (hDlg, IDC_COL_AVAIL); HWND hShown = GetDlgItem (hDlg, IDC_COL_SHOWN); int ii = LB_GetSelected (hAvail); if (ii != -1) { size_t iAvail = LB_GetData (hAvail, ii); int iShown = 1+ LB_GetSelected (hShown); TCHAR szText[ cchRESOURCE ]; SendMessage (hAvail, LB_GETTEXT, ii, (LPARAM)szText); LB_AddItem (hShown, szText, iAvail); SendMessage (hAvail, LB_DELETESTRING, ii, 0); lpvi->aColumns[ lpvi->nColsShown ] = iAvail; lpvi->nColsShown ++; for (size_t iCol = 0; iCol < nCOLUMNS; ++iCol) { if (lpvi == &COLUMNS[ iCol ].vi) COLUMNS[ iCol ].fChanged = TRUE; } Columns_OnSelAvail (hDlg); Columns_OnSelShown (hDlg); PropSheetChanged (hDlg); } }
void Time_Edit_OnUpdate (TimeInfo *pti, HWND hEdit) { TCHAR szText[ cchRESOURCE ]; if ((hEdit == pti->hHours) || (hEdit == pti->hAMPM)) { GetWindowText (pti->hHours, szText, 256); pti->timeNow.wHour = (WORD)atol (szText); if (!pti->f24Hour) { if ((pti->timeNow.wHour < 12) && (LB_GetSelected (pti->hAMPM) == 1)) pti->timeNow.wHour += 12; else if ((pti->timeNow.wHour >= 12) && (LB_GetSelected (pti->hAMPM) == 0)) pti->timeNow.wHour -= 12; } } if (hEdit == pti->hMinutes) { GetWindowText (pti->hMinutes, szText, 256); pti->timeNow.wMinute = (WORD)atol (szText); } if ((pti->timeNow.wHour == 24) && (pti->timeNow.wMinute != 0)) { pti->timeNow.wMinute = 0; Time_Edit_SetText (pti, pti->hMinutes); } SYSTEMTIME st = pti->timeNow; Time_SendCallback (pti, TN_UPDATE, (LPARAM)&st); }
void Columns_OnMoveDown (HWND hDlg) { LPVIEWINFO lpvi = (LPVIEWINFO)CB_GetSelectedData (GetDlgItem (hDlg, IDC_COLUMNS)); HWND hAvail = GetDlgItem (hDlg, IDC_COL_AVAIL); HWND hShown = GetDlgItem (hDlg, IDC_COL_SHOWN); int ii = LB_GetSelected (hShown); if (ii != -1) { size_t iAvail = (size_t)LB_GetData (hShown, ii); lpvi->aColumns[ ii ] = lpvi->aColumns[ ii+1 ]; lpvi->aColumns[ ii+1 ] = iAvail; for (size_t iCol = 0; iCol < nCOLUMNS; ++iCol) { if (lpvi == &COLUMNS[ iCol ].vi) COLUMNS[ iCol ].fChanged = TRUE; } Columns_OnSelect (hDlg); LB_SetSelectedByData (hShown, (LPARAM)iAvail); Columns_OnSelShown (hDlg); PropSheetChanged (hDlg); } }
void Columns_OnDelete (HWND hDlg) { LPVIEWINFO lpvi = (LPVIEWINFO)CB_GetSelectedData (GetDlgItem (hDlg, IDC_COLUMNS)); HWND hAvail = GetDlgItem (hDlg, IDC_COL_AVAIL); HWND hShown = GetDlgItem (hDlg, IDC_COL_SHOWN); int ii = LB_GetSelected (hShown); if (ii != -1) { TCHAR szText[ cchRESOURCE ]; SendMessage (hShown, LB_GETTEXT, ii, (LPARAM)szText); size_t iAvail = (size_t)LB_GetData (hShown, ii); LB_AddItem (hAvail, szText, iAvail); SendMessage (hShown, LB_DELETESTRING, ii, 0); for ( ; ii < (int)lpvi->nColsShown-1; ++ii) { lpvi->aColumns[ ii ] = lpvi->aColumns[ ii+1 ]; } lpvi->nColsShown --; for (size_t iCol = 0; iCol < nCOLUMNS; ++iCol) { if (lpvi == &COLUMNS[ iCol ].vi) COLUMNS[ iCol ].fChanged = TRUE; } Columns_OnSelAvail (hDlg); Columns_OnSelShown (hDlg); PropSheetChanged (hDlg); } }
void Columns_OnSelAvail (HWND hDlg) { HWND hList = GetDlgItem (hDlg, IDC_COL_AVAIL); int ii = LB_GetSelected (hList); EnableWindow (GetDlgItem (hDlg, IDC_COL_INSERT), (ii != -1)); }
void ChangeAddr_OnSelect (HWND hDlg) { HWND hList = GetDlgItem (hDlg, IDC_SVR_ADDRESSES); BOOL fSelected = (LB_GetSelected (hList) != -1) ? TRUE : FALSE; EnableWindow (GetDlgItem (hDlg, IDC_ADDR_CHANGE), fSelected); EnableWindow (GetDlgItem (hDlg, IDC_ADDR_REMOVE), fSelected); }
void Columns_OnSelShown (HWND hDlg) { HWND hList = GetDlgItem (hDlg, IDC_COL_SHOWN); int ii = LB_GetSelected (hList); if (ii == -1) { EnableWindow (GetDlgItem (hDlg, IDC_COL_DELETE), FALSE); EnableWindow (GetDlgItem (hDlg, IDC_COL_UP), FALSE); EnableWindow (GetDlgItem (hDlg, IDC_COL_DOWN), FALSE); } else { UINT_PTR iAvail = LB_GetData (hList, ii); EnableWindow (GetDlgItem (hDlg, IDC_COL_DELETE), (iAvail != 0)); int ci = (int)SendMessage (hList, LB_GETCOUNT, 0, 0); EnableWindow (GetDlgItem (hDlg, IDC_COL_UP), (ii > 1)); EnableWindow (GetDlgItem (hDlg, IDC_COL_DOWN), (ii > 0 && ii < ci-1)); } }
void ChangeAddr_OnRemove (HWND hDlg, LPSVR_CHANGEADDR_PARAMS lpp) { HWND hList = GetDlgItem (hDlg, IDC_SVR_ADDRESSES); int iSel; if ((iSel = LB_GetSelected (hList)) != -1) { TCHAR szItem[ cchRESOURCE ] = TEXT(""); SendMessage (hList, LB_GETTEXT, iSel, (LPARAM)szItem); SOCKADDR_IN AddrSel; Server_ParseAddress (&AddrSel, szItem); int AddrSelInt; AfsClass_AddressToInt (&AddrSelInt, &AddrSel); if (AddrSelInt != 0) { for (size_t iAddr = 0; iAddr < lpp->ssOld.nAddresses; ++iAddr) { int OldAddrInt; AfsClass_AddressToInt (&OldAddrInt, &lpp->ssOld.aAddresses[iAddr]); int NewAddrInt; AfsClass_AddressToInt (&NewAddrInt, &lpp->ssNew.aAddresses[iAddr]); if ((OldAddrInt == AddrSelInt) || (NewAddrInt == AddrSelInt)) { AfsClass_IntToAddress (&lpp->ssNew.aAddresses[iAddr], 0); } } } Server_FillAddrList (hDlg, &lpp->ssNew, FALSE); ChangeAddr_OnSelect (hDlg); } }
void ChangeAddr_OnChange (HWND hDlg, LPSVR_CHANGEADDR_PARAMS lpp) { HWND hList = GetDlgItem (hDlg, IDC_SVR_ADDRESSES); int iSel; if ((iSel = LB_GetSelected (hList)) != -1) { TCHAR szItem[ cchRESOURCE ] = TEXT(""); SendMessage (hList, LB_GETTEXT, iSel, (LPARAM)szItem); SOCKADDR_IN AddrSel; Server_ParseAddress (&AddrSel, szItem); int AddrSelInt; AfsClass_AddressToInt (&AddrSelInt, &AddrSel); if (AddrSelInt != 0) { SOCKADDR_IN AddrNew = AddrSel; if (ModalDialogParam (IDD_SVR_NEWADDR, hDlg, (DLGPROC)NewAddr_DlgProc, (LPARAM)&AddrNew) != IDOK) return; int AddrNewInt; AfsClass_AddressToInt (&AddrNewInt, &AddrNew); if (AddrNewInt && (AddrNewInt != AddrSelInt)) { // First see if the new IP address is already in the server's // list of IP addresses--if so, just delete the old address. // size_t iAddr; for (iAddr = 0; iAddr < lpp->ssOld.nAddresses; ++iAddr) { int OldAddrInt; AfsClass_AddressToInt (&OldAddrInt, &lpp->ssOld.aAddresses[iAddr]); int NewAddrInt; AfsClass_AddressToInt (&NewAddrInt, &lpp->ssNew.aAddresses[iAddr]); if ((OldAddrInt == AddrNewInt) || (NewAddrInt == AddrNewInt)) { AddrNewInt = 0; break; } } // Now update the SERVERSTATUS structure. // for (iAddr = 0; iAddr < lpp->ssOld.nAddresses; ++iAddr) { int OldAddrInt; AfsClass_AddressToInt (&OldAddrInt, &lpp->ssOld.aAddresses[iAddr]); int NewAddrInt; AfsClass_AddressToInt (&NewAddrInt, &lpp->ssNew.aAddresses[iAddr]); if ((OldAddrInt == AddrSelInt) || (NewAddrInt == AddrSelInt)) { AfsClass_IntToAddress (&lpp->ssNew.aAddresses[iAddr], AddrNewInt); break; } } } } Server_FillAddrList (hDlg, &lpp->ssNew, FALSE); ChangeAddr_OnSelect (hDlg); } }
BOOL CALLBACK Subsets_DlgProc (HWND hDlg, UINT msg, WPARAM wp, LPARAM lp) { if (AfsAppLib_HandleHelp (IDD_SUBSETS, hDlg, msg, wp, lp)) return TRUE; if (msg == WM_INITDIALOG) SetWindowLongPtr (hDlg, DWLP_USER, ((LPPROPSHEETPAGE)lp)->lParam); LPSUBSET sub = (LPSUBSET)GetWindowLongPtr (hDlg, DWLP_USER); switch (msg) { case WM_INITDIALOG_SHEET: PropCache_Add (pcGENERAL, NULL, hDlg); break; case WM_DESTROY_SHEET: PropCache_Delete (hDlg); break; case WM_INITDIALOG: Subsets_OnInitDialog (hDlg, sub); break; case WM_COMMAND: switch (LOWORD(wp)) { case IDAPPLY: Subsets_OnApply (hDlg, sub); break; case IDOK: case IDCANCEL: EndDialog (hDlg, LOWORD(wp)); break; case IDC_SUBSET_LOAD: LPSUBSET subNew; subNew = Subsets_OnLoad (hDlg, sub); if (subNew != NULL) { if (sub) Subsets_FreeSubset (sub); SetWindowLongPtr (hDlg, DWLP_USER, (LONG_PTR)subNew); } break; case IDC_SUBSET_LIST: if (HIWORD(wp) == LBN_CLICKED) // checked or unchecked? { int iSel = LB_GetSelected (GetDlgItem (hDlg, IDC_SUBSET_LIST)); subNew = Subsets_OnCheck (hDlg, iSel, sub); if (subNew && (subNew != sub)) { if (sub) Subsets_FreeSubset (sub); SetWindowLongPtr (hDlg, DWLP_USER, (LONG_PTR)subNew); } } break; case IDC_SUBSET_SAVE: Subsets_OnSave (hDlg, sub); break; case IDC_SUBSET_ALL: case IDC_SUBSET_NONE: subNew = Subsets_OnCheckAll (hDlg, sub, (LOWORD(wp) == IDC_SUBSET_ALL) ? TRUE : FALSE); if (subNew && (subNew != sub)) { if (sub) Subsets_FreeSubset (sub); SetWindowLongPtr (hDlg, DWLP_USER, (LONG_PTR)subNew); } break; } break; } return FALSE; }