Skip to content

Commit

Permalink
[#50] MDOS: Disk verification (Part 11: Fixed control item text retri…
Browse files Browse the repository at this point in the history
…eval from Part 10)
  • Loading branch information
tomas-nestorovic committed Aug 1, 2020
1 parent b52ab50 commit 7655c75
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 5 deletions.
10 changes: 5 additions & 5 deletions Main/src/MDOS2_Boot.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -339,12 +339,12 @@
break;
}
}
if (boot->current.diskFlags.driveD40 && !boot->current.diskFlags.fortyCylDiskInD80){
CDialog d( IDR_MDOS_DRIVE_EDITOR );
d.ShowWindow(SW_HIDE);
if (boot->current.diskFlags.driveD40 && !(boot->current.diskFlags.fortyCylDiskInD80&&boot->current.driveFlags.fortyCylDiskInD80)){
TCHAR txt[80];
d.GetDlgItemText( ID_40D80, txt, sizeof(txt)/sizeof(TCHAR) );
vp.fReport.LogWarning( _T("D40's often contained 80-track drives, please revise the \"%s\" setting"), txt );
vp.fReport.LogWarning(
_T("D40's often contained 80-track drives, please revise the \"%s\" setting"),
Utils::GetDialogTemplateItemText( IDR_MDOS_DRIVE_EDITOR, ID_40D80, txt, sizeof(txt)/sizeof(TCHAR) )
);
}
// - verifying Current drive information (continued)
if (const TStdWinError err=vp.WarnIfUnsignedValueOutOfRange( CHS, BOOT_SECTOR_LOCATION_STRING, _T("Last seeked cylinder"), boot->current.driveLastSeekedCylinder, (BYTE)0, (BYTE)(boot->current.nCylinders-1) ))
Expand Down
21 changes: 21 additions & 0 deletions Main/src/Utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -683,6 +683,27 @@ namespace Utils{
::SetWindowPos( hCtrl, 0, pt.x+dx, pt.y+dy, 0, 0, SWP_NOZORDER|SWP_NOSIZE );
}

PTCHAR GetDialogTemplateItemText(UINT idDlgRes,WORD idItem,PTCHAR chars,WORD nCharsMax){
// determines and returns the length of the text associated with given dialog item
PTCHAR result=nullptr; // assumption (text can't be determined, e.g. because no such item exists)
if (const HRSRC hRes=::FindResource( app.m_hInstance, MAKEINTRESOURCE(idDlgRes), RT_DIALOG ))
if (const HGLOBAL gRes=::LoadResource( app.m_hInstance, hRes )){
if (const LPCDLGTEMPLATE lpRes=(LPCDLGTEMPLATE)::LockResource( gRes )){
class CTmpDlg sealed:public CDialog{
public:
CTmpDlg(LPCDLGTEMPLATE lpRes){
CreateDlgIndirect( lpRes, nullptr );
}
} d(lpRes);
d.GetDlgItemText( idItem, chars, nCharsMax );
result=chars;
::UnlockResource(gRes);
}
::FreeResource( gRes );
}
return result;
}

void BytesToHigherUnits(DWORD bytes,float &rHigherUnit,LPCTSTR &rHigherUnitName){
// converts Bytes to suitable HigherUnits (e.g. "12345 Bytes" to "12.345 kiB")
if (bytes>=0x40000000)
Expand Down
1 change: 1 addition & 0 deletions Main/src/Utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ namespace Utils{
bool EnableDlgControls(HWND hDlg,PCWORD buttonIds,bool enabled);
bool IsDlgControlEnabled(HWND hDlg,WORD controlId);
void OffsetDlgControl(HWND hDlg,WORD controlId,int dx,int dy);
PTCHAR GetDialogTemplateItemText(UINT idDlgRes,WORD idItem,PTCHAR chars,WORD nCharsMax);
void BytesToHigherUnits(DWORD bytes,float &rHigherUnit,LPCTSTR &rHigherUnitName);
CString BytesToHexaText(PCBYTE bytes,BYTE nBytes,bool lastDelimitedWithAnd);
CString BytesToHexaText(const char *chars,BYTE nChars,bool lastDelimitedWithAnd);
Expand Down

0 comments on commit 7655c75

Please sign in to comment.