From bd3fd85b990598ef0b5fe42c8e713e15c8726be8 Mon Sep 17 00:00:00 2001 From: zilmar Date: Fri, 6 Mar 2015 18:27:31 +1100 Subject: [PATCH] Language: More code cleanup, status messages, dialog box, etc --- Source/3rd Party/WTL/atlgdi.h | 9 ++ Source/Project64/3rd Party/7zip.cpp | 28 +--- Source/Project64/3rd Party/7zip.h | 6 +- Source/Project64/N64 System/N64 Rom Class.cpp | 6 +- Source/Project64/User Interface/Gui Class.cpp | 15 +- Source/Project64/User Interface/Gui Class.h | 2 +- .../User Interface/Main Menu Class.cpp | 6 +- .../User Interface/Notification Class.cpp | 13 +- .../User Interface/Rom Browser Class.cpp | 135 +++++++++++------- .../Settings/Settings Page - Directories.cpp | 2 +- .../User Interface/Settings/Settings Page.h | 13 +- .../Project64/User Interface/UI Resources.rc | 2 +- .../WTL Controls/PartialGroupBox.cpp | 32 +++-- .../WTL Controls/PartialGroupBox.h | 1 - 14 files changed, 161 insertions(+), 109 deletions(-) diff --git a/Source/3rd Party/WTL/atlgdi.h b/Source/3rd Party/WTL/atlgdi.h index 1e452c4d9..0ecc43574 100644 --- a/Source/3rd Party/WTL/atlgdi.h +++ b/Source/3rd Party/WTL/atlgdi.h @@ -2521,6 +2521,15 @@ public: return ::DrawText(m_hDC, lpstrText, cchText, lpRect, uFormat); } + int DrawTextW(LPCWSTR lpstrText, int cchText, LPRECT lpRect, UINT uFormat) + { + ATLASSERT(m_hDC != NULL); +#ifndef _WIN32_WCE + ATLASSERT((uFormat & DT_MODIFYSTRING) == 0); +#endif // !_WIN32_WCE + return ::DrawTextW(m_hDC, lpstrText, cchText, lpRect, uFormat); + } + int DrawText(LPTSTR lpstrText, int cchText, LPRECT lpRect, UINT uFormat) { ATLASSERT(m_hDC != NULL); diff --git a/Source/Project64/3rd Party/7zip.cpp b/Source/Project64/3rd Party/7zip.cpp index 81d7782a7..0af7bd659 100644 --- a/Source/Project64/3rd Party/7zip.cpp +++ b/Source/Project64/3rd Party/7zip.cpp @@ -126,9 +126,9 @@ bool C7zip::GetFile(int index, Byte * Data, size_t DataLen ) size_t offset; size_t outSizeProcessed; - char Msg[200]; - std::string FileName = FileNameIndex(index); - sprintf(Msg,"Getting %s",FileName.c_str()); + wchar_t Msg[200]; + std::wstring FileName = FileNameIndex(index); + _snwprintf(Msg, sizeof(Msg) / sizeof(Msg[0]), L"extracting %s", FileName.c_str()); m_NotfyCallback(Msg,m_NotfyCallbackInfo); SRes res = SzArEx_Extract(m_db, &m_archiveLookStream.s, index, @@ -146,7 +146,7 @@ bool C7zip::GetFile(int index, Byte * Data, size_t DataLen ) outSizeProcessed = DataLen; } memcpy(Data,m_outBuffer + offset,outSizeProcessed); - m_NotfyCallback("",m_NotfyCallbackInfo); + m_NotfyCallback(L"",m_NotfyCallbackInfo); m_CurrentFile = -1; return true; } @@ -222,10 +222,9 @@ const char * C7zip::FileName ( char * FileName, int SizeOfFileName ) const return FileName; } -std::string C7zip::FileNameIndex (int index) +std::wstring C7zip::FileNameIndex (int index) { - std::string filename; - + std::wstring filename; if (m_db == NULL || m_db->FileNameOffsets == 0) { /* no filename */ @@ -237,20 +236,7 @@ std::string C7zip::FileNameIndex (int index) /* no filename */ return filename; } - std::wstring filename_utf16; - filename_utf16.resize(namelen); - - SzArEx_GetFileNameUtf16(m_db, index, (UInt16 *)filename_utf16.c_str()); - namelen = WideCharToMultiByte(CP_UTF8, 0, filename_utf16.c_str(), -1, NULL, 0, NULL, NULL); - if (namelen == 0) - { - /* no filename */ - return filename; - } filename.resize(namelen); - if (WideCharToMultiByte(CP_UTF8, 0, (LPCWSTR)filename_utf16.c_str(), -1, (LPSTR)filename.c_str(), namelen, NULL, NULL) == 0) - { - filename.clear(); - } + SzArEx_GetFileNameUtf16(m_db, index, (UInt16 *)filename.c_str()); return filename; } diff --git a/Source/Project64/3rd Party/7zip.h b/Source/Project64/3rd Party/7zip.h index 4b79aa5cc..7a5b1d820 100644 --- a/Source/Project64/3rd Party/7zip.h +++ b/Source/Project64/3rd Party/7zip.h @@ -22,7 +22,7 @@ public: C7zip (LPCSTR FileName); ~C7zip (); - typedef void (__stdcall *LP7ZNOTIFICATION)( LPCSTR Status, void * CBInfo ); + typedef void (__stdcall *LP7ZNOTIFICATION)( LPCWSTR Status, void * CBInfo ); inline int NumFiles ( void ) const { return m_db ? m_db->db.NumFiles : 0; } inline CSzFileItem * FileItem ( int index ) const { return m_db ? &m_db->db.Files[index] : NULL; } @@ -31,7 +31,7 @@ public: bool GetFile ( int index, Byte * Data, size_t DataLen ); const char * FileName ( char * FileName, int SizeOfFileName ) const; - std::string FileNameIndex (int index); + std::wstring FileNameIndex (int index); void SetNotificationCallback (LP7ZNOTIFICATION NotfyFnc, void * CBInfo); @@ -69,7 +69,7 @@ private: //static void __stdcall StatusUpdate(_7Z_STATUS status, int Value1, int Value2, C7zip * _this); - static void __stdcall NotfyCallbackDefault ( LPCSTR /*Status*/, void * /*CBInfo*/ ) { } + static void __stdcall NotfyCallbackDefault ( LPCWSTR /*Status*/, void * /*CBInfo*/ ) { } LP7ZNOTIFICATION m_NotfyCallback; void * m_NotfyCallbackInfo; diff --git a/Source/Project64/N64 System/N64 Rom Class.cpp b/Source/Project64/N64 System/N64 Rom Class.cpp index bb77d1a7d..d64d58b4b 100644 --- a/Source/Project64/N64 System/N64 Rom Class.cpp +++ b/Source/Project64/N64 System/N64 Rom Class.cpp @@ -292,7 +292,7 @@ bool CN64Rom::LoadN64Image ( const char * FileLoc, bool LoadBootCodeOnly ) { } C7zip ZipFile(FullPath); - //ZipFile.SetNotificationCallback((C7zip::LP7ZNOTIFICATION)NotificationCB,this); + ZipFile.SetNotificationCallback((C7zip::LP7ZNOTIFICATION)NotificationCB,this); for (int i = 0; i < ZipFile.NumFiles(); i++) { CSzFileItem * f = ZipFile.FileItem(i); @@ -300,7 +300,9 @@ bool CN64Rom::LoadN64Image ( const char * FileLoc, bool LoadBootCodeOnly ) { { continue; } - if (_stricmp(ZipFile.FileNameIndex(i).c_str(), SubFile) != 0) + stdstr ZipFileName; + ZipFileName.FromUTF16(ZipFile.FileNameIndex(i).c_str()); + if (_stricmp(ZipFileName.c_str(), SubFile) != 0) { continue; } diff --git a/Source/Project64/User Interface/Gui Class.cpp b/Source/Project64/User Interface/Gui Class.cpp index cc60cf652..df07c6d50 100644 --- a/Source/Project64/User Interface/Gui Class.cpp +++ b/Source/Project64/User Interface/Gui Class.cpp @@ -470,23 +470,24 @@ void CMainGui::RefreshMenu (void) m_Menu->ResetMenu(); } -void CMainGui::SetStatusText (int Panel,const char * Text) { - static char Message[2][500]; +void CMainGui::SetStatusText (int Panel,const wchar_t * Text) +{ + static wchar_t Message[2][500]; if (Panel >= 2) { Notify().BreakPoint(__FILE__,__LINE__); return; } - char * Msg = Message[Panel]; + wchar_t * Msg = Message[Panel]; memset(Msg,0,sizeof(Message[0])); - _snprintf(Msg,sizeof(Message[0]),"%s",Text); - Msg[sizeof(Message[0]) - 1] = 0; + _snwprintf(Msg, sizeof(Message[0]) / sizeof(Message[0][0]), L"%s", Text); + Msg[(sizeof(Message[0]) / sizeof(Message[0][0])) - 1] = 0; if (GetCurrentThreadId() == m_ThreadId) { - SendMessage( (HWND)m_hStatusWnd, SB_SETTEXT, Panel, (LPARAM)Msg ); + SendMessageW( (HWND)m_hStatusWnd, SB_SETTEXTW, Panel, (LPARAM)Msg ); } else { - PostMessage( (HWND)m_hStatusWnd, SB_SETTEXT, Panel, (LPARAM)Msg ); + PostMessageW( (HWND)m_hStatusWnd, SB_SETTEXTW, Panel, (LPARAM)Msg ); } } diff --git a/Source/Project64/User Interface/Gui Class.h b/Source/Project64/User Interface/Gui Class.h index 4d8cd085a..7b664744e 100644 --- a/Source/Project64/User Interface/Gui Class.h +++ b/Source/Project64/User Interface/Gui Class.h @@ -69,7 +69,7 @@ public: CBaseMenu * GetMenuClass ( void ) { return m_Menu; } // Status bar - void SetStatusText ( int Panel,const char * Text ); + void SetStatusText ( int Panel,const wchar_t * Text ); void ShowStatusBar ( bool ShowBar ); //About Window diff --git a/Source/Project64/User Interface/Main Menu Class.cpp b/Source/Project64/User Interface/Main Menu Class.cpp index 78c821af4..7be707aec 100644 --- a/Source/Project64/User Interface/Main Menu Class.cpp +++ b/Source/Project64/User Interface/Main Menu Class.cpp @@ -49,7 +49,8 @@ void CMainMenu::SettingsChanged (CMainMenu * _this ) _this->ResetMenu(); } -int CMainMenu::ProcessAccelerator ( HWND hWnd, void * lpMsg ) { +int CMainMenu::ProcessAccelerator ( HWND hWnd, void * lpMsg ) +{ if (m_ResetAccelerators) { m_ResetAccelerators = false; @@ -59,7 +60,8 @@ int CMainMenu::ProcessAccelerator ( HWND hWnd, void * lpMsg ) { return TranslateAccelerator((HWND)hWnd,(HACCEL)m_AccelTable,(LPMSG)lpMsg); } -bool CMainMenu::ProcessMessage(HWND hWnd, DWORD /*FromAccelerator*/, DWORD MenuID) { +bool CMainMenu::ProcessMessage(HWND hWnd, DWORD /*FromAccelerator*/, DWORD MenuID) +{ switch (MenuID) { case ID_FILE_OPEN_ROM: { diff --git a/Source/Project64/User Interface/Notification Class.cpp b/Source/Project64/User Interface/Notification Class.cpp index c51e1a50b..119842a4e 100644 --- a/Source/Project64/User Interface/Notification Class.cpp +++ b/Source/Project64/User Interface/Notification Class.cpp @@ -105,20 +105,20 @@ void CNotification::DisplayMessage ( int DisplayTime, const wchar_t * Message, va_end( ap ); - stdstr PluginMessage; - PluginMessage.FromUTF16(Msg); if (InFullScreen()) { if (m_gfxPlugin && m_gfxPlugin->DrawStatus) { WriteTrace(TraceGfxPlugin,__FUNCTION__ ": DrawStatus - Starting"); - m_gfxPlugin->DrawStatus(PluginMessage.c_str(),FALSE); + stdstr PluginMessage; + PluginMessage.FromUTF16(Msg); + m_gfxPlugin->DrawStatus(PluginMessage.c_str(), FALSE); WriteTrace(TraceGfxPlugin,__FUNCTION__ ": DrawStatus - Done"); } } else { - m_hWnd->SetStatusText(0,PluginMessage.c_str()); + m_hWnd->SetStatusText(0, Msg); } } @@ -137,10 +137,7 @@ void CNotification::DisplayMessage2 ( const wchar_t * Message, va_list ap ) con _vsnwprintf( Msg,sizeof(Msg) - 1 ,Message, ap ); va_end( ap ); - stdstr DisplayMessage; - DisplayMessage.FromUTF16(Msg); - - m_hWnd->SetStatusText(1,DisplayMessage.c_str()); + m_hWnd->SetStatusText(1,Msg); } void CNotification::SetGfxPlugin( CGfxPlugin * Plugin ) diff --git a/Source/Project64/User Interface/Rom Browser Class.cpp b/Source/Project64/User Interface/Rom Browser Class.cpp index 1b22b2a06..3af98e50b 100644 --- a/Source/Project64/User Interface/Rom Browser Class.cpp +++ b/Source/Project64/User Interface/Rom Browser Class.cpp @@ -364,21 +364,26 @@ DWORD CRomBrowser::AsciiToHex (char * HexValue) { } -void CRomBrowser::CreateRomListControl (void) { +void CRomBrowser::CreateRomListControl (void) +{ m_hRomList = (HWND)CreateWindowEx( WS_EX_CLIENTEDGE,WC_LISTVIEW,NULL, WS_TABSTOP | WS_VISIBLE | WS_CHILD | LVS_OWNERDRAWFIXED | WS_BORDER | LVS_SINGLESEL | LVS_REPORT, - 0,0,0,0,(HWND)m_MainWindow,(HMENU)IDC_ROMLIST,GetModuleHandle(NULL),NULL); + 0,0,0,0,m_MainWindow,(HMENU)IDC_ROMLIST,GetModuleHandle(NULL),NULL); ResetRomBrowserColomuns(); LoadRomList(); } -void CRomBrowser::DeallocateBrushs (void) { - for (size_t count = 0; count < m_RomInfo.size(); count++) { - if (m_RomInfo[count].SelColor == -1) { +void CRomBrowser::DeallocateBrushs (void) +{ + for (size_t count = 0; count < m_RomInfo.size(); count++) + { + if (m_RomInfo[count].SelColor == -1) + { continue; } - if (m_RomInfo[count].SelColorBrush) { + if (m_RomInfo[count].SelColorBrush) + { DeleteObject((HBRUSH)m_RomInfo[count].SelColorBrush); m_RomInfo[count].SelColorBrush = NULL; } @@ -406,36 +411,45 @@ void CRomBrowser::FillRomExtensionInfo(ROM_INFO * pRomInfo) sprintf(Identifier,"%08X-%08X-C:%X",pRomInfo->CRC1,pRomInfo->CRC2,pRomInfo->Country); //Rom Notes - if (m_Fields[RB_UserNotes].Pos() >= 0) { + if (m_Fields[RB_UserNotes].Pos() >= 0) + { m_NotesIniFile->GetString(Identifier,"Note","",pRomInfo->UserNotes,sizeof(pRomInfo->UserNotes)); } //Rom Extension info - if (m_Fields[RB_Developer].Pos() >= 0) { + if (m_Fields[RB_Developer].Pos() >= 0) + { m_ExtIniFile->GetString(Identifier,"Developer","",pRomInfo->Developer,sizeof(pRomInfo->Developer)); } - if (m_Fields[RB_ReleaseDate].Pos() >= 0) { + if (m_Fields[RB_ReleaseDate].Pos() >= 0) + { m_ExtIniFile->GetString(Identifier,"ReleaseDate","",pRomInfo->ReleaseDate,sizeof(pRomInfo->ReleaseDate)); } - if (m_Fields[RB_Genre].Pos() >= 0) { + if (m_Fields[RB_Genre].Pos() >= 0) + { m_ExtIniFile->GetString(Identifier,"Genre","",pRomInfo->Genre,sizeof(pRomInfo->Genre)); } - if (m_Fields[RB_Players].Pos() >= 0) { + if (m_Fields[RB_Players].Pos() >= 0) + { m_ExtIniFile->GetNumber(Identifier,"Players",1,(DWORD &)pRomInfo->Players); } - if (m_Fields[RB_ForceFeedback].Pos() >= 0) { + if (m_Fields[RB_ForceFeedback].Pos() >= 0) + { m_ExtIniFile->GetString(Identifier,"ForceFeedback","unknown",pRomInfo->ForceFeedback,sizeof(pRomInfo->ForceFeedback)); } //Rom Settings - if (m_Fields[RB_GoodName].Pos() >= 0) { + if (m_Fields[RB_GoodName].Pos() >= 0) + { m_RomIniFile->GetString(Identifier,"Good Name",pRomInfo->GoodName,pRomInfo->GoodName,sizeof(pRomInfo->GoodName)); } m_RomIniFile->GetString(Identifier,"Status",pRomInfo->Status,pRomInfo->Status,sizeof(pRomInfo->Status)); - if (m_Fields[RB_CoreNotes].Pos() >= 0) { + if (m_Fields[RB_CoreNotes].Pos() >= 0) + { m_RomIniFile->GetString(Identifier,"Core Note","",pRomInfo->CoreNotes,sizeof(pRomInfo->CoreNotes)); } - if (m_Fields[RB_PluginNotes].Pos() >= 0) { + if (m_Fields[RB_PluginNotes].Pos() >= 0) + { m_RomIniFile->GetString(Identifier,"Plugin Note","",pRomInfo->PluginNotes,sizeof(pRomInfo->PluginNotes)); } @@ -449,9 +463,12 @@ void CRomBrowser::FillRomExtensionInfo(ROM_INFO * pRomInfo) sprintf(String,"%s.Sel",pRomInfo->Status); m_RomIniFile->GetString("Rom Status",String,"FFFFFFFF",String,9); int selcol = AsciiToHex(String); - if (selcol < 0) { + if (selcol < 0) + { pRomInfo->SelColor = - 1; - } else { + } + else + { selcol = (AsciiToHex(String) & 0xFFFFFF); selcol = (selcol & 0x00FF00) | ((selcol >> 0x10) & 0xFF) | ((selcol & 0xFF) << 0x10); pRomInfo->SelColor = selcol; @@ -464,7 +481,8 @@ void CRomBrowser::FillRomExtensionInfo(ROM_INFO * pRomInfo) pRomInfo->SelTextColor = (pRomInfo->SelTextColor & 0x00FF00) | ((pRomInfo->SelTextColor >> 0x10) & 0xFF) | ((pRomInfo->SelTextColor & 0xFF) << 0x10); } -bool CRomBrowser::FillRomInfo(ROM_INFO * pRomInfo) { +bool CRomBrowser::FillRomInfo(ROM_INFO * pRomInfo) +{ int count; BYTE RomData[0x1000]; @@ -477,13 +495,17 @@ bool CRomBrowser::FillRomInfo(ROM_INFO * pRomInfo) { if (strstr(pRomInfo->szFullFileName,"?") != NULL) { strcpy(pRomInfo->FileName,strstr(pRomInfo->szFullFileName,"?") + 1); - } else { + } + else + { char drive[_MAX_DRIVE] ,dir[_MAX_DIR], ext[_MAX_EXT]; _splitpath( pRomInfo->szFullFileName, drive, dir, pRomInfo->FileName, ext ); } - if (m_Fields[RB_InternalName].Pos() >= 0) { + if (m_Fields[RB_InternalName].Pos() >= 0) + { memcpy(pRomInfo->InternalName,(void *)(RomData + 0x20),20); - for( count = 0 ; count < 20; count += 4 ) { + for( count = 0 ; count < 20; count += 4 ) + { pRomInfo->InternalName[count] ^= pRomInfo->InternalName[count+3]; pRomInfo->InternalName[count + 3] ^= pRomInfo->InternalName[count]; pRomInfo->InternalName[count] ^= pRomInfo->InternalName[count+3]; @@ -504,9 +526,12 @@ bool CRomBrowser::FillRomInfo(ROM_INFO * pRomInfo) { FillRomExtensionInfo(pRomInfo); - if (pRomInfo->SelColor == -1) { + if (pRomInfo->SelColor == -1) + { pRomInfo->SelColorBrush = (DWORD)((HBRUSH)(COLOR_HIGHLIGHT + 1)); - } else { + } + else + { pRomInfo->SelColorBrush = (DWORD)CreateSolidBrush(pRomInfo->SelColor); } @@ -528,7 +553,8 @@ bool CRomBrowser::GetRomFileNames( strlist & FileList, const CPath & BaseDirecto return false; } - do { + do + { if (InWatchThread && WaitForSingleObject(m_WatchStopEvent,0) != WAIT_TIMEOUT) { return false; @@ -541,7 +567,9 @@ bool CRomBrowser::GetRomFileNames( strlist & FileList, const CPath & BaseDirecto stdstr CurrentDir = Directory + SearchPath.GetCurrentDirectory() + "\\"; GetRomFileNames(FileList,BaseDirectory,CurrentDir,InWatchThread); } - } else { + } + else + { AddFileNameToList(FileList, Directory, SearchPath); } } while (SearchPath.FindNext()); @@ -585,7 +613,8 @@ void CRomBrowser::FillRomList ( strlist & FileList, const CPath & BaseDirectory, return; } - do { + do + { WriteTraceF(TraceDebug,__FUNCTION__ ": 2 %s m_StopRefresh = %d",(LPCSTR)SearchPath,m_StopRefresh); if (m_StopRefresh) { break; } @@ -635,12 +664,14 @@ void CRomBrowser::FillRomList ( strlist & FileList, const CPath & BaseDirectory, } ROM_INFO RomInfo; - std::string FileName = ZipFile.FileNameIndex(i); - if (FileName.length() == 0) + std::wstring FileNameW = ZipFile.FileNameIndex(i); + if (FileNameW.length() == 0) { continue; } + stdstr FileName; + FileName.FromUTF16(FileNameW.c_str()); WriteTrace(TraceDebug,__FUNCTION__ ": 5"); char drive2[_MAX_DRIVE] ,dir2[_MAX_DIR], FileName2[MAX_PATH], ext2[_MAX_EXT]; _splitpath( FileName.c_str(), drive2, dir2, FileName2, ext2 ); @@ -657,7 +688,7 @@ void CRomBrowser::FillRomList ( strlist & FileList, const CPath & BaseDirectory, WriteTrace(TraceDebug,__FUNCTION__ ": 7"); memset(&RomInfo, 0, sizeof(ROM_INFO)); stdstr_f zipFileName("%s?%s",(LPCSTR)SearchPath,FileName.c_str()); - //ZipFile.SetNotificationCallback((C7zip::LP7ZNOTIFICATION)NotificationCB,this); + ZipFile.SetNotificationCallback((C7zip::LP7ZNOTIFICATION)NotificationCB,this); strncpy(RomInfo.szFullFileName, zipFileName.c_str(), sizeof(RomInfo.szFullFileName) - 1); RomInfo.szFullFileName[sizeof(RomInfo.szFullFileName) - 1] = 0; @@ -1475,7 +1506,7 @@ void CRomBrowser::RomList_PopupMenu(DWORD /*pnmh*/) GetCursorPos(&Mouse); //Show the menu - TrackPopupMenu(hPopupMenu, 0, Mouse.x, Mouse.y, 0,(HWND)m_MainWindow, NULL); + TrackPopupMenu(hPopupMenu, 0, Mouse.x, Mouse.y, 0,m_MainWindow, NULL); DestroyMenu(hMenu); } @@ -1577,7 +1608,8 @@ int CALLBACK CRomBrowser::SelectRomDirCallBack(HWND hwnd,DWORD uMsg,DWORD /*lp*/ // It would be FALSE if you were passing a pidl. if (lpData) { - SendMessage((HWND)hwnd,BFFM_SETSELECTION,TRUE,lpData); + SendMessage(hwnd,BFFM_SETSELECTION,TRUE,lpData); + SetWindowTextW(hwnd, GS(DIR_SELECT_ROM)); } break; } @@ -1586,24 +1618,21 @@ int CALLBACK CRomBrowser::SelectRomDirCallBack(HWND hwnd,DWORD uMsg,DWORD /*lp*/ void CRomBrowser::SelectRomDir(void) { - char SelectedDir[MAX_PATH]; + wchar_t SelectedDir[MAX_PATH]; LPITEMIDLIST pidl; - BROWSEINFO bi; - - stdstr WindowTitle; - WindowTitle.FromUTF16(GS(SELECT_ROM_DIR)); + BROWSEINFOW bi; WriteTrace(TraceDebug,__FUNCTION__ " 1"); stdstr RomDir = g_Settings->LoadString(Directory_Game); - bi.hwndOwner = (HWND)m_MainWindow; + bi.hwndOwner = m_MainWindow; bi.pidlRoot = NULL; bi.pszDisplayName = SelectedDir; - bi.lpszTitle = WindowTitle.c_str(); + bi.lpszTitle = GS(SELECT_ROM_DIR); bi.ulFlags = BIF_RETURNFSANCESTORS | BIF_RETURNONLYFSDIRS; bi.lpfn = (BFFCALLBACK)SelectRomDirCallBack; bi.lParam = (DWORD)RomDir.c_str(); WriteTrace(TraceDebug,__FUNCTION__ " 2"); - if ((pidl = SHBrowseForFolder(&bi)) != NULL) + if ((pidl = SHBrowseForFolderW(&bi)) != NULL) { WriteTrace(TraceDebug,__FUNCTION__ " 3"); char Directory[_MAX_PATH]; @@ -1632,11 +1661,11 @@ void CRomBrowser::FixRomListWindow (void) { //Change the window Style long Style = GetWindowLong(m_MainWindow,GWL_STYLE) | WS_SIZEBOX | WS_MAXIMIZEBOX; - SetWindowLong((HWND)m_MainWindow,GWL_STYLE,Style); + SetWindowLong(m_MainWindow,GWL_STYLE,Style); //Get the current window size RECT rect; - GetWindowRect((HWND)m_MainWindow, &rect); + GetWindowRect(m_MainWindow, &rect); //We find the middle position of the screen, we use this if theres no setting int X = (GetSystemMetrics(SM_CXSCREEN) - (rect.right - rect.left)) / 2; @@ -1660,12 +1689,12 @@ void CRomBrowser::FixRomListWindow (void) rcClient.bottom = Height; rcClient.left = 0; rcClient.right = Width; - AdjustWindowRect(&rcClient,GetWindowLong((HWND)m_MainWindow,GWL_STYLE),true); + AdjustWindowRect(&rcClient,GetWindowLong(m_MainWindow,GWL_STYLE),true); int WindowHeight = rcClient.bottom - rcClient.top; int WindowWidth = rcClient.right - rcClient.left; - SetWindowPos((HWND)m_MainWindow,NULL,0,0,WindowWidth,WindowHeight,SWP_NOMOVE|SWP_NOZORDER); + SetWindowPos(m_MainWindow,NULL,0,0,WindowWidth,WindowHeight,SWP_NOMOVE|SWP_NOZORDER); } void CRomBrowser::ShowRomList (void) @@ -1687,7 +1716,7 @@ void CRomBrowser::ShowRomList (void) m_Visible = true; RECT rcWindow; - if (GetClientRect((HWND)m_MainWindow,&rcWindow)) + if (GetClientRect(m_MainWindow,&rcWindow)) { ResizeRomList((WORD)rcWindow.right,(WORD)rcWindow.bottom); } @@ -1702,7 +1731,7 @@ void CRomBrowser::ShowRomList (void) void CRomBrowser::HideRomList (void) { if (!RomBrowserVisible()) { return; } - ShowWindow((HWND)m_MainWindow,SW_HIDE); + ShowWindow(m_MainWindow,SW_HIDE); SaveRomListColoumnInfo(); WatchThreadStop(); @@ -1714,28 +1743,28 @@ void CRomBrowser::HideRomList (void) EnableWindow((HWND)m_hRomList,FALSE); ShowWindow((HWND)m_hRomList,SW_HIDE); - if (g_Settings->LoadBool(RomBrowser_Maximized)) { ShowWindow((HWND)m_MainWindow,SW_RESTORE); } + if (g_Settings->LoadBool(RomBrowser_Maximized)) { ShowWindow(m_MainWindow,SW_RESTORE); } //Change the window style - long Style = GetWindowLong((HWND)m_MainWindow,GWL_STYLE) & ~(WS_SIZEBOX | WS_MAXIMIZEBOX); - SetWindowLong((HWND)m_MainWindow,GWL_STYLE,Style); + long Style = GetWindowLong(m_MainWindow,GWL_STYLE) & ~(WS_SIZEBOX | WS_MAXIMIZEBOX); + SetWindowLong(m_MainWindow,GWL_STYLE,Style); //Move window to correct location RECT rect; - GetWindowRect((HWND)m_MainWindow,&rect); + GetWindowRect(m_MainWindow,&rect); int X = (GetSystemMetrics( SM_CXSCREEN ) - (rect.right - rect.left)) / 2; int Y = (GetSystemMetrics( SM_CYSCREEN ) - (rect.bottom - rect.top)) / 2; g_Settings->LoadDword(UserInterface_MainWindowTop,(DWORD &)Y); g_Settings->LoadDword(UserInterface_MainWindowLeft,(DWORD &)X); - SetWindowPos((HWND)m_MainWindow,NULL,X,Y,0,0,SWP_NOZORDER|SWP_NOSIZE); + SetWindowPos(m_MainWindow,NULL,X,Y,0,0,SWP_NOZORDER|SWP_NOSIZE); //Mark the window as not visible m_Visible = false; //Make the main window visible again - ShowWindow((HWND)m_MainWindow,SW_SHOW); - BringWindowToTop((HWND)m_MainWindow); - PostMessage((HWND)m_MainWindow, WM_MAKE_FOCUS, 0,0 ); + ShowWindow(m_MainWindow,SW_SHOW); + BringWindowToTop(m_MainWindow); + PostMessage(m_MainWindow, WM_MAKE_FOCUS, 0,0 ); } bool CRomBrowser::RomDirNeedsRefresh ( void ) diff --git a/Source/Project64/User Interface/Settings/Settings Page - Directories.cpp b/Source/Project64/User Interface/Settings/Settings Page - Directories.cpp index a217f3653..a793e3ad3 100644 --- a/Source/Project64/User Interface/Settings/Settings Page - Directories.cpp +++ b/Source/Project64/User Interface/Settings/Settings Page - Directories.cpp @@ -63,7 +63,7 @@ int CALLBACK COptionsDirectoriesPage::SelectDirCallBack (HWND hwnd,DWORD uMsg,DW // It would be FALSE if you were passing a pidl. if (lpData) { - SendMessage((HWND)hwnd,BFFM_SETSELECTION,TRUE,lpData); + SendMessage(hwnd,BFFM_SETSELECTION,TRUE,lpData); } break; } diff --git a/Source/Project64/User Interface/Settings/Settings Page.h b/Source/Project64/User Interface/Settings/Settings Page.h index 5387f9ab6..f9a3581d0 100644 --- a/Source/Project64/User Interface/Settings/Settings Page.h +++ b/Source/Project64/User Interface/Settings/Settings Page.h @@ -55,7 +55,18 @@ protected: } bool Create(HWND hParent, const RECT & rcDispay) { - CDialogImpl::Create(hParent); + BOOL result = m_thunk.Init(NULL, NULL); + if (result == FALSE) + { + SetLastError(ERROR_OUTOFMEMORY); + return false; + } + + _AtlWinModule.AddCreateWndData(&m_thunk.cd, this); +#ifdef _DEBUG + m_bModal = false; +#endif //_DEBUG + m_hWnd = ::CreateDialogParamW(_AtlBaseModule.GetResourceInstance(), MAKEINTRESOURCEW(static_cast(this)->IDD), hParent, T::StartDialogProc, NULL); if (m_hWnd == NULL) { return false; diff --git a/Source/Project64/User Interface/UI Resources.rc b/Source/Project64/User Interface/UI Resources.rc index a75559c2d..e92dd3823 100644 --- a/Source/Project64/User Interface/UI Resources.rc +++ b/Source/Project64/User Interface/UI Resources.rc @@ -1,7 +1,7 @@ // Microsoft Visual C++ generated resource script. // #include "resource.h" -#include "Version.h" +#include "../Version.h" #define APSTUDIO_READONLY_SYMBOLS diff --git a/Source/Project64/User Interface/WTL Controls/PartialGroupBox.cpp b/Source/Project64/User Interface/WTL Controls/PartialGroupBox.cpp index 3885a1dbb..1772d2ab5 100644 --- a/Source/Project64/User Interface/WTL Controls/PartialGroupBox.cpp +++ b/Source/Project64/User Interface/WTL Controls/PartialGroupBox.cpp @@ -10,14 +10,30 @@ ****************************************************************************/ #include "stdafx.h" -BOOL CPartialGroupBox::Attach(HWND hWndNew) +BOOL CPartialGroupBox::Attach(HWND hWnd) { - return SubclassWindow(hWndNew); + ATLASSUME(m_hWnd == NULL); + ATLASSERT(::IsWindow(hWnd)); + + // Allocate the thunk structure here, where we can fail gracefully. + + BOOL result = m_thunk.Init(GetWindowProc(), this); + if (result == FALSE) + { + return FALSE; + } + WNDPROC pProc = m_thunk.GetWNDPROC(); + WNDPROC pfnWndProc = (WNDPROC)::SetWindowLongPtrW(hWnd, GWLP_WNDPROC, (LONG_PTR)pProc); + if (pfnWndProc == NULL) + return FALSE; + m_pfnSuperWindowProc = pfnWndProc; + m_hWnd = hWnd; + return TRUE; } BOOL CPartialGroupBox::AttachToDlgItem(HWND parent, UINT dlgID) { - return SubclassWindow(::GetDlgItem(parent,dlgID)); + return Attach(::GetDlgItem(parent,dlgID)); } void CPartialGroupBox::Draw3dLine(CPaintDC & dc, LPCRECT lpRect, COLORREF clrTopLeft, COLORREF /*clrBottomRight*/) @@ -48,11 +64,11 @@ void CPartialGroupBox::OnPaint(HDC /*hDC*/) dc.SetMapMode(MM_TEXT); dc.SelectBrush(GetSysColorBrush(COLOR_BTNFACE)); - TCHAR grptext[MAX_PATH]; - GetWindowText(grptext,MAX_PATH); + wchar_t grptext[500]; + GetWindowTextW(m_hWnd, grptext, sizeof(grptext) / sizeof(grptext[0])); CRect fontsizerect(0,0,0,0); - dc.DrawText(grptext,-1,fontsizerect,DT_SINGLELINE|DT_LEFT|DT_CALCRECT); + dc.DrawTextW(grptext, -1, fontsizerect, DT_SINGLELINE | DT_LEFT | DT_CALCRECT); CRect framerect(controlrect); framerect.top += (fontsizerect.Height())/2; @@ -71,7 +87,7 @@ void CPartialGroupBox::OnPaint(HDC /*hDC*/) Draw3dLine(dc,framerect,GetSysColor(COLOR_3DHILIGHT),GetSysColor(COLOR_3DSHADOW)); } - if(_tcslen(grptext)) + if (wcslen(grptext)) { CRect fontrect(controlrect); fontrect.bottom = controlrect.top+fontsizerect.Height(); @@ -100,7 +116,7 @@ void CPartialGroupBox::OnPaint(HDC /*hDC*/) dc.SetBkMode(OPAQUE); dc.SetBkColor(GetSysColor(COLOR_BTNFACE)); - dc.DrawText(grptext,-1,fontrect,DT_SINGLELINE|DT_LEFT); + dc.DrawTextW(grptext,-1,fontrect,DT_SINGLELINE|DT_LEFT); } } diff --git a/Source/Project64/User Interface/WTL Controls/PartialGroupBox.h b/Source/Project64/User Interface/WTL Controls/PartialGroupBox.h index 2ab7562a3..0a971f3da 100644 --- a/Source/Project64/User Interface/WTL Controls/PartialGroupBox.h +++ b/Source/Project64/User Interface/WTL Controls/PartialGroupBox.h @@ -25,7 +25,6 @@ public: { } - virtual ~CPartialGroupBox() { }