📄 warmmcfiletypes.cpp
字号:
#include "StdAfx.h"#include "WarMmcFileTypes.h" // class implementedusing namespace std;/////////////////////////////// PUBLIC ///////////////////////////////////////WarMmcFileTypes *WarMmcFileTypes::mpThis;//============================= LIFECYCLE ====================================WarMmcFileTypes::WarMmcFileTypes(){ if (NULL == mpThis) mpThis = this;}WarMmcFileTypes::~WarMmcFileTypes(){ if (mpThis == this) mpThis = NULL;}//============================= OPERATORS ====================================//============================= OPERATIONS ===================================void WarMmcFileTypes::Load(const WarWin32Registry& regPath){ // Get file types from registry war_registrypath_t module_path; module_path << regPath.GetPath().GetPath() << WAR_SYSSLASH << WAR_WINNT_REG_MODULES << WAR_SYSSLASH << WAR_WINNT_REG_FILE_SYSTEMS; WarWin32Registry fs_root; fs_root.Open(regPath.GetRootKey(), module_path); WarWin32Registry::keyname_list_t fs_list, st_list; fs_root.EnumKey(fs_list); for(WarWin32Registry::keyname_list_t::iterator P = fs_list.begin() ; P != fs_list.end() ; P++) { WarWin32Registry node; node.Create(regPath.GetRootKey(), fs_root.GetPath(P->c_str())); if (node.GetIntValue(WAR_WINNT_REG_ENABLE, false)) { WarMmcFileType file_type(P->c_str()); WarWin32Registry styles; styles.Create(regPath.GetRootKey(), node.GetPath(WAR_WINNT_REG_STYLES)); styles.EnumKey(st_list); file_type.mIsEnabled = node.GetIntValue(WAR_WINNT_REG_ENABLE, false); for(WarWin32Registry::keyname_list_t::iterator PP = st_list.begin() ; PP != st_list.end() ; PP++) { WarWin32Registry st_node; st_node.Create(regPath.GetRootKey(), styles.GetPath(PP->c_str())); WarMmcFileTypeStyle style(PP->c_str(), st_node.GetIntValue(WAR_WINNT_REG_PERMISSIONS)); file_type.mThemes.push_back(style); } mFileTypes.push_back(file_type); } }}const WarMmcFileType& WarMmcFileTypes::GetTypeFromName(LPCTSTR currentName) const throw(WarException) { if (!currentName || !*currentName) WarThrow(WarError(WAR_ERR_INVALID_ARGUMENT), NULL); WarMmcFileTypes::filetypes_t::const_iterator P = find( mFileTypes.begin(), mFileTypes.end(), currentName); if (mFileTypes.end () == P) WarThrow(WarError(WAR_ERR_OBJECT_NOT_FOUND), NULL); return *P;}void WarMmcFileTypes::UpdateComboBox(HWND hWnd, LPCTSTR currentName, war_uint32_t currentPerms, bool doResetContent) const throw(WarException){ if (doResetContent) ::SendMessage(hWnd, CB_RESETCONTENT, 0, 0); bool do_deselect = true; try { // Find the current node, based on name const WarMmcFileType& current_type = GetTypeFromName(currentName); // Do the update int index = 0; for(WarMmcFileType::themes_t::const_iterator P = current_type.mThemes.begin() ; P != current_type.mThemes.end() ; P++, index++) {#ifdef _DEBUG const WarMmcFileTypeStyle& style = *P;#endif if (doResetContent) { ::SendMessage(hWnd, CB_INSERTSTRING, index, (LPARAM)P->mName.c_str()); ::SendMessage(hWnd, CB_SETITEMDATA, index, P->mPerms); } if (P->mPerms == currentPerms) { ::SendMessage(hWnd, CB_SETCURSEL, index, 0); do_deselect = false; } } } catch(WarException) { } if (do_deselect) ::SendMessage(hWnd, CB_SETCURSEL, -1, 0);}//============================= ACCESS ===================================//============================= INQUIRY ===================================/////////////////////////////// PROTECTED ////////////////////////////////////////////////////////////////// PRIVATE ///////////////////////////////////
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -