void COptionSheet::OnBack() { LRESULT result; // Make sure there is a current item it has a page ASSERT(NULL != m_CurrentPage); // Make sure the Next button is enabled CWnd *wnd = GetDlgItem(ID_WIZBACK); if(NULL == wnd) { return; } if(FALSE == wnd->IsWindowEnabled()) { return; } // Check to see if we can move to the next page result = GetPage(m_PageIndex)->OnWizardNext(); switch(result) { case -1: break; case 0: SetActivePage(--m_PageIndex); break; default: if(result > 0) { SetActivePage(result); } break; } return; }
void COXRollup::ReArrangeArranged() { POSITION pos = m_ArrangedRollups.GetHeadPosition(); if (pos == NULL) return; // this function has to be as fast as possible CWnd* pMainWnd = AfxGetMainWnd(); ASSERT((pMainWnd != NULL) && ::IsWindow(pMainWnd->m_hWnd)); // don´t care about OLE if (!pMainWnd->IsWindowEnabled() && pMainWnd->IsIconic()) return; // set out new top point; because we have to move to first position CWnd* pWndLeftOverPane = pMainWnd->GetDlgItem(AFX_IDW_PANE_FIRST); ASSERT(pWndLeftOverPane != NULL); CRect rcWndNewPos; pWndLeftOverPane->GetWindowRect(&rcWndNewPos); int nLeft = rcWndNewPos.left; int nNewTop = rcWndNewPos.top; COXRollup* pRoll = NULL; while (pos != NULL) { pRoll = (COXRollup*)m_ArrangedRollups.GetNext(pos); pRoll->GetWindowRect(&rcWndNewPos); pRoll->SetWindowPos(NULL, nLeft, nNewTop, 0, 0, SWP_NOZORDER | SWP_NOSIZE | SWP_NOACTIVATE); nNewTop += rcWndNewPos.Height() - 1; } }
BOOL CProgressWnd::GoModal(LPCTSTR pszTitle /*=_T("Progress")"*/, BOOL bSmooth /*=FALSE*/) { CWnd *pMainWnd = AfxGetMainWnd(); if (!::IsWindow(m_hWnd) && !Create(pMainWnd, pszTitle, bSmooth)) return FALSE; // Walk up the window chain to find the main parent wnd and disable it. CWnd * wnd = this; do { CWnd * parent = wnd->GetParent(); // if we have no parent (ie. the main window) // or if our parent is disabled, // then this is the window that we will want to remember for reenabling if (!parent || !parent->IsWindowEnabled()) { m_wRenenableWnd = wnd; m_wRenenableWnd->EnableWindow(false); break; } wnd = parent; } while (1); // Re-enable this window EnableWindow(TRUE); m_bModal = TRUE; return TRUE; }
void CPatchPageDlg::EnableControls(bool Enable) { CWnd *pFirstCtrl = GetWindow(GW_CHILD); ASSERT(pFirstCtrl != NULL); // need at least one control // if requested state differs from first control's enable state if (Enable != (pFirstCtrl->IsWindowEnabled() != 0)) CWinAppCK::EnableChildWindows(*this, Enable); // iterate controls }
void CPageEvents::ToggleCheckBox(UINT id) { CWnd* pwndCheckBox = GetDlgItem(id); if (!pwndCheckBox->IsWindowEnabled()) MessageBeep(static_cast<DWORD>(-1)); else { bool bChecked = BST_CHECKED == IsDlgButtonChecked(id); CheckDlgButton(id, bChecked ? BST_UNCHECKED : BST_CHECKED); } }
void CTemplateDialog::OnDblClkTemplate(NMHDR* /*pNMHDR*/, LRESULT* pResult) { CWnd *pOkButton = GetDlgItem(IDC_BUTTON_CREATE); if (!pOkButton || !pOkButton->IsWindowEnabled()) return; // simulate click on button OnCreate(); *pResult = 0; }
void CSiteGroupPropertiesDlg::EnableOK(bool enable) { CWnd *ok = GetDlgItem(IDOK); ASSERT(ok); if (ok->IsWindowEnabled()) { if (enable == false) ok->EnableWindow(FALSE); } else { if (enable) ok->EnableWindow(TRUE); } }
void DDV_FileEditCtrl(CDataExchange *pDX, int nIDC) { // verify the files or folder entered actually exists // verify that files are entered when looking for files // and that folders are entered when looking for folders CWnd *pWnd = pDX->m_pDlgWnd->GetDlgItem(nIDC); if(!pWnd->IsKindOf(RUNTIME_CLASS(CFileEditCtrl))) // is this control a CFileEditCtrl control? { TRACE (_T("Control %d not subclassed to CFileEditCtrl, must first call DDX_FileEditCtrl()"),nIDC); ASSERT(FALSE); AfxThrowNotSupportedException(); } if(!pDX->m_bSaveAndValidate) // not saving data return; if ( !pWnd->IsWindowEnabled() ) return; CFileEditCtrl *pFEC = (CFileEditCtrl *)pWnd; pDX->PrepareEditCtrl(nIDC); POSITION pos = pFEC->GetStartPosition(); if (!pos) { // no name entered AfxMessageBox(FEC_IDS_NOFILE); pDX->Fail(); } while(pos) { CString szMessage; CString szFile = pFEC->GetNextPathName(pos); DWORD dwAttribute = GetFileAttributes(szFile); if (dwAttribute == 0xFFFFFFFF) // GetFileAttributes() failed { // does not exist szMessage.Format(FEC_IDS_NOTEXIST, szFile); AfxMessageBox(szMessage); pDX->Fail(); } if (pFEC->GetFindFolder() && !(dwAttribute & FILE_ATTRIBUTE_DIRECTORY)) { // not a folder szMessage.Format(FEC_IDS_NOTFOLDER, szFile); AfxMessageBox(szMessage); pDX->Fail(); } if (!pFEC->GetFindFolder() && dwAttribute & FILE_ATTRIBUTE_DIRECTORY) { // not a file szMessage.Format(FEC_IDS_NOTFILE, szFile); AfxMessageBox(szMessage); pDX->Fail(); } } }
//============================================================================= BOOL CXProgressWnd::GoModal(CWnd *pParent, LPCTSTR lpszTitle /*=_T("Progress")"*/, // start modified code: added to allow dialog with only a message BOOL bEnableCancel /* = TRUE */, BOOL bEnableProgressBar /* = TRUE */, // end modified code LPCTSTR lpszAviId /*= NULL*/, BOOL bSmooth /*=FALSE*/) //============================================================================= { ASSERT(pParent); if (!pParent) return FALSE; m_pParent = pParent; if (!IsWindow(m_hWnd)) { // if (!Create(m_pParent, lpszTitle, lpszAviId, bSmooth)) // start modified code: added to allow dialog with only a message if (!Create(m_pParent, lpszTitle, bEnableCancel, bEnableProgressBar, lpszAviId, bSmooth)) // end modified code return FALSE; } // Walk up the window chain to find the main parent wnd and disable it. CWnd *pWnd = m_pParent; CWnd *prev = pWnd; for (;;) { // if we have no parent (ie. the main window) // or if our parent is disabled, // then this is the window that we will want to remember for reenabling if (!pWnd || !IsWindow(pWnd->m_hWnd) || !pWnd->IsWindowEnabled()) { m_wRenenableWnd = prev; m_wRenenableWnd->EnableWindow(FALSE); break; } prev = pWnd; pWnd = pWnd->GetParent(); } // Re-enable this window EnableWindow(TRUE); m_bModal = TRUE; return TRUE; }
void COXRollup::ArrangeAll() { ASSERT_VALID(this); CWnd* pMainWnd = AfxGetMainWnd(); ASSERT((pMainWnd != NULL) && ::IsWindow(pMainWnd->m_hWnd)); // don´t care about OLE if (!pMainWnd->IsWindowEnabled() && pMainWnd->IsIconic()) return; // set out new top point; because we have to move to first position CWnd* pWndLeftOverPane = pMainWnd->GetDlgItem(AFX_IDW_PANE_FIRST); ASSERT(pWndLeftOverPane != NULL); CRect rcWndNewPos; pWndLeftOverPane->GetWindowRect(&rcWndNewPos); int nLeft = rcWndNewPos.left; int nNewTop = rcWndNewPos.top; POSITION pos = m_ArrangedRollups.GetHeadPosition(); COXRollup* pRoll = NULL; while (pos != NULL) { pRoll = (COXRollup*)m_ArrangedRollups.GetNext(pos); pRoll->GetWindowRect(&rcWndNewPos); pRoll->SetWindowPos(NULL, nLeft, nNewTop, 0, 0, SWP_NOZORDER | SWP_NOSIZE | SWP_NOACTIVATE); nNewTop += rcWndNewPos.Height() - 1; } // now add the ones that haven´t been rolled up before POSITION posNotArranged = m_RollupList.GetHeadPosition(); while (posNotArranged != NULL) { pRoll = (COXRollup*)m_ArrangedRollups.GetNext(posNotArranged); if (m_ArrangedRollups.Find(pRoll, NULL) == NULL) { if ((::IsWindow(pRoll->m_hWnd)) && pRoll->IsWindowVisible()) { pRoll->InternalRollUp(); pRoll->SetArrangeFlagTrue(); pRoll->GetWindowRect(&rcWndNewPos); pRoll->SetWindowPos(NULL, nLeft, nNewTop, 0, 0,SWP_NOZORDER | SWP_NOSIZE | SWP_NOACTIVATE); nNewTop += rcWndNewPos.Height() - 1; m_ArrangedRollups.AddTail(pRoll); // add it to list } } } }
void CPitchPage::OnTimer(UINT nIDEvent) { if (m_bIsNeedPressButton == true) { m_csResult += "Missed Note\r\n"; UpdateData(FALSE); m_bIsNeedPressButton = false; DWORD dwLines = m_editResult.GetLineCount(); m_editResult.LineScroll(dwLines); } if (!UpdateData(TRUE)) { KillTimer(0); return; } DWORD dwRand = rand() * m_nSliderProbability / RAND_MAX; DWORD dwNote = dwRand == 0 ? GetComboPitch() : CNoteUtils::GetRandomNote(m_nComboPitchMin, m_nComboPitchMax); if (m_vNotes.size() > 0) CNoteUtils::MidiNoteOff(m_vNotes.back()); CNoteUtils::MidiNoteOn(dwNote); m_vNotes.push_back(dwNote); if (abs((long)(dwNote - GetComboPitch())) % 12 == 0) m_bIsNeedPressButton = true; CWnd *pWndPress = GetDlgItem(IDC_BUTTON_PITCH_PRESS_IF_MATCHED); if (pWndPress->IsWindowEnabled() == 0) pWndPress->EnableWindow(TRUE); pWndPress->SetFocus(); CString csTempo; GetDlgItemText(IDC_EDIT_PITCH_TEMPO, csTempo); DWORD dwTempo = atoi((LPCTSTR)csTempo); DWORD dwElapse = 1000*60/dwTempo; KillTimer(0); SetTimer(0, dwElapse, NULL); CPropertyPage::OnTimer(nIDEvent); }
bool CResizableStandAloneDialog::OnEnterPressed() { if (GetAsyncKeyState(VK_CONTROL)&0x8000) { CWnd * pOkBtn = GetDlgItem(IDOK); #ifdef ID_OK if (pOkBtn == NULL) pOkBtn = GetDlgItem(ID_OK); #endif if ( pOkBtn && pOkBtn->IsWindowEnabled() ) { if (DWORD(CRegStdDWORD(L"Software\\TortoiseSVN\\CtrlEnter", TRUE))) PostMessage(WM_COMMAND, IDOK); } return true; } return false; }
void CSheetExchMain::OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags) { // TODO: Add your message handler code here and/or call default if( nChar == VK_RETURN ) { CWnd* pWnd = GetDlgItem(ID_WIZNEXT); if( pWnd ) { if( pWnd->IsWindowEnabled() ) OnBnClickedWiznext(); else OnBnClickedWizfinish(); return; } } CHSNewWizDialog::OnKeyDown(nChar, nRepCnt, nFlags); }
bool CPatchUndoTest::DoPageEdit(CWnd *pParent, CString& PageName, CString& CtrlCaption) { CHWNDArray Ctrl; CTabbedDlg *pTabDlg = GetPageControls(pParent, PageName, Ctrl); ASSERT(pTabDlg != NULL); ASSERT(Ctrl.GetSize()); int iCtrl = Random(Ctrl.GetSize()); CWnd *pWnd = CWnd::FromHandle(Ctrl[iCtrl]); if (pWnd == NULL || !pWnd->IsWindowEnabled()) // skip disabled controls return(FALSE); UINT nID = pWnd->GetDlgCtrlID(); CtrlCaption = pTabDlg->GetControlCaption(nID); CNumEdit *pNumEdit = DYNAMIC_DOWNCAST(CNumEdit, pWnd); if (pNumEdit != NULL) { double val = pNumEdit->GetVal(); pNumEdit->AddSpin(1); if (pNumEdit->GetVal() == val) pNumEdit->AddSpin(-1); return(TRUE); } CComboBox *pCombo = DYNAMIC_DOWNCAST(CComboBox, pWnd); if (pCombo != NULL) { int nItems = pCombo->GetCount(); if (nID == IDC_PATCH_GEN_PPQ) // if PPQ combo nItems /= 4; // limit range to avoid zero timer period int iItem = RandomExcluding(nItems, pCombo->GetCurSel()); if (iItem < 0) return(FALSE); pCombo->SetCurSel(iItem); pCombo->GetParent()->SendMessage(WM_COMMAND, MAKELONG(pCombo->GetDlgCtrlID(), CBN_SELCHANGE)); return(TRUE); } CButton *pBtn = DYNAMIC_DOWNCAST(CButton, pWnd); if (pBtn != NULL) { pBtn->SetCheck(!pBtn->GetCheck()); pBtn->GetParent()->SendMessage(WM_COMMAND, MAKELONG(pBtn->GetDlgCtrlID(), BN_CLICKED)); return(TRUE); } return(FALSE); }
void COXRollup::Arrange() { ASSERT_VALID(this); if (IsArranged()) return; CWnd* pMainWnd = AfxGetMainWnd(); ASSERT((pMainWnd != NULL) && ::IsWindow(pMainWnd->m_hWnd)); // don´t care about OLE if (!pMainWnd->IsWindowEnabled() && pMainWnd->IsIconic()) return; InternalRollUp(); COXRollup* pRollup = NULL; if (!m_ArrangedRollups.IsEmpty()) pRollup = (COXRollup*)m_ArrangedRollups.GetTail(); // get last rolled up element // we have got a rollup (or not...) CPoint topLeft(0,0); if (pRollup == NULL) { // we found no college that was rolled up, so we arrange to the left of the screen CRect rcLeftOver; CWnd* pWndLeftOverPane = pMainWnd->GetDlgItem(AFX_IDW_PANE_FIRST); ASSERT(pWndLeftOverPane != NULL); pWndLeftOverPane->GetWindowRect(&rcLeftOver); topLeft = CPoint(rcLeftOver.left, rcLeftOver.top); } else { ASSERT(pRollup != this); // can´t happen, otherwise we would have been arranged ASSERT(pRollup->IsRolledUp()); // must be up if arranged CRect rcLastRollup; pRollup->GetWindowRect(&rcLastRollup); topLeft = CPoint(rcLastRollup.left, rcLastRollup.bottom - 1); } SetWindowPos(NULL, topLeft.x, topLeft.y, 0, 0, SWP_NOSIZE | SWP_NOZORDER); m_ArrangedRollups.AddTail(this); m_bIsArranged = TRUE; }
int CControlBar::HitTestToolTip(CPoint point, UINT* pHit) { if (pHit != NULL) *pHit = (UINT)-1; // assume it won't hit anything // make sure this app is active if (!IsTopParentActive()) return HITTYPE_INACTIVE; // make sure the toolbar itself is active CWnd* pParent = GetTopLevelParent(); if (!pParent->IsWindowEnabled()) return HITTYPE_DISABLED; // check for this application tracking (capture set) CWnd* pCapture = GetCapture(); CWnd* pCaptureParent = pCapture->GetTopLevelParent(); if (pCaptureParent == pParent) return HITTYPE_TRACKING; // check for the bar having focus HWND hWnd = ::GetFocus(); if (hWnd != NULL && (hWnd == m_hWnd || ::IsChild(m_hWnd, hWnd))) return HITTYPE_FOCUS; // see if the mouse point is actually in the control bar window hWnd = ::WindowFromPoint(point); if (hWnd == NULL || (hWnd != m_hWnd && !::IsChild(m_hWnd, hWnd))) return HITTYPE_OUTSIDE; // finally do the hit test on the items within the control bar ScreenToClient(&point); UINT nHit = OnCmdHitTest(point, NULL); if (pHit != NULL) *pHit = nHit; return nHit != (UINT)-1 ? HITTYPE_SUCCESS : HITTYPE_NOTHING; }
BOOL COccManager::IsDialogMessage(CWnd* pWndDlg, LPMSG lpMsg) { // If an OLE Control has the focus, then give it the first crack at key // and mouse messages. CWnd* pWndFocus = CWnd::GetFocus(); HWND hWndFocus = pWndFocus->GetSafeHwnd(); HWND hWndDlg = pWndDlg->GetSafeHwnd(); UINT uMsg = lpMsg->message; if (((uMsg >= WM_KEYFIRST) && (uMsg <= WM_KEYLAST)) || ((uMsg >= WM_MOUSEFIRST) && (uMsg <= WM_MOUSELAST))) { CWnd* pWndCtrl = pWndFocus; // Walk up the parent chain, until we find an OLE control. while ((pWndCtrl != NULL) && (pWndCtrl->m_pCtrlSite == NULL) && (pWndCtrl->GetParent() != pWndDlg)) { pWndCtrl = pWndCtrl->GetParent(); } // let the control attempt to translate the message if (pWndCtrl != NULL && pWndCtrl->m_pCtrlSite != NULL && pWndCtrl->m_pCtrlSite->m_pActiveObject != NULL && pWndCtrl->m_pCtrlSite->m_pActiveObject->TranslateAccelerator(lpMsg) == S_OK) { return TRUE; } // handle CTRLINFO_EATS_RETURN and CTRLINFO_EATS_ESCAPE flags if ((uMsg == WM_KEYUP || uMsg == WM_KEYDOWN || uMsg == WM_CHAR) && pWndCtrl != NULL && pWndCtrl->m_pCtrlSite != NULL && ((LOWORD(lpMsg->wParam) == VK_RETURN && (pWndCtrl->m_pCtrlSite->m_ctlInfo.dwFlags & CTRLINFO_EATS_RETURN)) || (LOWORD(lpMsg->wParam) == VK_ESCAPE && (pWndCtrl->m_pCtrlSite->m_ctlInfo.dwFlags & CTRLINFO_EATS_ESCAPE)))) { return FALSE; } } BOOL bResult = FALSE; CWnd* pWndMsg = CWnd::FromHandle(lpMsg->hwnd); CWnd* pWndNext = NULL; DWORD code; BOOL bBack = FALSE; int iOK = IDCANCEL; switch (uMsg) { case WM_SYSCHAR: // If no control has focus, and Alt not down, then ignore. if ((pWndFocus == NULL) && (GetKeyState(VK_MENU) >= 0)) break; // If alt+menuchar, process as menu. if (LOWORD(lpMsg->wParam) == CH_SYSMENU) break; // FALL THRU case WM_CHAR: // Ignore chars sent to the dialog box (rather than the control). if (pWndMsg == pWndDlg) return TRUE; code = _AfxGetDlgCode(pWndMsg, lpMsg); // If the control wants to process the message, then don't check // for possible mnemonic key. if (uMsg == WM_CHAR && (code & (DLGC_WANTCHARS|DLGC_WANTMESSAGE))) break; // If the control wants tabs, then don't let tab fall thru here if (LOWORD(lpMsg->wParam) == VK_TAB && (code & DLGC_WANTTAB)) break; // Don't handle space as a mnemonic if (LOWORD(lpMsg->wParam) == VK_SPACE) return TRUE; if ((pWndNext = _AfxGetNextMnem(pWndDlg, pWndMsg, lpMsg)) != NULL) { if (pWndNext->m_pCtrlSite != NULL) { // UI Activate new control, and send the mnemonic to it. pWndNext->m_pCtrlSite->SendMnemonic(lpMsg); bResult = TRUE; } } break; case WM_KEYDOWN: code = _AfxGetDlgCode(pWndMsg, lpMsg); switch (LOWORD(lpMsg->wParam)) { case VK_TAB: if (code & DLGC_WANTTAB) // If control wants tabs, bail out. break; pWndNext = pWndDlg->GetNextDlgTabItem(pWndMsg, (GetKeyState(VK_SHIFT) < 0)); if (pWndNext != NULL) { _AfxDlgSetFocus(pWndNext); UIDeactivateIfNecessary(pWndFocus, pWndNext); } bResult = TRUE; break; case VK_LEFT: case VK_UP: bBack = TRUE; // FALL THRU case VK_RIGHT: case VK_DOWN: if (_AfxGetDlgCode(pWndFocus, lpMsg) & DLGC_WANTARROWS) break; pWndNext = pWndDlg->GetNextDlgGroupItem(pWndFocus, bBack); if ((pWndNext != NULL) && (pWndNext->m_pCtrlSite != NULL)) { _AfxDlgSetFocus(pWndNext); bResult = TRUE; } break; case VK_EXECUTE: case VK_RETURN: // Return was pressed. Find default button and click it. if (GetDefBtnCode(pWndFocus) & DLGC_DEFPUSHBUTTON) { pWndNext = pWndFocus; iOK = (DWORD)pWndNext->GetDlgCtrlID(); } else { iOK = _AfxOriginalDefButton(pWndDlg); } // FALL THRU case VK_ESCAPE: case VK_CANCEL: if (pWndNext == NULL) { pWndNext = _AfxFindDlgItem(pWndDlg, iOK); if (pWndNext == NULL) break; } ASSERT(pWndNext != NULL); // Make sure button is not disabled. if (!pWndNext->IsWindowEnabled()) { MessageBeep(0); } else if (pWndNext->m_pCtrlSite != NULL) { // "push" the pWndNext control. TRY { pWndNext->InvokeHelper(DISPID_DOCLICK, DISPATCH_METHOD, VT_EMPTY, NULL, VTS_NONE); } END_TRY bResult = TRUE; } break; } break; }
AFX_STATIC void AFXAPI _AfxCheckDefPushButton(CWnd* pWndRoot, CWnd* pWndOldFocus, CWnd* pWndNewFocus) { DWORD code = 0; CWnd* pWndT; // If the focus has gone to a totally separate window, bail out. if (!pWndRoot->IsChild(pWndNewFocus)) return; if (pWndNewFocus != NULL) { // Do nothing if clicking on dialog background or recursive dialog // background. if (IsControlParent(pWndNewFocus)) return; code = COccManager::GetDefBtnCode(pWndNewFocus); } if (pWndOldFocus == pWndNewFocus) { // Check the default ID and see if is the same as pwndOldFocus' ID. // If not, find it and use it as pwndOldFocus if (code & DLGC_UNDEFPUSHBUTTON) { if (pWndOldFocus != NULL) { pWndOldFocus = _AfxFindDlgItem(pWndRoot, _AfxOriginalDefButton(pWndRoot)); if ((pWndOldFocus != NULL) && (pWndOldFocus != pWndNewFocus)) { if (COccManager::GetDefBtnCode(pWndOldFocus) & DLGC_DEFPUSHBUTTON) { _AfxRemoveDefaultButton(pWndRoot, pWndOldFocus); goto SetNewDefault; } } } COccManager::SetDefaultButton(pWndNewFocus, TRUE); } return; } // If the focus is changing to or from a pushbutton, then remove the // default style from the current default button if (((pWndOldFocus != NULL) && (COccManager::GetDefBtnCode(pWndOldFocus) != 0)) || ((pWndNewFocus != NULL) && (code != 0))) { _AfxRemoveDefaultButton(pWndRoot, pWndNewFocus); } SetNewDefault: // If moving to a button, make that button the default. if (code & (DLGC_UNDEFPUSHBUTTON | DLGC_DEFPUSHBUTTON)) { COccManager::SetDefaultButton(pWndNewFocus, TRUE); } else { // Otherwise, make sure the original default button is default // Get the original default button pWndT = _AfxFindDlgItem(pWndRoot, _AfxOriginalDefButton(pWndRoot)); if ((COccManager::GetDefBtnCode(pWndT) & DLGC_UNDEFPUSHBUTTON) && pWndT->IsWindowEnabled()) { COccManager::SetDefaultButton(pWndT, TRUE); } } }
int SectorFileEditDialog::LoadData(void) { ASSERT(fpDiskFS != NULL); ASSERT(fpDiskFS->GetDiskImg() != NULL); DIError dierr; LOGI("SFED LoadData reading index=%d", fSectorIdx); #if 0 LOGI("LoadData reading offset=%d", fOffset); size_t actual = 0; dierr = fpFile->Seek(fOffset, EmbeddedFD::kSeekSet); if (dierr == kDIErrNone) { dierr = fpFile->Read(fSectorData, 1 /*kSectorSize*/, &actual); } if (dierr != kDIErrNone) { CString msg, failed; failed.LoadString(IDS_FAILED); msg.Format(IDS_DISKEDIT_FIRDFAILED, DiskImg::DIStrError(dierr)); MessageBox(msg, failed, MB_OK); // TO DO: mark contents as invalid, so editing fails return -1; } if (actual != kSectorSize) { LOGI(" SFED partial read of %d bytes", actual); ASSERT(actual < kSectorSize && actual >= 0); } /* * We've read the data, but we can't use it. We're a sector editor, * not a file editor, and we need to get the actual sector data without * EOF trimming or CP/M 0xe5 removal. */ fpFile->GetLastLocationRead(&fTrack, &fSector); if (fTrack == A2File::kLastWasSparse && fSector == A2File::kLastWasSparse) ; #endif fAlertMsg = ""; dierr = fpOpenFile->GetStorage(fSectorIdx, &fTrack, &fSector); if (dierr == kDIErrInvalidIndex && fSectorIdx == 0) { // no first sector; should only happen on CP/M //FillWithPattern(fSectorData, sizeof(fSectorData), _T("EMPTY ")); fAlertMsg.LoadString(IDS_DISKEDITMSG_EMPTY); } else if (dierr != kDIErrNone) { CString msg, failed; failed.LoadString(IDS_FAILED); msg.Format(IDS_DISKEDIT_FIRDFAILED, DiskImgLib::DIStrError(dierr)); MessageBox(msg, failed, MB_OK); fAlertMsg.LoadString(IDS_FAILED); // TO DO: mark contents as invalid, so editing fails return -1; } else { if (fTrack == 0 && fSector == 0) { LOGI("LoadData Sparse sector"); //FillWithPattern(fSectorData, sizeof(fSectorData), _T("SPARSE ")); fAlertMsg.Format(IDS_DISKEDITMSG_SPARSE, fSectorIdx); } else { LOGI("LoadData reading T=%d S=%d", fTrack, fSector); dierr = fpDiskFS->GetDiskImg()->ReadTrackSector(fTrack, fSector, fSectorData); if (dierr != kDIErrNone) { //CString msg; //CString err; //err.LoadString(IDS_ERROR); //msg.Format(IDS_DISKEDIT_NOREADTS, fTrack, fSector); //MessageBox(msg, err, MB_OK|MB_ICONSTOP); fAlertMsg.LoadString(IDS_DISKEDITMSG_BADSECTOR); //return -1; } } } SetSpinner(IDC_DISKEDIT_TRACKSPIN, fTrack); SetSpinner(IDC_DISKEDIT_SECTORSPIN, fSector); CWnd* pWnd; pWnd = GetDlgItem(IDC_DISKEDIT_PREV); ASSERT(pWnd != NULL); pWnd->EnableWindow(fSectorIdx > 0); if (!pWnd->IsWindowEnabled() && GetFocus() == NULL) GetDlgItem(IDC_DISKEDIT_NEXT)->SetFocus(); pWnd = GetDlgItem(IDC_DISKEDIT_NEXT); ASSERT(pWnd != NULL); pWnd->EnableWindow(fSectorIdx+1 < fpOpenFile->GetSectorCount()); if (!pWnd->IsWindowEnabled() && GetFocus() == NULL) GetDlgItem(IDC_DISKEDIT_PREV)->SetFocus(); DisplayData(); return 0; }