本文整理汇总了C++中PWSprefs类的典型用法代码示例。如果您正苦于以下问题:C++ PWSprefs类的具体用法?C++ PWSprefs怎么用?C++ PWSprefs使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了PWSprefs类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int main(int argc, char **argv)
{
testing::InitGoogleTest(&argc, argv);
int rc = RUN_ALL_TESTS();
#ifdef WIN32
system("pause");
#endif
// Need to find these in order to delete them
PWSLog *pwslog = PWSLog::GetLog();
PWSprefs *pwsprefs = PWSprefs::GetInstance();
PWSrand *pwsrand = PWSrand::GetInstance();
pwsprefs->DeleteInstance();
pwslog->DeleteLog();
pwsrand->DeleteInstance();
// To stop Compiler warning C4189
pwsprefs = NULL;
pwslog = NULL;
pwsrand = NULL;
return rc;
}
示例2: sxOldDBPrefsString
void PasswordSafeFrame::OnPreferencesClick( wxCommandEvent& /* evt */ )
{
PWSprefs* prefs = PWSprefs::GetInstance();
const StringX sxOldDBPrefsString(prefs->Store());
COptions *window = new COptions(this);
if (window->ShowModal() == wxID_OK) {
StringX sxNewDBPrefsString(prefs->Store(true));
// Update system tray icon if visible so changes show up immediately
if (m_sysTray && prefs->GetPref(PWSprefs::UseSystemTray))
m_sysTray->ShowIcon();
if (!m_core.GetCurFile().empty() && !m_core.IsReadOnly() &&
m_core.GetReadFileVersion() == PWSfile::VCURRENT) {
if (sxOldDBPrefsString != sxNewDBPrefsString) {
Command *pcmd = DBPrefsCommand::Create(&m_core, sxNewDBPrefsString);
if (pcmd) {
//I don't know why notifications should ever be suspended, but that's how
//things were before I messed with them, so I want to limit the damage by
//enabling notifications only as long as required and no more
m_core.ResumeOnDBNotification();
Execute(pcmd); //deleted automatically
m_core.SuspendOnDBNotification();
}
}
}
}
window->Destroy();
}
示例3: TEST_F
TEST_F(ItemDataTest, PasswordHistory)
{
size_t pwh_max, num_err;
PWHistList pwhl;
const StringX pw1(L"banana-0rchid");
const StringX pw2(L"banana-1rchid");
const StringX pw3(L"banana-2rchid");
const StringX pw4(L"banana-5rchid");
PWSprefs *prefs = PWSprefs::GetInstance();
prefs->SetPref(PWSprefs::SavePasswordHistory, true);
prefs->SetPref(PWSprefs::NumPWHistoryDefault, 3);
CItemData di;
di.SetCTime();
di.SetPassword(pw1); // first time must be Set, not Update!
di.UpdatePassword(pw2);
EXPECT_FALSE(di.GetPWHistory().empty());
EXPECT_TRUE(CreatePWHistoryList(di.GetPWHistory(), pwh_max, num_err,
pwhl, PWSUtil::TMC_ASC_UNKNOWN));
EXPECT_EQ(0, num_err);
EXPECT_EQ(3, pwh_max);
EXPECT_EQ(1, pwhl.size());
EXPECT_EQ(pw1, pwhl[0].password);
di.UpdatePassword(pw3);
EXPECT_TRUE(CreatePWHistoryList(di.GetPWHistory(), pwh_max, num_err,
pwhl, PWSUtil::TMC_ASC_UNKNOWN));
EXPECT_EQ(0, num_err);
EXPECT_EQ(3, pwh_max);
EXPECT_EQ(2, pwhl.size());
EXPECT_EQ(pw1, pwhl[0].password);
EXPECT_EQ(pw2, pwhl[1].password);
di.UpdatePassword(pw4);
EXPECT_TRUE(CreatePWHistoryList(di.GetPWHistory(), pwh_max, num_err,
pwhl, PWSUtil::TMC_ASC_UNKNOWN));
EXPECT_EQ(0, num_err);
EXPECT_EQ(3, pwh_max);
EXPECT_EQ(3, pwhl.size());
EXPECT_EQ(pw1, pwhl[0].password);
EXPECT_EQ(pw2, pwhl[1].password);
EXPECT_EQ(pw3, pwhl[2].password);
di.UpdatePassword(L"Last1");
EXPECT_TRUE(CreatePWHistoryList(di.GetPWHistory(), pwh_max, num_err,
pwhl, PWSUtil::TMC_ASC_UNKNOWN));
EXPECT_EQ(0, num_err);
EXPECT_EQ(3, pwh_max);
EXPECT_EQ(3, pwhl.size());
EXPECT_EQ(pw2, pwhl[0].password);
EXPECT_EQ(pw3, pwhl[1].password);
EXPECT_EQ(pw4, pwhl[2].password);
}
示例4: CAddEdit_PropertyPage
CAddEdit_Basic::CAddEdit_Basic(CWnd *pParent, st_AE_master_data *pAEMD)
: CAddEdit_PropertyPage(pParent,
CAddEdit_Basic::IDD, CAddEdit_Basic::IDD_SHORT,
pAEMD),
m_bInitdone(false), m_thread(NULL), m_isNotesHidden(false)
{
if (CS_SHOW.IsEmpty()) { // one-time initializations
HIDDEN_NOTES.LoadString(IDS_HIDDENNOTES);
CS_SHOW.LoadString(IDS_SHOWPASSWORDTXT);
CS_HIDE.LoadString(IDS_HIDEPASSWORDTXT);
}
PWSprefs *prefs = PWSprefs::GetInstance();
// Setup
m_bWordWrap = prefs->GetPref(PWSprefs::NotesWordWrap);
m_password = m_password2 = M_realpassword();
m_notes = M_realnotes().Left(MAXTEXTCHARS);
// Set up right-click Notes context menu additions
std::vector<st_context_menu> vmenu_items;
st_context_menu st_cm;
std::wstring cs_menu_string;
LoadAString(cs_menu_string, IDS_WORD_WRAP);
st_cm.menu_string = cs_menu_string;
st_cm.message_number = PWS_MSG_EDIT_WORDWRAP;
st_cm.flags = m_bWordWrap ? MF_CHECKED : MF_UNCHECKED;
vmenu_items.push_back(st_cm);
st_cm.Empty();
LoadAString(cs_menu_string, IDS_NOTESZOOMIN);
st_cm.menu_string = cs_menu_string;
st_cm.message_number = PWS_MSG_CALL_NOTESZOOMIN;
st_cm.flags = 0;
st_cm.lParam = 1;
vmenu_items.push_back(st_cm);
st_cm.Empty();
LoadAString(cs_menu_string, IDS_NOTESZOOMOUT);
st_cm.menu_string = cs_menu_string;
st_cm.message_number = PWS_MSG_CALL_NOTESZOOMOUT;
st_cm.flags = 0;
st_cm.lParam = -1;
vmenu_items.push_back(st_cm);
st_cm.Empty();
LoadAString(cs_menu_string, IDS_EDITEXTERNALLY);
st_cm.menu_string = cs_menu_string;
st_cm.message_number = PWS_MSG_CALL_EXTERNAL_EDITOR;
st_cm.flags = 0;
vmenu_items.push_back(st_cm);
m_ex_notes.SetContextMenu(vmenu_items);
}
示例5: currbackup
//////////////////////////////////////////
// Backup and Restore
//
void PasswordSafeFrame::OnBackupSafe(wxCommandEvent& /*evt*/)
{
PWSprefs *prefs = PWSprefs::GetInstance();
const wxFileName currbackup(towxstring(prefs->GetPref(PWSprefs::CurrentBackup)));
const wxString title(_("Please Choose a Name for this Backup:"));
wxString dir;
if (m_core.GetCurFile().empty())
dir = towxstring(PWSdirs::GetSafeDir());
else {
wxFileName::SplitPath(towxstring(m_core.GetCurFile()), &dir, NULL, NULL);
wxCHECK_RET(!dir.IsEmpty(), _("Could not parse current file path"));
}
//returns empty string if user cancels
wxString wxbf = wxFileSelector(title,
dir,
currbackup.GetFullName(),
wxT("bak"),
_("Password Safe Backups (*.bak)|*.bak"),
wxFD_SAVE|wxFD_OVERWRITE_PROMPT,
this);
/*
The wxFileSelector code says it appends the default extension if user
doesn't type one, but it actually doesn't and I don't see the purported
code in 2.8.10. And doing it ourselves after the dialog has returned is
risky because we might silently overwrite an existing file
*/
//create a copy to avoid multiple conversions to StringX
const StringX backupfile(tostringx(wxbf));
#ifdef NOT_YET
if (m_inExit) {
// If U3ExitNow called while in CPWFileDialog,
// PostQuitMessage makes us return here instead
// of exiting the app. Try resignalling
PostQuitMessage(0);
return PWScore::USER_CANCEL;
}
#endif
if (!backupfile.empty()) { //i.e. if user didn't cancel
if (m_core.WriteFile(backupfile, m_core.GetReadFileVersion(),
false) == PWScore::CANT_OPEN_FILE) {
wxMessageBox( wxbf << wxT("\n\n") << _("Could not open file for writing!"),
_("Write Error"), wxOK|wxICON_ERROR, this);
}
prefs->SetPref(PWSprefs::CurrentBackup, backupfile);
}
}
示例6: recentDatabases
int PwsafeApp::OnExit()
{
m_idleTimer->Stop();
recentDatabases().Save();
PWSprefs *prefs = PWSprefs::GetInstance();
if (!m_core.GetCurFile().empty())
prefs->SetPref(PWSprefs::CurrentFile, m_core.GetCurFile());
// Save Application related preferences
prefs->SaveApplicationPreferences();
// Save shortcuts, if changed
PWSMenuShortcuts::GetShortcutsManager()->SaveUserShortcuts();
PWSMenuShortcuts::DestroyShortcutsManager();
////@begin PwsafeApp cleanup
return wxApp::OnExit();
////@end PwsafeApp cleanup
}
示例7: UpdateItem
//Just update the item's text, don't move it into its sorted position
void PWSTreeCtrl::UpdateItemField(const CItemData &item, CItemData::FieldType ft)
{
PWSprefs* prefs = PWSprefs::GetInstance();
if (ft == CItemData::GROUP) {
//remove & add again
UpdateItem(item);
}
//these are the only items ever shown in the tree
else if (ft == CItemData::TITLE || ft == CItemData::START ||
(ft == CItemData::USER && prefs->GetPref(PWSprefs::ShowUsernameInTree)) ||
(ft == CItemData::PASSWORD && prefs->GetPref(PWSprefs::ShowPasswordInTree))) {
wxRect rc;
wxTreeItemId ti = Find(item);
if (ti.IsOk()) {
SetItemText(ti, ItemDisplayString(item));
}
}
}
示例8: ReadList
void CPWSRecentFileList::ReadList()
{
PWSprefs *pref = PWSprefs::GetInstance();
// reads from registry or config file
if (pref->IsUsingRegistry()) {
CRecentFileList::ReadList();
} else {
const int nMRUItems = pref->GetPref(PWSprefs::MaxMRUItems);
ASSERT(nMRUItems == m_nSize);
std::wstring *arrNames = new std::wstring[nMRUItems];
pref->GetMRUList(arrNames);
for (int i = 0; i < nMRUItems; i++) {
std::wstring path = arrNames[i].c_str();
pws_os::AddDrive(path);
m_arrNames[i] = path.c_str();
}
delete[] arrNames;
}
}
示例9: wxT
wxString PWSTreeCtrl::ItemDisplayString(const CItemData &item) const
{
PWSprefs *prefs = PWSprefs::GetInstance();
const wxString title = item.GetTitle().c_str();
wxString disp = title;
if (prefs->GetPref(PWSprefs::ShowUsernameInTree)) {
const wxString user = item.GetUser().c_str();
if (!user.empty())
disp += wxT(" [") + user + wxT("]");
}
if (prefs->GetPref(PWSprefs::ShowPasswordInTree)) {
const wxString passwd = item.GetPassword().c_str();
if (!passwd.empty())
disp += wxT(" {") + passwd + wxT("}");
}
return disp;
}
示例10: RelativizePath
void CPWSRecentFileList::WriteList()
{
extern void RelativizePath(stringT &);
PWSprefs *pref = PWSprefs::GetInstance();
// writes to registry or config file
if (pref->IsUsingRegistry()) {
CRecentFileList::WriteList();
} else {
const int num_MRU = GetSize();
const int max_MRU = ID_FILE_MRU_ENTRYMAX - ID_FILE_MRU_ENTRY1;
std::wstring *csMRUFiles = new std::wstring[num_MRU];
for (int i = 0; i < num_MRU; i++) {
csMRUFiles[i] = (*this)[i];
if (!csMRUFiles[i].empty()) {
Trim(csMRUFiles[i]);
RelativizePath(csMRUFiles[i]);
}
}
pref->SetMRUList(csMRUFiles, num_MRU, max_MRU);
delete[] csMRUFiles;
}
}
示例11: wsCO
BOOL COptionsSystem::OnInitDialog()
{
COptions_PropertyPage::OnInitDialog();
PWSprefs *prefs = PWSprefs::GetInstance();
PWSprefs::ConfigOption configoption;
StringX sx_CF = prefs->GetConfigFile(configoption).c_str();
std::wstring wsCO(L"");
switch (configoption) {
case PWSprefs::CF_NONE:
LoadAString(sx_CF, IDS_NONE);
break;
case PWSprefs::CF_REGISTRY:
LoadAString(sx_CF, IDS_REGISTRY);
break;
case PWSprefs::CF_FILE_RO:
LoadAString(wsCO, IDS_READ_ONLY);
break;
case PWSprefs::CF_FILE_RW:
case PWSprefs::CF_FILE_RW_NEW:
LoadAString(wsCO, IDS_READ_WRITE);
break;
default:
ASSERT(0);
}
CString cs_text;
// R/W status
GetDlgItem(IDC_STATIC_RWSTATUS)->SetWindowText(wsCO.c_str());
// Config file name & location
cs_text = PWSUtil::NormalizeTTT(sx_CF, 60).c_str();
GetDlgItem(IDC_CONFIGFILE)->SetWindowText(cs_text);
// Effective host & user used in config file
if (configoption == PWSprefs::CF_FILE_RO ||
configoption == PWSprefs::CF_FILE_RW ||
configoption == PWSprefs::CF_FILE_RW_NEW) {
stringT hn = SysInfo::GetInstance()->GetEffectiveHost();
PWSprefs::XMLify(charT('H'), hn);
stringT un = SysInfo::GetInstance()->GetEffectiveUser();
PWSprefs::XMLify(charT('u'), un);
cs_text.Format(IDS_HOSTUSER, static_cast<LPCWSTR>(hn.c_str()), static_cast<LPCWSTR>(un.c_str()));
GetDlgItem(IDC_STATIC_HOSTUSER)->SetWindowText(cs_text);
}
bool bofferdeleteregistry = prefs->OfferDeleteRegistry();
bool boffermigrate2appdata = OfferConfigMigration();
if (!bofferdeleteregistry) {
GetDlgItem(IDC_REGDEL)->ShowWindow(SW_HIDE);
GetDlgItem(IDC_REGDEL)->EnableWindow(FALSE);
}
if (!boffermigrate2appdata) {
GetDlgItem(IDC_MIGRATETOAPPDATA)->ShowWindow(SW_HIDE);
GetDlgItem(IDC_MIGRATETOAPPDATA)->EnableWindow(FALSE);
}
if (!bofferdeleteregistry && !boffermigrate2appdata) {
GetDlgItem(IDC_CONFIG_GRP)->ShowWindow(SW_HIDE);
GetDlgItem(IDC_APPLYCONFIGCHANGES)->ShowWindow(SW_HIDE);
} else {
GetDlgItem(IDC_APPLYCONFIGCHANGES)->ShowWindow(SW_SHOW);
}
GetDlgItem(IDC_APPLYCONFIGCHANGES)->EnableWindow(FALSE);
CSpinButtonCtrl *pspin = (CSpinButtonCtrl *)GetDlgItem(IDC_RESPIN);
pspin->SetBuddy(GetDlgItem(IDC_MAXREITEMS));
pspin->SetRange(M_prefminREItems(), M_prefmaxREItems());
pspin->SetBase(10);
pspin->SetPos(m_MaxREItems);
pspin = (CSpinButtonCtrl *)GetDlgItem(IDC_MRUSPIN);
pspin->SetBuddy(GetDlgItem(IDC_MAXMRUITEMS));
pspin->SetRange(M_prefminMRU(), M_prefmaxMRU());
pspin->SetBase(10);
pspin->SetPos(m_MaxMRUItems);
OnUseSystemTray();
if (InitToolTip(TTS_BALLOON | TTS_NOPREFIX, 0)) {
m_Help1.Init(IDB_QUESTIONMARK);
m_Help2.Init(IDB_QUESTIONMARK);
// Note naming convention: string IDS_xxx corresponds to control IDC_xxx_HELP
AddTool(IDC_REGDELHELP, IDS_REGDEL);
AddTool(IDC_MIGRATETOAPPDATAHELP, IDS_MIGRATETOAPPDATA);
ActivateToolTip();
} else {
m_Help1.EnableWindow(FALSE);
m_Help1.ShowWindow(SW_HIDE);
m_Help2.EnableWindow(FALSE);
m_Help2.ShowWindow(SW_HIDE);
}
//.........这里部分代码省略.........
示例12: SetAppName
bool PwsafeApp::OnInit()
{
//Used by help subsystem
wxFileSystem::AddHandler(new wxArchiveFSHandler);
SetAppName(pwsafeAppName);
m_core.SetApplicationNameAndVersion(tostdstring(pwsafeAppName),
DWORD((MINORVERSION << 16) | MAJORVERSION));
PWSprefs::SetReporter(&aReporter);
PWScore::SetReporter(&aReporter);
PWScore::SetAsker(&anAsker);
#if wxUSE_XPM
wxImage::AddHandler(new wxXPMHandler);
#endif
#if wxUSE_LIBPNG
wxImage::AddHandler(new wxPNGHandler);
#endif
#if wxUSE_LIBJPEG
wxImage::AddHandler(new wxJPEGHandler);
#endif
#if wxUSE_GIF
wxImage::AddHandler(new wxGIFHandler);
#endif
// Get progname
wxString progName(argv[0]);
progName = progName.AfterLast(wxChar('/'));
// Parse command line
wxCmdLineParser cmdParser(cmdLineDesc, argc, argv);
int res = cmdParser.Parse();
if (res != 0)
return false;
// Don't allow ptrace or gdump on release build
if (!pws_os::DisableDumpAttach())
return false;
// Parse command line options:
wxString filename, user, host, cfg_file;
bool cmd_ro = cmdParser.Found(wxT("r"));
// Next variable currently not referenced
bool cmd_encrypt = cmdParser.Found(wxT("e"), &filename);
bool cmd_decrypt = cmdParser.Found(wxT("d"), &filename);
bool cmd_closed = cmdParser.Found(wxT("c"));
bool cmd_silent = cmdParser.Found(wxT("s"));
bool cmd_minimized = cmdParser.Found(wxT("m"));
bool cmd_user = cmdParser.Found(wxT("u"), &user);
bool cmd_host = cmdParser.Found(wxT("h"), &host);
bool cmd_cfg = cmdParser.Found(wxT("g"), &cfg_file);
bool file_in_cmd = false;
size_t count = cmdParser.GetParamCount();
if (count == 1) {
filename = cmdParser.GetParam();
file_in_cmd = true;
}
else if (count > 1) {
cmdParser.Usage();
return false;
}
// check for mutually exclusive options
if (((cmd_encrypt + cmd_decrypt) > 1) ||
((cmd_closed + cmd_silent + cmd_minimized) > 1)) {
cmdParser.Usage();
return false;
}
if (cmd_user)
SysInfo::GetInstance()->SetEffectiveUser(tostdstring(user));
if (cmd_host)
SysInfo::GetInstance()->SetEffectiveHost(tostdstring(host));
if (cmd_cfg)
PWSprefs::SetConfigFile(tostdstring(cfg_file));
m_core.SetReadOnly(cmd_ro);
// OK to load prefs now
PWSprefs *prefs = PWSprefs::GetInstance();
// Initialize language only after parsing cmd_cfg and instantiating prefs,
// otherwise GetSelectedLanguage()&Co will instantiate prefs singleton and it
// will ignore config file parameter
wxLanguage selectedLang = GetSelectedLanguage();
m_locale->Init(selectedLang);
ActivateLanguage(selectedLang, false);
// if filename passed in command line, it takes precedence
// over that in preference:
if (filename.empty()) {
filename = prefs->GetPref(PWSprefs::CurrentFile).c_str();
} else {
recentDatabases().AddFileToHistory(filename);
}
m_core.SetCurFile(tostringx(filename));
m_core.SetApplicationNameAndVersion(tostdstring(progName),
MAKEWORD(MINORVERSION, MAJORVERSION));
static wxSingleInstanceChecker appInstance;
if (!prefs->GetPref(PWSprefs::MultipleInstances) &&
(appInstance.Create(wxT("pwsafe.lck"), towxstring(pws_os::getuserprefsdir())) &&
appInstance.IsAnotherRunning()))
{
//.........这里部分代码省略.........
示例13: GetDlgItem
BOOL COptionsSystem::OnInitDialog()
{
COptions_PropertyPage::OnInitDialog();
PWSprefs *prefs = PWSprefs::GetInstance();
if (!m_bShowConfigFile) {
GetDlgItem(IDC_STATIC_CONFIGFILE)->ShowWindow(SW_HIDE);
GetDlgItem(IDC_STATIC_RWSTATUS)->ShowWindow(SW_HIDE);
GetDlgItem(IDC_CONFIGFILE)->ShowWindow(SW_HIDE);
} else {
PWSprefs::ConfigOption configoption;
std::wstring wsCF = prefs->GetConfigFile(configoption);
std::wstring wsCO(L"");
switch (configoption) {
case PWSprefs::CF_NONE:
LoadAString(wsCF, IDS_NONE);
break;
case PWSprefs::CF_REGISTRY:
LoadAString(wsCF, IDS_REGISTRY);
break;
case PWSprefs::CF_FILE_RO:
LoadAString(wsCO, IDS_READ_ONLY);
break;
case PWSprefs::CF_FILE_RW:
case PWSprefs::CF_FILE_RW_NEW:
LoadAString(wsCO, IDS_READ_WRITE);
break;
default:
ASSERT(0);
}
GetDlgItem(IDC_CONFIGFILE)->SetWindowText(wsCF.c_str());
GetDlgItem(IDC_STATIC_RWSTATUS)->SetWindowText(wsCO.c_str());
}
bool bofferdeleteregistry = prefs->OfferDeleteRegistry();
bool boffermigrate2appdata = OfferConfigMigration();
if (!bofferdeleteregistry) {
GetDlgItem(IDC_REGDEL)->ShowWindow(SW_HIDE);
GetDlgItem(IDC_REGDEL)->EnableWindow(FALSE);
}
if (!boffermigrate2appdata) {
GetDlgItem(IDC_MIGRATETOAPPDATA)->ShowWindow(SW_HIDE);
GetDlgItem(IDC_MIGRATETOAPPDATA)->EnableWindow(FALSE);
}
if (!bofferdeleteregistry && !boffermigrate2appdata) {
GetDlgItem(IDC_CONFIG_GRP)->ShowWindow(SW_HIDE);
GetDlgItem(IDC_APPLYCONFIGCHANGES)->ShowWindow(SW_HIDE);
} else {
GetDlgItem(IDC_APPLYCONFIGCHANGES)->ShowWindow(SW_SHOW);
}
GetDlgItem(IDC_APPLYCONFIGCHANGES)->EnableWindow(FALSE);
CSpinButtonCtrl *pspin = (CSpinButtonCtrl *)GetDlgItem(IDC_RESPIN);
pspin->SetBuddy(GetDlgItem(IDC_MAXREITEMS));
pspin->SetRange(0, ID_TRAYRECENT_ENTRYMAX - ID_TRAYRECENT_ENTRY1 + 1);
pspin->SetBase(10);
pspin->SetPos(m_MaxREItems);
pspin = (CSpinButtonCtrl *)GetDlgItem(IDC_MRUSPIN);
pspin->SetBuddy(GetDlgItem(IDC_MAXMRUITEMS));
pspin->SetRange(0, ID_FILE_MRU_ENTRYMAX - ID_FILE_MRU_ENTRY1 + 1);
pspin->SetBase(10);
pspin->SetPos(m_MaxMRUItems);
OnUseSystemTray();
InitToolTip(TTS_BALLOON | TTS_NOPREFIX, 2);
AddTool(IDC_REGDEL, IDS_REGDEL);
AddTool(IDC_MIGRATETOAPPDATA, IDS_MIGRATETOAPPDATA);
ActivateToolTip();
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
示例14: ModifyStyleEx
BOOL CAddEdit_Basic::OnInitDialog()
{
CAddEdit_PropertyPage::OnInitDialog();
ModifyStyleEx(0, WS_EX_CONTROLPARENT);
Fonts *pFonts = Fonts::GetInstance();
pFonts->ApplyPasswordFont(GetDlgItem(IDC_PASSWORD));
pFonts->ApplyPasswordFont(GetDlgItem(IDC_PASSWORD2));
// Need to get change notifcations
m_ex_notes.SetEventMask(ENM_CHANGE | m_ex_notes.GetEventMask());
// Set plain text - not that it seems to do much!
m_ex_notes.SetTextMode(TM_PLAINTEXT);
PWSprefs *prefs = PWSprefs::GetInstance();
// Set Notes font!
if (prefs->GetPref(PWSprefs::NotesFont).empty()) {
m_ex_notes.SetFont(pFonts->GetCurrentFont());
} else {
m_ex_notes.SetFont(pFonts->GetNotesFont());
}
if (M_uicaller() == IDS_EDITENTRY && M_protected() != 0) {
GetDlgItem(IDC_STATIC_PROTECTED)->ShowWindow(SW_SHOW);
m_stc_protected.SetColour(RGB(255,0,0));
}
if (M_uicaller() != IDS_ADDENTRY) {
InitToolTip();
AddTool(IDC_STATIC_GROUP, IDS_CLICKTOCOPY);
AddTool(IDC_STATIC_TITLE, IDS_CLICKTOCOPY);
AddTool(IDC_STATIC_USERNAME, IDS_CLICKTOCOPY);
AddTool(IDC_STATIC_PASSWORD, IDS_CLICKTOCOPY);
AddTool(IDC_STATIC_NOTES, IDS_CLICKTOCOPY);
AddTool(IDC_STATIC_URL, IDS_CLICKTOCOPY);
AddTool(IDC_STATIC_EMAIL, IDS_CLICKTOCOPYPLUS1);
AddTool(IDC_LAUNCH, IDS_CLICKTOGOPLUS);
AddTool(IDC_SENDEMAIL, IDS_CLICKTOSEND);
if (M_uicaller() == IDS_EDITENTRY && M_protected() != 0) {
AddTool(IDC_STATIC_PROTECTED, IDS_UNPROTECT);
}
ActivateToolTip();
m_stc_group.SetHighlight(true, CAddEdit_PropertyPage::crefWhite);
m_stc_title.SetHighlight(true, CAddEdit_PropertyPage::crefWhite);
m_stc_username.SetHighlight(true, CAddEdit_PropertyPage::crefWhite);
m_stc_password.SetHighlight(true, CAddEdit_PropertyPage::crefWhite);
m_stc_notes.SetHighlight(true, CAddEdit_PropertyPage::crefWhite);
m_stc_URL.SetHighlight(true, CAddEdit_PropertyPage::crefWhite);
m_stc_email.SetHighlight(true, CAddEdit_PropertyPage::crefWhite);
}
m_ex_group.ChangeColour();
GetDlgItem(IDC_LAUNCH)->EnableWindow(M_URL().IsEmpty() ? FALSE : TRUE);
GetDlgItem(IDC_SENDEMAIL)->EnableWindow(M_email().IsEmpty() ? FALSE : TRUE);
if (M_uicaller() == IDS_VIEWENTRY ||
(M_uicaller() == IDS_EDITENTRY && M_protected() != 0)) {
// Change 'OK' to 'Close' and disable 'Cancel'
// "CancelToClose" disables the System Command SC_CLOSE
// from clicking X on PropertySheet so have implemented
// CAddEdit_PropertySheet::OnSysCommand to deal with it.
CancelToClose();
// Disable Group Combo
GetDlgItem(IDC_GROUP)->EnableWindow(FALSE);
// Disable normal Edit controls
GetDlgItem(IDC_TITLE)->SendMessage(EM_SETREADONLY, TRUE, 0);
GetDlgItem(IDC_USERNAME)->SendMessage(EM_SETREADONLY, TRUE, 0);
GetDlgItem(IDC_PASSWORD)->SendMessage(EM_SETREADONLY, TRUE, 0);
GetDlgItem(IDC_PASSWORD2)->SendMessage(EM_SETREADONLY, TRUE, 0);
GetDlgItem(IDC_NOTES)->SendMessage(EM_SETREADONLY, TRUE, 0);
GetDlgItem(IDC_URL)->SendMessage(EM_SETREADONLY, TRUE, 0);
GetDlgItem(IDC_EMAIL)->SendMessage(EM_SETREADONLY, TRUE, 0);
// Disable Button
GetDlgItem(IDC_GENERATEPASSWORD)->EnableWindow(FALSE);
}
// Populate the combo box
m_ex_group.ResetContent(); // groups might be from a previous DB (BR 3062758)
// The core function "GetUniqueGroups(vGroups)" returns the group list by
// going through the entries in the database. This will not include empty
// groups. However, we already maintain this list in the UI to save the
// display status, so use this instead.
std::vector<std::wstring> vGroups;
GetMainDlg()->GetAllGroups(vGroups);
for (std::vector<std::wstring>::iterator iter = vGroups.begin();
iter != vGroups.end(); ++iter) {
m_ex_group.AddString(iter->c_str());
}
//.........这里部分代码省略.........
示例15: CPWPropertySheet
CAddEdit_PropertySheet::CAddEdit_PropertySheet(UINT nID, CWnd* pParent,
PWScore *pcore,
CItemData *pci_original, CItemData *pci,
const bool bLongPPs,
const StringX currentDB)
: CPWPropertySheet(nID, pParent, bLongPPs), m_bIsModified(false), m_bChanged(false),
m_bNotesChanged(false), m_bSymbolsChanged(false)
{
m_AEMD.bLongPPs = bLongPPs;
m_AEMD.uicaller = nID;
ASSERT(pParent != NULL);
ASSERT(pcore != NULL);
ASSERT(pci != NULL);
m_AEMD.pcore = pcore;
m_AEMD.pci_original = pci_original;
m_AEMD.pci = pci;
m_AEMD.currentDB = currentDB;
PWSprefs *prefs = PWSprefs::GetInstance();
m_AEMD.default_pwp = prefs->GetDefaultPolicy();
m_AEMD.default_symbols = prefs->GetPref(PWSprefs::DefaultSymbols);
// Set up data used by all Property Pages, as appropriate
if (m_AEMD.uicaller == IDS_ADDENTRY) {
// Basic initialisation
m_AEMD.group = L"";
m_AEMD.title = L"";
m_AEMD.username = L"";
m_AEMD.realpassword = L"";
m_AEMD.realnotes = m_AEMD.originalrealnotesTRC = L"";
m_AEMD.URL = L"";
m_AEMD.email = L"";
m_AEMD.symbols = m_AEMD.oldsymbols = L"";
m_AEMD.num_dependents = 0;
// Entry type initialisation
m_AEMD.original_entrytype = CItemData::ET_NORMAL;
// Additional initialisation
m_AEMD.autotype = L"";
m_AEMD.runcommand = L"";
m_AEMD.oldDCA = m_AEMD.DCA = m_AEMD.oldShiftDCA = m_AEMD.ShiftDCA = -1;
// Date & Time initialisation
m_AEMD.locCTime.LoadString(IDS_NA);
m_AEMD.locXTime = m_AEMD.locATime = m_AEMD.locRMTime = m_AEMD.locPMTime =
m_AEMD.oldlocXTime = m_AEMD.locCTime;
m_AEMD.tttXTime = m_AEMD.tttCPMTime = (time_t)0;
m_AEMD.oldXTimeInt = m_AEMD.XTimeInt = 0;
// PWHistory initialisation
m_AEMD.SavePWHistory = m_AEMD.oldSavePWHistory =
PWSprefs::GetInstance()->GetPref(PWSprefs::SavePasswordHistory) ? TRUE : FALSE;
m_AEMD.MaxPWHistory = m_AEMD.oldMaxPWHistory =
PWSprefs::GetInstance()->GetPref(PWSprefs::NumPWHistoryDefault);
m_AEMD.NumPWHistory = m_AEMD.oldNumPWHistory = 0;
// PWPolicy fields
m_AEMD.pwp = m_AEMD.oldpwp = m_AEMD.default_pwp;
m_AEMD.ipolicy = m_AEMD.oldipolicy = DEFAULT_POLICY;
m_AEMD.iownsymbols = m_AEMD.ioldownsymbols = DEFAULT_SYMBOLS;
m_AEMD.symbols = L"";
m_AEMD.policyname = m_AEMD.oldpolicyname = L"";
// Protected
m_AEMD.ucprotected = 0;
// Entry Keyboard shortcut
m_AEMD.oldKBShortcut = m_AEMD.KBShortcut = 0;
} else {
SetupInitialValues();
}
// Only now allocate the PropertyPages - after all data there
// to be used by their c'tors
m_pp_basic = new CAddEdit_Basic(this, &m_AEMD);
m_pp_additional = new CAddEdit_Additional(this, &m_AEMD);
m_pp_datetimes = new CAddEdit_DateTimes(this, &m_AEMD);
m_pp_pwpolicy = new CAddEdit_PasswordPolicy(this, &m_AEMD);
if (pcore->GetReadFileVersion() == PWSfile::V40)
m_pp_attachment = new CAddEdit_Attachment(this, &m_AEMD);
else
m_pp_attachment = NULL;
AddPage(m_pp_basic);
AddPage(m_pp_additional);
AddPage(m_pp_datetimes);
AddPage(m_pp_pwpolicy);
if (pcore->GetReadFileVersion() == PWSfile::V40)
AddPage(m_pp_attachment);
}