Fixing unicode in georges edit dll

feature/3ds-max-2020
kaetemi 6 years ago
parent 01d5edd47b
commit 556806715e

@ -579,12 +579,12 @@ void CGeorgesImpl::LoadDocument( const std::string& _sxfullname )
AFX_MANAGE_STATE(AfxGetStaticModuleState()); AFX_MANAGE_STATE(AfxGetStaticModuleState());
try try
{ {
theApp.OpenDocumentFile(_sxfullname.c_str()); theApp.OpenDocumentFile(utf8ToTStr(_sxfullname));
} }
catch (const NLMISC::Exception &e) catch (const NLMISC::Exception &e)
{ {
std::string tmp = std::string(e.what()) + "(" + _sxfullname + ")"; std::string tmp = std::string(e.what()) + "(" + _sxfullname + ")";
theApp.m_pMainWnd->MessageBox(tmp.c_str(), "Georges_Lib", MB_ICONERROR | MB_OK); theApp.m_pMainWnd->MessageBox(utf8ToTStr(tmp), _T("Georges_Lib"), MB_ICONERROR | MB_OK);
} }
} }
@ -666,7 +666,7 @@ IGeorges* IGeorges::getInterface (int version)
// Check version number // Check version number
if (version != GEORGES_VERSION) if (version != GEORGES_VERSION)
{ {
MessageBox (NULL, "Bad version of georges.dll.", "Georges", MB_ICONEXCLAMATION|MB_OK); MessageBox(NULL, _T("Bad version of georges.dll."), _T("Georges"), MB_ICONEXCLAMATION | MB_OK);
return NULL; return NULL;
} }
else else

@ -86,20 +86,20 @@ BOOL CHeaderDialog::OnInitDialog()
// Create the version // Create the version
setStaticSize (currentPos); setStaticSize (currentPos);
char versionText[512]; CString versionText;
smprintf (versionText, 512, "Version %d.%d", 0, 0); versionText.Format(_T("Version %d.%d"), 0, 0);
LabelVersion.Create (versionText, WS_VISIBLE, currentPos, this); LabelVersion.Create (versionText, WS_VISIBLE, currentPos, this);
initWidget (LabelVersion); initWidget (LabelVersion);
getNextPosLabel (currentPos); getNextPosLabel (currentPos);
setButtonSize (currentPos, SmallWidget); setButtonSize (currentPos, SmallWidget);
IncrementVersion.Create ("Increment Version", WS_VISIBLE|WS_TABSTOP, currentPos, this, BtIncrement); IncrementVersion.Create (_T("Increment Version"), WS_VISIBLE|WS_TABSTOP, currentPos, this, BtIncrement);
initWidget (IncrementVersion); initWidget (IncrementVersion);
getNextPos (currentPos); getNextPos (currentPos);
// Create the state combo // Create the state combo
setStaticSize (currentPos); setStaticSize (currentPos);
LabelState.Create ("State:", WS_VISIBLE, currentPos, this); LabelState.Create (_T("State:"), WS_VISIBLE, currentPos, this);
initWidget (LabelState); initWidget (LabelState);
getNextPosLabel (currentPos); getNextPosLabel (currentPos);
@ -109,30 +109,30 @@ BOOL CHeaderDialog::OnInitDialog()
ComboState.Create (WS_VISIBLE|CBS_DROPDOWNLIST|WS_TABSTOP, pos, this, CbState); ComboState.Create (WS_VISIBLE|CBS_DROPDOWNLIST|WS_TABSTOP, pos, this, CbState);
uint item; uint item;
for (item=0; item<CFileHeader::StateCount; item++) for (item=0; item<CFileHeader::StateCount; item++)
ComboState.InsertString (-1, CFileHeader::getStateString ((CFileHeader::TState)item)); ComboState.InsertString (-1, utf8ToTStr(CFileHeader::getStateString ((CFileHeader::TState)item)));
ComboState.SetCurSel (0); ComboState.SetCurSel (0);
initWidget (ComboState); initWidget (ComboState);
getNextPos (currentPos); getNextPos (currentPos);
// Default value // Default value
setStaticSize (currentPos); setStaticSize (currentPos);
LabelComments.Create ("Comments:", WS_VISIBLE, currentPos, this); LabelComments.Create (_T("Comments:"), WS_VISIBLE, currentPos, this);
initWidget (LabelComments); initWidget (LabelComments);
getNextPosLabel (currentPos); getNextPosLabel (currentPos);
setBigEditSize (currentPos, SmallWidget); setBigEditSize (currentPos, SmallWidget);
Comments.CreateEx (WS_EX_CLIENTEDGE, _T("EDIT"), "", WS_VSCROLL|ES_OEMCONVERT|ES_MULTILINE|ES_WANTRETURN|WS_CHILD|WS_VISIBLE|WS_TABSTOP|ES_AUTOHSCROLL|ES_AUTOVSCROLL, currentPos, this, EdComments); Comments.CreateEx (WS_EX_CLIENTEDGE, _T("EDIT"), _T(""), WS_VSCROLL|ES_OEMCONVERT|ES_MULTILINE|ES_WANTRETURN|WS_CHILD|WS_VISIBLE|WS_TABSTOP|ES_AUTOHSCROLL|ES_AUTOVSCROLL, currentPos, this, EdComments);
initWidget (Comments); initWidget (Comments);
getNextPos (currentPos); getNextPos (currentPos);
// Min value // Min value
setStaticSize (currentPos); setStaticSize (currentPos);
LabelLog.Create ("Log:", WS_VISIBLE, currentPos, this); LabelLog.Create (_T("Log:"), WS_VISIBLE, currentPos, this);
initWidget (LabelLog); initWidget (LabelLog);
getNextPosLabel (currentPos); getNextPosLabel (currentPos);
setBigEditSize (currentPos, SmallWidget); setBigEditSize (currentPos, SmallWidget);
Log.CreateEx (WS_EX_CLIENTEDGE, _T("EDIT"), "", WS_VSCROLL|ES_READONLY|ES_MULTILINE|WS_CHILD|WS_VISIBLE|ES_AUTOHSCROLL|ES_AUTOVSCROLL, currentPos, this, EdLog); Log.CreateEx (WS_EX_CLIENTEDGE, _T("EDIT"), _T(""), WS_VSCROLL|ES_READONLY|ES_MULTILINE|WS_CHILD|WS_VISIBLE|ES_AUTOHSCROLL|ES_AUTOVSCROLL, currentPos, this, EdLog);
initWidget (Log); initWidget (Log);
getNextPos (currentPos); getNextPos (currentPos);
@ -244,8 +244,8 @@ void CHeaderDialog::getFromDocument (const NLGEORGES::CFileHeader &header)
{ {
// Nel standard version number // Nel standard version number
ComboState.SetCurSel (header.State); ComboState.SetCurSel (header.State);
char name[512]; CString name;
smprintf (name, 512, "Version %d.%d", header.MajorVersion, header.MinorVersion); name.Format(_T("Version %d.%d"), header.MajorVersion, header.MinorVersion);
LabelVersion.SetWindowText (name); LabelVersion.SetWindowText (name);
// Set comments // Set comments
@ -276,16 +276,16 @@ void CHeaderDialog::setVersionToDocument ()
uint v0, v1; uint v0, v1;
CString str; CString str;
LabelVersion.GetWindowText (str); LabelVersion.GetWindowText (str);
if (sscanf ((const char*)str, "Version %d.%d", &v0, &v1)==2) if (sscanf (tStrToUtf8(str).c_str(), "Version %d.%d", &v0, &v1)==2)
{ {
v0++; v0++;
v1=0; v1=0;
char name[512]; CString name;
smprintf (name, 512, "Version %d.%d", v0, v1); name.Format(_T("Version %d.%d"), v0, v1);
LabelVersion.SetWindowText (name); LabelVersion.SetWindowText (name);
// Modify docuemnt // Modify docuemnt
doc->modify (new CActionString (IAction::HeaderVersion, name, *doc, "", "", doc->modify(new CActionString(IAction::HeaderVersion, tStrToUtf8(name).c_str(), *doc, "", "",
doc->getLeftView ()->getCurrentSelectionId (), 0)); doc->getLeftView ()->getCurrentSelectionId (), 0));
} }
} }
@ -299,7 +299,7 @@ void CHeaderDialog::setCommentsToDocument ()
CGeorgesEditDocSub *current = doc->getSelectedObject (); CGeorgesEditDocSub *current = doc->getSelectedObject ();
CString str; CString str;
Comments.GetWindowText (str); Comments.GetWindowText (str);
doc->modify (new CActionString (IAction::HeaderComments, str, *doc, "", "", doc->modify(new CActionString(IAction::HeaderComments, tStrToUtf8(str).c_str(), *doc, "", "",
doc->getLeftView ()->getCurrentSelectionId (), 0)); doc->getLeftView ()->getCurrentSelectionId (), 0));
} }
} }

@ -85,7 +85,7 @@ void CIconWnd::create (DWORD wStyle, RECT &pos, CWnd *parent, uint dialogIndex)
LPCTSTR className = AfxRegisterWndClass(CS_OWNDC); LPCTSTR className = AfxRegisterWndClass(CS_OWNDC);
// Create this window // Create this window
CWnd::Create(className, "empty", wStyle, pos, parent, dialogIndex); CWnd::Create(className, _T("empty"), wStyle, pos, parent, dialogIndex);
} }
bool CIconWnd::updateStr() bool CIconWnd::updateStr()
@ -283,14 +283,15 @@ void CIconWnd::addIconLayer(NLMISC::CBitmap &dst, const std::string iconStr, con
bool CIconWnd::updateWnd(CWnd *pWnd, std::string &str) bool CIconWnd::updateWnd(CWnd *pWnd, std::string &str)
{ {
char buffer[512]; TCHAR buffer[512];
if (pWnd) if (pWnd)
{ {
pWnd->GetWindowText(buffer, 512); pWnd->GetWindowText(buffer, 512);
if (buffer != str) std::string buf = tStrToUtf8(buffer);
if (buf != str)
{ {
str = buffer; str = buf;
return true; return true;
} }
} }

@ -27,7 +27,7 @@ using namespace NLMISC;
#pragma warning (disable : 4786) #pragma warning (disable : 4786)
BOOL CALLBACK EnumResLangProc(HMODULE hModule, LPCSTR lpszType, LPCSTR lpszName, WORD wIDLanguage, BOOL CALLBACK EnumResLangProc(HMODULE hModule, LPCTSTR lpszType, LPCTSTR lpszName, WORD wIDLanguage,
LONG_PTR lParam) LONG_PTR lParam)
{ {
set<HRSRC> *iconNames = (set<HRSRC>*)lParam; set<HRSRC> *iconNames = (set<HRSRC>*)lParam;
@ -96,7 +96,7 @@ void CImageListEx::addResourceIcon (const char *filename)
int height = imageInfo.rcImage.bottom - imageInfo.rcImage.top; int height = imageInfo.rcImage.bottom - imageInfo.rcImage.top;
// Load the icon // Load the icon
HICON handle = (HICON) LoadImage (NULL, filename, IMAGE_ICON, width, height, LR_COLOR|LR_LOADFROMFILE); HICON handle = (HICON) LoadImage (NULL, utf8ToTStr(filename), IMAGE_ICON, width, height, LR_COLOR|LR_LOADFROMFILE);
if (handle) if (handle)
{ {
// Copy the icon // Copy the icon

Loading…
Cancel
Save