Replace StringCbPrintf() with StrFormat() (PR #1032)

This commit is contained in:
Kelvin Lee 2022-02-16 05:48:20 +11:00 committed by GitHub
parent 48dd638d33
commit 1a4e933778
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
16 changed files with 103 additions and 147 deletions

View File

@ -65,13 +65,12 @@ static INT_PTR CALLBACK DlgProcAbout(HWND hWnd, UINT message, WPARAM wparam, LPA
case WM_INITDIALOG: case WM_INITDIALOG:
{ {
HICON hIcon = LoadIcon(GetFrame().g_hInstance, TEXT("APPLEWIN_ICON")); HICON hIcon = LoadIcon(GetFrame().g_hInstance, TEXT("APPLEWIN_ICON"));
SendDlgItemMessage(hWnd, IDC_APPLEWIN_ICON, STM_SETIMAGE, IMAGE_ICON, (LPARAM)hIcon); SendDlgItemMessage(hWnd, IDC_APPLEWIN_ICON, STM_SETIMAGE, IMAGE_ICON, reinterpret_cast<LPARAM>(hIcon));
TCHAR szAppleWinVersion[50]; std::string strAppleWinVersion = "AppleWin v" + g_VERSIONSTRING;
StringCbPrintf(szAppleWinVersion, 50, "AppleWin v%s", VERSIONSTRING); SendDlgItemMessage(hWnd, IDC_APPLEWIN_VERSION, WM_SETTEXT, 0, reinterpret_cast<LPARAM>(strAppleWinVersion.c_str()));
SendDlgItemMessage(hWnd, IDC_APPLEWIN_VERSION, WM_SETTEXT, 0, (LPARAM)szAppleWinVersion);
SendDlgItemMessage(hWnd, IDC_GPL_TEXT, WM_SETTEXT, 0, (LPARAM)g_szGPL); SendDlgItemMessage(hWnd, IDC_GPL_TEXT, WM_SETTEXT, 0, reinterpret_cast<LPARAM>(g_szGPL));
} }
break; break;
} }

View File

@ -476,7 +476,6 @@ void CPageDisk::HandleHDDSwap(HWND hWnd)
UINT CPageDisk::RemovalConfirmation(UINT uCommand) UINT CPageDisk::RemovalConfirmation(UINT uCommand)
{ {
TCHAR szText[100];
bool bMsgBox = true; bool bMsgBox = true;
bool isDisk = false; bool isDisk = false;
@ -492,18 +491,19 @@ UINT CPageDisk::RemovalConfirmation(UINT uCommand)
drive = uCommand - IDC_COMBO_DISK1_SLOT5; drive = uCommand - IDC_COMBO_DISK1_SLOT5;
} }
std::string strText;
if (isDisk) if (isDisk)
StringCbPrintf(szText, sizeof(szText), "Do you really want to eject the disk in drive-%c ?", '1' + drive); strText = StrFormat("Do you really want to eject the disk in drive-%c ?", '1' + drive);
else if (uCommand == IDC_COMBO_HDD1 || uCommand == IDC_COMBO_HDD2) else if (uCommand == IDC_COMBO_HDD1 || uCommand == IDC_COMBO_HDD2)
StringCbPrintf(szText, sizeof(szText), "Do you really want to unplug harddisk-%c ?", '1' + uCommand - IDC_COMBO_HDD1); strText = StrFormat("Do you really want to unplug harddisk-%c ?", '1' + uCommand - IDC_COMBO_HDD1);
else if (uCommand == IDC_HDD_SWAP) else if (uCommand == IDC_HDD_SWAP)
StringCbPrintf(szText, sizeof(szText), "Do you really want to swap the harddisk images?"); strText = "Do you really want to swap the harddisk images?";
else else
bMsgBox = false; bMsgBox = false;
if (bMsgBox) if (bMsgBox)
{ {
int nRes = GetFrame().FrameMessageBox(szText, "Eject/Unplug Warning", MB_ICONWARNING | MB_YESNO | MB_SETFOREGROUND); int nRes = GetFrame().FrameMessageBox(strText.c_str(), "Eject/Unplug Warning", MB_ICONWARNING | MB_YESNO | MB_SETFOREGROUND);
if (nRes == IDNO) if (nRes == IDNO)
uCommand = 0; uCommand = 0;
} }

View File

@ -44,10 +44,10 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#include "Speech.h" #include "Speech.h"
#endif #endif
static const UINT VERSIONSTRING_SIZE = 16; static UINT16 g_OldAppleWinVersion[4] = { 0 };
static UINT16 g_OldAppleWinVersion[4] = {0};
UINT16 g_AppleWinVersion[4] = { 0 }; UINT16 g_AppleWinVersion[4] = { 0 };
TCHAR VERSIONSTRING[VERSIONSTRING_SIZE] = "xx.yy.zz.ww"; std::string g_VERSIONSTRING = "xx.yy.zz.ww";
std::string g_pAppTitle; std::string g_pAppTitle;
@ -257,14 +257,15 @@ void SetAppleWinVersion(UINT16 major, UINT16 minor, UINT16 fix, UINT16 fix_minor
g_AppleWinVersion[1] = minor; g_AppleWinVersion[1] = minor;
g_AppleWinVersion[2] = fix; g_AppleWinVersion[2] = fix;
g_AppleWinVersion[3] = fix_minor; g_AppleWinVersion[3] = fix_minor;
StringCbPrintf(VERSIONSTRING, VERSIONSTRING_SIZE, "%d.%d.%d.%d", major, minor, fix, fix_minor); g_VERSIONSTRING = StrFormat("%d.%d.%d.%d", major, minor, fix, fix_minor);
} }
bool CheckOldAppleWinVersion(void) bool CheckOldAppleWinVersion(void)
{ {
TCHAR szOldAppleWinVersion[VERSIONSTRING_SIZE + 1]; const int VERSIONSTRING_SIZE = 16;
RegLoadString(TEXT(REG_CONFIG), TEXT(REGVALUE_VERSION), 1, szOldAppleWinVersion, VERSIONSTRING_SIZE, TEXT("")); char szOldAppleWinVersion[VERSIONSTRING_SIZE + 1];
const bool bShowAboutDlg = strcmp(szOldAppleWinVersion, VERSIONSTRING) != 0; RegLoadString(REG_CONFIG, REGVALUE_VERSION, TRUE, szOldAppleWinVersion, VERSIONSTRING_SIZE, "");
const bool bShowAboutDlg = (g_VERSIONSTRING != szOldAppleWinVersion);
// version: xx.yy.zz.ww // version: xx.yy.zz.ww
char* p0 = szOldAppleWinVersion; char* p0 = szOldAppleWinVersion;

View File

@ -9,7 +9,7 @@ void LogFileTimeUntilFirstKeyReadReset(void);
void LogFileTimeUntilFirstKeyRead(void); void LogFileTimeUntilFirstKeyRead(void);
extern const UINT16* GetOldAppleWinVersion(void); extern const UINT16* GetOldAppleWinVersion(void);
extern TCHAR VERSIONSTRING[]; // Constructed in WinMain() extern std::string g_VERSIONSTRING; // Constructed in WinMain()
void SetAppleWinVersion(UINT16 major, UINT16 minor, UINT16 fix, UINT16 fix_minor); void SetAppleWinVersion(UINT16 major, UINT16 minor, UINT16 fix, UINT16 fix_minor);
bool CheckOldAppleWinVersion(void); bool CheckOldAppleWinVersion(void);

View File

@ -1611,7 +1611,7 @@ Update_t CmdVersion (int nArgs)
ConsolePrintFormat( sText, " Emulator: %s%s%s Debugger: %s%d.%d.%d.%d%s" ConsolePrintFormat( sText, " Emulator: %s%s%s Debugger: %s%d.%d.%d.%d%s"
, CHC_SYMBOL , CHC_SYMBOL
, VERSIONSTRING , g_VERSIONSTRING.c_str()
, CHC_DEFAULT , CHC_DEFAULT
, CHC_SYMBOL , CHC_SYMBOL
, nMajor, nMinor, nFixMajor, nFixMinor , nMajor, nMinor, nFixMajor, nFixMinor

View File

@ -728,9 +728,10 @@ ImageError_e Disk2InterfaceCard::InsertDisk(const int drive, const std::string&
if (Error == eIMAGE_ERROR_NONE && ImageIsMultiFileZip(pFloppy->m_imagehandle)) if (Error == eIMAGE_ERROR_NONE && ImageIsMultiFileZip(pFloppy->m_imagehandle))
{ {
TCHAR szText[100+MAX_PATH]; std::string strText = StrFormat("Only the first file in a multi-file zip is supported\n"
StringCbPrintf(szText, sizeof(szText), "Only the first file in a multi-file zip is supported\nUse disk image '%s' ?", pFloppy->m_strFilenameInZip.c_str()); "Use disk image '%s' ?",
int nRes = GetFrame().FrameMessageBox(szText, TEXT("Multi-Zip Warning"), MB_ICONWARNING | MB_YESNO | MB_SETFOREGROUND); pFloppy->m_strFilenameInZip.c_str());
int nRes = GetFrame().FrameMessageBox(strText.c_str(), "Multi-Zip Warning", MB_ICONWARNING | MB_YESNO | MB_SETFOREGROUND);
if (nRes == IDNO) if (nRes == IDNO)
{ {
EjectDisk(drive); EjectDisk(drive);
@ -769,89 +770,62 @@ bool Disk2InterfaceCard::IsConditionForFullSpeed(void)
void Disk2InterfaceCard::NotifyInvalidImage(const int drive, LPCTSTR pszImageFilename, const ImageError_e Error) void Disk2InterfaceCard::NotifyInvalidImage(const int drive, LPCTSTR pszImageFilename, const ImageError_e Error)
{ {
TCHAR szBuffer[MAX_PATH + 128]; std::string strText;
switch (Error) switch (Error)
{ {
case eIMAGE_ERROR_UNABLE_TO_OPEN: case eIMAGE_ERROR_UNABLE_TO_OPEN:
case eIMAGE_ERROR_UNABLE_TO_OPEN_GZ: case eIMAGE_ERROR_UNABLE_TO_OPEN_GZ:
case eIMAGE_ERROR_UNABLE_TO_OPEN_ZIP: case eIMAGE_ERROR_UNABLE_TO_OPEN_ZIP:
StringCbPrintf( strText = StrFormat("Unable to open the file %s.",
szBuffer, pszImageFilename);
MAX_PATH + 128,
TEXT("Unable to open the file %s."),
pszImageFilename);
break; break;
case eIMAGE_ERROR_BAD_SIZE: case eIMAGE_ERROR_BAD_SIZE:
StringCbPrintf( strText = StrFormat("Unable to use the file %s\n"
szBuffer, "because the disk image is an unsupported size.",
MAX_PATH + 128, pszImageFilename);
TEXT("Unable to use the file %s\nbecause the ")
TEXT("disk image is an unsupported size."),
pszImageFilename);
break; break;
case eIMAGE_ERROR_BAD_FILE: case eIMAGE_ERROR_BAD_FILE:
StringCbPrintf( strText = StrFormat("Unable to use the file %s\n"
szBuffer, "because the OS can't access it.",
MAX_PATH + 128, pszImageFilename);
TEXT("Unable to use the file %s\nbecause the ")
TEXT("OS can't access it."),
pszImageFilename);
break; break;
case eIMAGE_ERROR_UNSUPPORTED: case eIMAGE_ERROR_UNSUPPORTED:
StringCbPrintf( strText = StrFormat("Unable to use the file %s\n"
szBuffer, "because the disk image format is not recognized.",
MAX_PATH + 128, pszImageFilename);
TEXT("Unable to use the file %s\nbecause the ")
TEXT("disk image format is not recognized."),
pszImageFilename);
break; break;
case eIMAGE_ERROR_UNSUPPORTED_HDV: case eIMAGE_ERROR_UNSUPPORTED_HDV:
StringCbPrintf( strText = StrFormat("Unable to use the file %s\n"
szBuffer, "because this UniDisk 3.5/Apple IIGS/hard-disk image is not supported.\n"
MAX_PATH + 128, "Try inserting as a hard-disk image instead.",
TEXT("Unable to use the file %s\n") pszImageFilename);
TEXT("because this UniDisk 3.5/Apple IIGS/hard-disk image is not supported.\n")
TEXT("Try inserting as a hard-disk image instead."),
pszImageFilename);
break; break;
case eIMAGE_ERROR_GZ: case eIMAGE_ERROR_GZ:
case eIMAGE_ERROR_ZIP: case eIMAGE_ERROR_ZIP:
StringCbPrintf( strText = StrFormat("Unable to use the compressed file %s\n"
szBuffer, "because the compressed disk image is corrupt/unsupported.",
MAX_PATH + 128, pszImageFilename);
TEXT("Unable to use the compressed file %s\nbecause the ")
TEXT("compressed disk image is corrupt/unsupported."),
pszImageFilename);
break; break;
case eIMAGE_ERROR_FAILED_TO_GET_PATHNAME: case eIMAGE_ERROR_FAILED_TO_GET_PATHNAME:
StringCbPrintf( strText = StrFormat("Unable to GetFullPathName() for the file: %s.",
szBuffer, pszImageFilename);
MAX_PATH + 128,
TEXT("Unable to GetFullPathName() for the file: %s."),
pszImageFilename);
break; break;
case eIMAGE_ERROR_ZEROLENGTH_WRITEPROTECTED: case eIMAGE_ERROR_ZEROLENGTH_WRITEPROTECTED:
StringCbPrintf( strText = StrFormat("Unsupported zero-length write-protected file: %s.",
szBuffer, pszImageFilename);
MAX_PATH + 128,
TEXT("Unsupported zero-length write-protected file: %s."),
pszImageFilename);
break; break;
case eIMAGE_ERROR_FAILED_TO_INIT_ZEROLENGTH: case eIMAGE_ERROR_FAILED_TO_INIT_ZEROLENGTH:
StringCbPrintf( strText = StrFormat("Failed to resize the zero-length file: %s.",
szBuffer, pszImageFilename);
MAX_PATH + 128,
TEXT("Failed to resize the zero-length file: %s."),
pszImageFilename);
break; break;
default: default:
@ -859,10 +833,9 @@ void Disk2InterfaceCard::NotifyInvalidImage(const int drive, LPCTSTR pszImageFil
return; return;
} }
GetFrame().FrameMessageBox( GetFrame().FrameMessageBox(strText.c_str(),
szBuffer, g_pAppTitle.c_str(),
g_pAppTitle.c_str(), MB_ICONEXCLAMATION | MB_SETFOREGROUND);
MB_ICONEXCLAMATION | MB_SETFOREGROUND);
} }
//=========================================================================== //===========================================================================
@ -1578,12 +1551,11 @@ bool Disk2InterfaceCard::UserSelectNewDiskImage(const int drive, LPCSTR pszFilen
TCHAR directory[MAX_PATH]; TCHAR directory[MAX_PATH];
TCHAR filename[MAX_PATH]; TCHAR filename[MAX_PATH];
TCHAR title[40];
StringCbCopy(filename, MAX_PATH, pszFilename); StringCbCopy(filename, MAX_PATH, pszFilename);
RegLoadString(TEXT(REG_PREFS), TEXT(REGVALUE_PREF_START_DIR), 1, directory, MAX_PATH, TEXT("")); RegLoadString(TEXT(REG_PREFS), TEXT(REGVALUE_PREF_START_DIR), 1, directory, MAX_PATH, TEXT(""));
StringCbPrintf(title, 40, TEXT("Select Disk Image For Drive %d"), drive + 1); std::string title = StrFormat("Select Disk Image For Drive %d", drive + 1);
OPENFILENAME ofn; OPENFILENAME ofn;
memset(&ofn, 0, sizeof(OPENFILENAME)); memset(&ofn, 0, sizeof(OPENFILENAME));
@ -1597,7 +1569,7 @@ bool Disk2InterfaceCard::UserSelectNewDiskImage(const int drive, LPCSTR pszFilen
ofn.nMaxFile = MAX_PATH; ofn.nMaxFile = MAX_PATH;
ofn.lpstrInitialDir = directory; ofn.lpstrInitialDir = directory;
ofn.Flags = OFN_PATHMUSTEXIST; ofn.Flags = OFN_PATHMUSTEXIST;
ofn.lpstrTitle = title; ofn.lpstrTitle = title.c_str();
bool bRes = false; bool bRes = false;

View File

@ -2227,8 +2227,7 @@ BYTE* CWOZHelper::CreateEmptyDisk(DWORD& size)
pWOZ->info.v1.version = 2; pWOZ->info.v1.version = 2;
pWOZ->info.v1.diskType = InfoChunk::diskType5_25; pWOZ->info.v1.diskType = InfoChunk::diskType5_25;
pWOZ->info.v1.cleaned = 1; pWOZ->info.v1.cleaned = 1;
std::string creator("AppleWin v"); std::string creator = "AppleWin v" + g_VERSIONSTRING;
creator += std::string(VERSIONSTRING);
memset(&pWOZ->info.v1.creator[0], ' ', sizeof(pWOZ->info.v1.creator)); memset(&pWOZ->info.v1.creator[0], ' ', sizeof(pWOZ->info.v1.creator));
memcpy(&pWOZ->info.v1.creator[0], creator.c_str(), creator.size()); // don't include null memcpy(&pWOZ->info.v1.creator[0], creator.c_str(), creator.size()); // don't include null
pWOZ->info.diskSides = 1; pWOZ->info.diskSides = 1;
@ -2280,8 +2279,7 @@ BYTE* CWOZHelper::CreateEmptyDiskv1(DWORD& size)
pWOZ->info.version = 1; pWOZ->info.version = 1;
pWOZ->info.diskType = InfoChunk::diskType5_25; pWOZ->info.diskType = InfoChunk::diskType5_25;
pWOZ->info.cleaned = 1; pWOZ->info.cleaned = 1;
std::string creator("AppleWin v"); std::string creator = "AppleWin v" + g_VERSIONSTRING;
creator += std::string(VERSIONSTRING);
memset(&pWOZ->info.creator[0], ' ', sizeof(pWOZ->info.creator)); memset(&pWOZ->info.creator[0], ' ', sizeof(pWOZ->info.creator));
memcpy(&pWOZ->info.creator[0], creator.c_str(), creator.size()); // don't include null memcpy(&pWOZ->info.creator[0], creator.c_str(), creator.size()); // don't include null

View File

@ -73,7 +73,7 @@ void FrameBase::Video_RedrawAndTakeScreenShot(const char* pScreenshotFilename)
void FrameBase::Video_TakeScreenShot(const Video::VideoScreenShot_e ScreenShotType) void FrameBase::Video_TakeScreenShot(const Video::VideoScreenShot_e ScreenShotType)
{ {
TCHAR sScreenShotFileName[MAX_PATH]; std::string strScreenShotFileName;
// find last screenshot filename so we don't overwrite the existing user ones // find last screenshot filename so we don't overwrite the existing user ones
bool bExists = true; bool bExists = true;
@ -81,15 +81,16 @@ void FrameBase::Video_TakeScreenShot(const Video::VideoScreenShot_e ScreenShotTy
{ {
if (g_nLastScreenShot > nMaxScreenShot) // Holy Crap! User has maxed the number of screenshots!? if (g_nLastScreenShot > nMaxScreenShot) // Holy Crap! User has maxed the number of screenshots!?
{ {
TCHAR msg[512]; std::string msg = StrFormat("You have more then %d screenshot filenames! They will no longer be saved.\n\n"
StringCbPrintf(msg, 512, "You have more then %d screenshot filenames! They will no longer be saved.\n\nEither move some of your screenshots or increase the maximum in video.cpp\n", nMaxScreenShot); "Either move some of your screenshots or increase the maximum in video.cpp\n",
FrameMessageBox(msg, "Warning", MB_OK); nMaxScreenShot);
FrameMessageBox(msg.c_str(), "Warning", MB_OK);
g_nLastScreenShot = 0; g_nLastScreenShot = 0;
return; return;
} }
Util_MakeScreenShotFileName(sScreenShotFileName, MAX_PATH); strScreenShotFileName = Util_MakeScreenShotFileName();
bExists = Util_TestScreenShotFileName(sScreenShotFileName); bExists = Util_TestScreenShotFileName(strScreenShotFileName.c_str());
if (!bExists) if (!bExists)
{ {
break; break;
@ -97,7 +98,7 @@ void FrameBase::Video_TakeScreenShot(const Video::VideoScreenShot_e ScreenShotTy
g_nLastScreenShot++; g_nLastScreenShot++;
} }
Video_SaveScreenShot(ScreenShotType, sScreenShotFileName); Video_SaveScreenShot(ScreenShotType, strScreenShotFileName.c_str());
g_nLastScreenShot++; g_nLastScreenShot++;
} }
@ -118,12 +119,12 @@ void FrameBase::Video_SaveScreenShot(const Video::VideoScreenShot_e ScreenShotTy
} }
} }
void FrameBase::Util_MakeScreenShotFileName(TCHAR* pFinalFileName_, DWORD chars) std::string FrameBase::Util_MakeScreenShotFileName() const
{ {
const std::string sPrefixScreenShotFileName = "AppleWin_ScreenShot"; const std::string sPrefixScreenShotFileName = "AppleWin_ScreenShot";
const std::string pPrefixFileName = !g_pLastDiskImageName.empty() ? g_pLastDiskImageName : sPrefixScreenShotFileName; const std::string pPrefixFileName = !g_pLastDiskImageName.empty() ? g_pLastDiskImageName : sPrefixScreenShotFileName;
const std::string folder = Video_GetScreenShotFolder(); const std::string folder = Video_GetScreenShotFolder();
StringCbPrintf(pFinalFileName_, chars, TEXT("%s%s_%09d.bmp"), folder.c_str(), pPrefixFileName.c_str(), g_nLastScreenShot); return StrFormat("%s%s_%09d.bmp", folder.c_str(), pPrefixFileName.c_str(), g_nLastScreenShot);
} }
// Returns TRUE if file exists, else FALSE // Returns TRUE if file exists, else FALSE

View File

@ -56,7 +56,7 @@ public:
void VideoRedrawScreenAfterFullSpeed(DWORD dwCyclesThisFrame); void VideoRedrawScreenAfterFullSpeed(DWORD dwCyclesThisFrame);
void Video_RedrawAndTakeScreenShot(const char* pScreenshotFilename); void Video_RedrawAndTakeScreenShot(const char* pScreenshotFilename);
virtual std::string Video_GetScreenShotFolder() = 0; virtual std::string Video_GetScreenShotFolder() const = 0;
void Video_TakeScreenShot(const Video::VideoScreenShot_e ScreenShotType); void Video_TakeScreenShot(const Video::VideoScreenShot_e ScreenShotType);
void Video_SaveScreenShot(const Video::VideoScreenShot_e ScreenShotType, const TCHAR* pScreenShotFileName); void Video_SaveScreenShot(const Video::VideoScreenShot_e ScreenShotType, const TCHAR* pScreenShotFileName);
void SetDisplayPrintScreenFileName(bool state) { g_bDisplayPrintScreenFileName = state; } void SetDisplayPrintScreenFileName(bool state) { g_bDisplayPrintScreenFileName = state; }
@ -66,7 +66,7 @@ public:
void SetShowPrintScreenWarningDialog(bool state) { g_bShowPrintScreenWarningDialog = state; } void SetShowPrintScreenWarningDialog(bool state) { g_bShowPrintScreenWarningDialog = state; }
private: private:
void Util_MakeScreenShotFileName(TCHAR* pFinalFileName_, DWORD chars); std::string Util_MakeScreenShotFileName() const;
bool Util_TestScreenShotFileName(const TCHAR* pFileName); bool Util_TestScreenShotFileName(const TCHAR* pFileName);
bool g_bShowPrintScreenWarningDialog; bool g_bShowPrintScreenWarningDialog;

View File

@ -209,18 +209,12 @@ void HarddiskInterfaceCard::NotifyInvalidImage(TCHAR* pszImageFilename)
{ {
// TC: TO DO - see Disk2InterfaceCard::NotifyInvalidImage() // TC: TO DO - see Disk2InterfaceCard::NotifyInvalidImage()
char szBuffer[MAX_PATH + 128]; std::string strText = StrFormat("Unable to open the file %s.",
pszImageFilename);
StringCbPrintf( GetFrame().FrameMessageBox(strText.c_str(),
szBuffer, g_pAppTitle.c_str(),
MAX_PATH + 128, MB_ICONEXCLAMATION | MB_SETFOREGROUND);
TEXT("Unable to open the file %s."),
pszImageFilename);
GetFrame().FrameMessageBox(
szBuffer,
g_pAppTitle.c_str(),
MB_ICONEXCLAMATION | MB_SETFOREGROUND);
} }
//=========================================================================== //===========================================================================
@ -401,12 +395,11 @@ bool HarddiskInterfaceCard::SelectImage(const int drive, LPCSTR pszFilename)
{ {
TCHAR directory[MAX_PATH]; TCHAR directory[MAX_PATH];
TCHAR filename[MAX_PATH]; TCHAR filename[MAX_PATH];
TCHAR title[40];
StringCbCopy(filename, MAX_PATH, pszFilename); StringCbCopy(filename, MAX_PATH, pszFilename);
RegLoadString(TEXT(REG_PREFS), TEXT(REGVALUE_PREF_HDV_START_DIR), 1, directory, MAX_PATH, TEXT("")); RegLoadString(TEXT(REG_PREFS), TEXT(REGVALUE_PREF_HDV_START_DIR), 1, directory, MAX_PATH, TEXT(""));
StringCbPrintf(title, 40, TEXT("Select HDV Image For HDD %d"), drive + 1); std::string title = StrFormat("Select HDV Image For HDD %d", drive + 1);
OPENFILENAME ofn; OPENFILENAME ofn;
memset(&ofn, 0, sizeof(OPENFILENAME)); memset(&ofn, 0, sizeof(OPENFILENAME));
@ -419,7 +412,7 @@ bool HarddiskInterfaceCard::SelectImage(const int drive, LPCSTR pszFilename)
ofn.nMaxFile = MAX_PATH; ofn.nMaxFile = MAX_PATH;
ofn.lpstrInitialDir = directory; ofn.lpstrInitialDir = directory;
ofn.Flags = OFN_FILEMUSTEXIST | OFN_HIDEREADONLY; // Don't allow creation & hide the read-only checkbox ofn.Flags = OFN_FILEMUSTEXIST | OFN_HIDEREADONLY; // Don't allow creation & hide the read-only checkbox
ofn.lpstrTitle = title; ofn.lpstrTitle = title.c_str();
bool bRes = false; bool bRes = false;

View File

@ -1585,15 +1585,13 @@ void MemInitializeROM(void)
} }
} }
TCHAR sText[MAX_PATH]; std::string strText = StrFormat("Unable to open the required firmware ROM data file.\n\nFile: %s", sRomFileName);
StringCbPrintf(sText, sizeof(sText), TEXT("Unable to open the required firmware ROM data file.\n\nFile: %s"), sRomFileName);
LogFileOutput("%s\n", sText); LogFileOutput("%s\n", strText.c_str());
GetFrame().FrameMessageBox( GetFrame().FrameMessageBox(strText.c_str(),
sText, g_pAppTitle.c_str(),
g_pAppTitle.c_str(), MB_ICONSTOP | MB_SETFOREGROUND);
MB_ICONSTOP | MB_SETFOREGROUND);
ExitProcess(1); ExitProcess(1);
} }

View File

@ -30,6 +30,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#include "Registry.h" #include "Registry.h"
#include "CmdLine.h" #include "CmdLine.h"
#include "StrFormat.h"
namespace _ini { namespace _ini {
//=========================================================================== //===========================================================================
@ -60,14 +61,13 @@ BOOL RegLoadString (LPCTSTR section, LPCTSTR key, BOOL peruser, LPTSTR buffer, D
if (!g_sConfigFile.empty()) if (!g_sConfigFile.empty())
return _ini::RegLoadString(section, key, peruser, buffer, chars); return _ini::RegLoadString(section, key, peruser, buffer, chars);
TCHAR fullkeyname[256]; std::string fullkeyname = std::string("Software\\AppleWin\\CurrentVersion\\") + section;
StringCbPrintf(fullkeyname, 256, TEXT("Software\\AppleWin\\CurrentVersion\\%s"), section);
BOOL success = FALSE; BOOL success = FALSE;
HKEY keyhandle; HKEY keyhandle;
LSTATUS status = RegOpenKeyEx( LSTATUS status = RegOpenKeyEx(
(peruser ? HKEY_CURRENT_USER : HKEY_LOCAL_MACHINE), (peruser ? HKEY_CURRENT_USER : HKEY_LOCAL_MACHINE),
fullkeyname, fullkeyname.c_str(),
0, 0,
KEY_READ, KEY_READ,
&keyhandle); &keyhandle);
@ -119,14 +119,13 @@ void RegSaveString (LPCTSTR section, LPCTSTR key, BOOL peruser, const std::strin
if (!g_sConfigFile.empty()) if (!g_sConfigFile.empty())
return _ini::RegSaveString(section, key, peruser, buffer); return _ini::RegSaveString(section, key, peruser, buffer);
TCHAR fullkeyname[256]; std::string fullkeyname = std::string("Software\\AppleWin\\CurrentVersion\\") + section;
StringCbPrintf(fullkeyname, 256, TEXT("Software\\AppleWin\\CurrentVersion\\%s"), section);
HKEY keyhandle; HKEY keyhandle;
DWORD disposition; DWORD disposition;
LSTATUS status = RegCreateKeyEx( LSTATUS status = RegCreateKeyEx(
(peruser ? HKEY_CURRENT_USER : HKEY_LOCAL_MACHINE), (peruser ? HKEY_CURRENT_USER : HKEY_LOCAL_MACHINE),
fullkeyname, fullkeyname.c_str(),
0, 0,
NULL, NULL,
REG_OPTION_NON_VOLATILE, REG_OPTION_NON_VOLATILE,
@ -149,9 +148,8 @@ void RegSaveString (LPCTSTR section, LPCTSTR key, BOOL peruser, const std::strin
//=========================================================================== //===========================================================================
void RegSaveValue (LPCTSTR section, LPCTSTR key, BOOL peruser, DWORD value) { void RegSaveValue (LPCTSTR section, LPCTSTR key, BOOL peruser, DWORD value) {
TCHAR buffer[32] = TEXT(""); std::string strValue = StrFormat("%d", value);
StringCbPrintf(buffer, 32, "%d", value); RegSaveString(section, key, peruser, strValue.c_str());
RegSaveString(section, key, peruser, buffer);
} }
//=========================================================================== //===========================================================================
@ -188,13 +186,12 @@ void RegDeleteConfigSlotSection(UINT slot)
return _ini::RegDeleteString(section.c_str(), peruser); return _ini::RegDeleteString(section.c_str(), peruser);
} }
TCHAR fullkeyname[256]; std::string fullkeyname = std::string("Software\\AppleWin\\CurrentVersion\\") + REG_CONFIG;
StringCbPrintf(fullkeyname, 256, TEXT("Software\\AppleWin\\CurrentVersion\\%s"), REG_CONFIG);
HKEY keyhandle; HKEY keyhandle;
LSTATUS status = RegOpenKeyEx( LSTATUS status = RegOpenKeyEx(
(peruser ? HKEY_CURRENT_USER : HKEY_LOCAL_MACHINE), (peruser ? HKEY_CURRENT_USER : HKEY_LOCAL_MACHINE),
fullkeyname, fullkeyname.c_str(),
0, 0,
KEY_READ, KEY_READ,
&keyhandle); &keyhandle);

View File

@ -115,15 +115,13 @@ void LoadConfiguration(bool loadImages)
if (dwLoadedComputerType != dwComputerType) if (dwLoadedComputerType != dwComputerType)
{ {
char sText[100]; std::string strText = StrFormat("Unsupported Apple2Type(%d). Changing to %d", dwLoadedComputerType, dwComputerType);
StringCbPrintf(sText, sizeof(sText), "Unsupported Apple2Type(%d). Changing to %d", dwLoadedComputerType, dwComputerType);
LogFileOutput("%s\n", sText); LogFileOutput("%s\n", strText.c_str());
GetFrame().FrameMessageBox( GetFrame().FrameMessageBox(strText.c_str(),
sText, "Load Configuration",
"Load Configuration", MB_ICONSTOP | MB_SETFOREGROUND);
MB_ICONSTOP | MB_SETFOREGROUND);
GetPropertySheet().ConfigSaveApple2Type((eApple2Type)dwComputerType); GetPropertySheet().ConfigSaveApple2Type((eApple2Type)dwComputerType);
} }

View File

@ -611,7 +611,7 @@ static void GetAppleWinVersion(void)
delete [] pVerInfoBlock; delete [] pVerInfoBlock;
} }
LogFileOutput("AppleWin version: %s\n", VERSIONSTRING); LogFileOutput("AppleWin version: %s\n", g_VERSIONSTRING.c_str());
} }
// DO ONE-TIME INITIALIZATION // DO ONE-TIME INITIALIZATION
@ -830,9 +830,9 @@ static void RepeatInitialization(void)
if (bShowAboutDlg) if (bShowAboutDlg)
{ {
if (!AboutDlg()) if (!AboutDlg())
g_cmdLine.bShutdown = true; // Close everything down g_cmdLine.bShutdown = true; // Close everything down
else else
RegSaveString(TEXT(REG_CONFIG), TEXT(REGVALUE_VERSION), 1, VERSIONSTRING); // Only save version after user accepts license RegSaveString(REG_CONFIG, REGVALUE_VERSION, TRUE, g_VERSIONSTRING); // Only save version after user accepts license
} }
if (g_bCapturePrintScreenKey) if (g_bCapturePrintScreenKey)

View File

@ -413,16 +413,15 @@ void Win32Frame::DisplayLogo(void)
SetTextAlign(hFrameDC, TA_RIGHT | TA_TOP); SetTextAlign(hFrameDC, TA_RIGHT | TA_TOP);
SetBkMode(hFrameDC, TRANSPARENT); SetBkMode(hFrameDC, TRANSPARENT);
TCHAR szVersion[64]; std::string strVersion = "Version " + g_VERSIONSTRING;
StringCbPrintf(szVersion, 64, "Version %s", VERSIONSTRING);
int xoff = GetFullScreenOffsetX(), yoff = GetFullScreenOffsetY(); int xoff = GetFullScreenOffsetX(), yoff = GetFullScreenOffsetY();
#define DRAWVERSION(x,y,c) \ #define DRAWVERSION(x,y,c) \
SetTextColor(hFrameDC,c); \ SetTextColor(hFrameDC,c); \
TextOut(hFrameDC, \ TextOut(hFrameDC, \
scale*540+x+xoff,scale*358+y+yoff, \ scale*540+x+xoff,scale*358+y+yoff, \
szVersion, \ strVersion.c_str(), \
strlen(szVersion)); strVersion.length());
if (GetDeviceCaps(hFrameDC, PLANES) * GetDeviceCaps(hFrameDC, BITSPIXEL) <= 4) { if (GetDeviceCaps(hFrameDC, PLANES) * GetDeviceCaps(hFrameDC, BITSPIXEL) <= 4) {
DRAWVERSION(2, 2, RGB(0x00, 0x00, 0x00)); DRAWVERSION(2, 2, RGB(0x00, 0x00, 0x00));
@ -436,7 +435,7 @@ void Win32Frame::DisplayLogo(void)
} }
#if _DEBUG #if _DEBUG
StringCbPrintf(szVersion, 64, "DEBUG"); strVersion = "DEBUG";
DRAWVERSION(2, -358 * scale, RGB(0x00, 0x00, 0x00)); DRAWVERSION(2, -358 * scale, RGB(0x00, 0x00, 0x00));
DRAWVERSION(1, -357 * scale, RGB(0x00, 0x00, 0x00)); DRAWVERSION(1, -357 * scale, RGB(0x00, 0x00, 0x00));
DRAWVERSION(0, -356 * scale, RGB(0xFF, 0x00, 0xFF)); DRAWVERSION(0, -356 * scale, RGB(0xFF, 0x00, 0xFF));
@ -621,8 +620,8 @@ BYTE* Win32Frame::GetResource(WORD id, LPCSTR lpType, DWORD dwExpectedSize)
return pResource; return pResource;
} }
std::string Win32Frame::Video_GetScreenShotFolder() std::string Win32Frame::Video_GetScreenShotFolder() const
{ {
// save in current folder // save in current folder
return ""; return std::string();
} }

View File

@ -55,7 +55,7 @@ public:
virtual BYTE* GetResource(WORD id, LPCSTR lpType, DWORD expectedSize); virtual BYTE* GetResource(WORD id, LPCSTR lpType, DWORD expectedSize);
virtual void Restart(); virtual void Restart();
virtual std::string Video_GetScreenShotFolder(); virtual std::string Video_GetScreenShotFolder() const;
bool GetFullScreenShowSubunitStatus(void); bool GetFullScreenShowSubunitStatus(void);
int GetFullScreenOffsetX(void); int GetFullScreenOffsetX(void);