winport - fix drag & drop and recent roms menu so I can verify whether any of that stuff works in chinese

This commit is contained in:
zeromus 2020-05-05 02:00:58 -04:00
parent d4c17e5f8d
commit 76fafe0230
2 changed files with 19 additions and 16 deletions

View File

@ -4253,12 +4253,13 @@ DOKEYDOWN:
case WM_DROPFILES:
{
char filename[MAX_PATH] = "";
DragQueryFile((HDROP)wParam,0,filename,MAX_PATH);
wchar_t wfilename[MAX_PATH] = L"";
DragQueryFileW((HDROP)wParam,0,wfilename,MAX_PATH);
DragFinish((HDROP)wParam);
std::string fileDropped = wcstombs((std::wstring)wfilename);
const char* filename = fileDropped.c_str();
//adelikat: dropping these in from FCEUX, I hope this is the best place for that
std::string fileDropped = filename;
//-------------------------------------------------------
//Check if Movie file
//-------------------------------------------------------
@ -4326,7 +4327,7 @@ DOKEYDOWN:
//Else load it as a ROM
//-------------------------------------------------------
else if(OpenCoreSystemCP(filename))
else if(OpenCore(filename))
{
romloaded = TRUE;
}

View File

@ -41,6 +41,7 @@ void PopulateRecentRomsMenu()
//----------------------------------------------------------------------
//Get Menu item info
MENUITEMINFOW moow;
MENUITEMINFO moo;
moo.cbSize = sizeof(moo);
moo.fMask = MIIM_SUBMENU | MIIM_STATE;
@ -91,20 +92,21 @@ void PopulateRecentRomsMenu()
//the recent roms are UTF-8, so convert to windows stupid codepage
auto wtmp = mbstowcs(tmp);
char garbage[1024];
WideCharToMultiByte(CP_ACP,0,wtmp.c_str(),-1,garbage,1024,NULL,NULL);
wchar_t garbage[1024];
wcscpy(garbage,wtmp.c_str());
PathCompactPath(dc, garbage, 500);
PathCompactPathW(dc, garbage, 500);
moo.cbSize = sizeof(moo);
moo.fMask = MIIM_DATA | MIIM_ID | MIIM_TYPE;
memset(&moow, 0, sizeof(moow));
moow.cbSize = sizeof(moo);
moow.fMask = MIIM_DATA | MIIM_ID | MIIM_TYPE;
moo.cch = tmp.size();
moo.fType = 0;
moo.wID = recentRoms_baseid + x;
moo.dwTypeData = garbage;
moow.cch = wtmp.size();
moow.fType = 0;
moow.wID = recentRoms_baseid + x;
moow.dwTypeData = garbage;
//LOG("Inserting: %s\n",tmp.c_str()); //Debug
InsertMenuItem(GetSubMenu(recentromsmenu, 0), 0, 1, &moo);
InsertMenuItemW(GetSubMenu(recentromsmenu, 0), 0, 1, &moow);
}
ReleaseDC(MainWindow->getHWnd(), dc);
@ -141,7 +143,7 @@ void LoadRecentRoms()
//This function retrieves the recent ROMs stored in the .ini file
//Then is populates the RecentRomsMenu array
char tempstr[256];
char tempstr[1024];
// Avoids duplicating when changing the language.
RecentRoms.clear();
@ -152,7 +154,7 @@ void LoadRecentRoms()
char keyName[100];
sprintf(keyName,"Recent Rom %d",x);
GetPrivateProfileString("General",keyName,"", tempstr, 256, IniName);
GetPrivateProfileString("General",keyName,"", tempstr, 1024, IniName);
if (tempstr[0])
RecentRoms.push_back(tempstr);
}