예제 #1
0
void CArborEditCurrency::DoDataExchange(CDataExchange* pDX) 
{

  // Put the numeric value in the text field
	SetWindowText(ArbI18N::translateFromUTF8( GetFormattedString()));  //CAMqa75092

	if( pDX->m_bSaveAndValidate	)
	{
    // check to see if any value has been entered into the control....
		if( !IsNumericZero() )
    {
      // then do validation
      DDV_Float();	
    }
	
	  if( IsNumericZero() && m_bIsRequiredField )
	  {
		  CString sMsg;
		  
		  //sMsg.Format( "This is a required field" );
		  sMsg.Format( GetIntlString(IDS_REQD_FIELD_MSG) );
		  AfxMessageBox( sMsg, MB_ICONEXCLAMATION );
		  SetFocus();
		  AfxThrowUserException();   
	  }
  }

	CEdit::DoDataExchange(pDX);
}
예제 #2
0
void CArborEditCurrency::SetNumeric(Arb_numeric &nNumeric)
{
	// first set the member
	CArborCurrency::SetNumeric(nNumeric);

	// then show the formatted string in the edit control
	SetWindowText( ArbI18N::translateFromUTF8(GetFormattedString()));  //CAMqa75092
}
예제 #3
0
//	////////////////////////////////////////////////////////////////////////////
std::ostream & operator << (std::ostream &o_str,
	const LbmConfigOptionList &datum)
{
	o_str
		<< GetFormattedString(datum)
			;

	return(o_str);
}
예제 #4
0
Arb_numeric *CArborEditCurrency::SetNumeric(LPCTSTR lpszMoneyStr)
{
	// first set the member
	CArborCurrency::SetNumeric(lpszMoneyStr);

	// then show the formatted string in the edit control
	SetWindowText( ArbI18N::translateFromUTF8(GetFormattedString()));  //CAMqa75092

  return &m_nNumeric;
}
예제 #5
0
void Logger::DeleteLogFile()
{
	const WCHAR* filePath = m_LogFilePath.c_str();
	if (_waccess(filePath, 0) != -1)
	{
		const std::wstring text = GetFormattedString(ID_STR_LOGFILEDELETE, filePath);
		const int res = GetRainmeter().ShowMessage(nullptr, text.c_str(), MB_YESNO | MB_ICONQUESTION);
		if (res == IDYES)
		{
			SetLogToFile(false);
			System::RemoveFile(m_LogFilePath);
		}
	}
}
예제 #6
0
void Logger::StartLogFile()
{
	const WCHAR* filePath = m_LogFilePath.c_str();
	if (_waccess(filePath, 0) == -1)
	{
		// Create empty log file.
		HANDLE file = CreateFile(filePath, GENERIC_WRITE, 0, nullptr, CREATE_NEW, FILE_ATTRIBUTE_NORMAL, nullptr);
		if (file != INVALID_HANDLE_VALUE)
		{
			CloseHandle(file);
		}
		else
		{
			const std::wstring text = GetFormattedString(ID_STR_LOGFILECREATEFAIL, filePath);
			GetRainmeter().ShowMessage(nullptr, text.c_str(), MB_OK | MB_ICONERROR);
			SetLogToFile(false);
			return;
		}
	}

	SetLogToFile(true);
}
예제 #7
0
INT_PTR CDialogManage::CTabThemes::OnCommand(WPARAM wParam, LPARAM lParam)
{
	switch (LOWORD(wParam))
	{
	case IDC_MANAGETHEMES_EMPTYTHEME_CHECKBOX:
		{
			BOOL state = !(Button_GetCheck((HWND)lParam) == BST_CHECKED);

			HWND item = GetDlgItem(m_Window, IDC_MANAGETHEMES_UNUSEDSKINS_CHECKBOX);
			EnableWindow(item, state);
			Button_SetCheck(item, BST_UNCHECKED);

			item = GetDlgItem(m_Window, IDC_MANAGETHEMES_WALLPAPER_CHECKBOX);
			EnableWindow(item, state);
			Button_SetCheck(item, BST_UNCHECKED);
		}
		break;

	case IDC_MANAGETHEMES_NAME_TEXT:
		if (HIWORD(wParam) == EN_CHANGE)
		{
			WCHAR buffer[32];
			int len = Edit_GetText((HWND)lParam, buffer, 32);

			// Disable save button if no text or if backup
			BOOL state = (len > 0 && _wcsicmp(buffer, L"@Backup") != 0);
			EnableWindow(GetDlgItem(m_Window, IDC_MANAGETHEMES_SAVE_BUTTON), state);
		}
		break;

	case IDC_MANAGETHEMES_LIST:
		if (HIWORD(wParam) == LBN_SELCHANGE)
		{
			// Ignore clicks that don't hit items
			if (ListBox_GetCurSel((HWND)lParam) != LB_ERR)
			{
				HWND item = GetDlgItem(m_Window, IDC_MANAGETHEMES_LOAD_BUTTON);
				EnableWindow(item, TRUE);
				item = GetDlgItem(m_Window, IDC_MANAGETHEMES_DELETE_BUTTON);
				EnableWindow(item, TRUE);
				item = GetDlgItem(m_Window, IDC_MANAGETHEMES_EDIT_BUTTON);
				EnableWindow(item, TRUE);
				
				const std::vector<std::wstring>& themes = Rainmeter->GetAllThemes();
				item  = GetDlgItem(m_Window, IDC_MANAGETHEMES_LIST);
				int sel = ListBox_GetCurSel(item);
				
				item = GetDlgItem(m_Window, IDC_MANAGETHEMES_NAME_TEXT);
				Edit_SetText(item, themes[sel].c_str());
			}
		}
		break;

	case IDC_MANAGETHEMES_SAVE_BUTTON:
		{
			WCHAR buffer[MAX_PATH];
			HWND item = GetDlgItem(m_Window, IDC_MANAGETHEMES_NAME_TEXT);
			Edit_GetText(item, buffer, MAX_PATH);

			std::wstring theme = buffer;
			std::wstring path = Rainmeter->GetThemePath();
			CreateDirectory(path.c_str(), 0);

			path += theme;
			bool alreadyExists = (_waccess(path.c_str(), 0) != -1);
			if (alreadyExists)
			{
				std::wstring text = GetFormattedString(ID_STR_THEMEALREADYEXISTS, theme.c_str());
				if (Rainmeter->ShowMessage(m_Window, text.c_str(), MB_ICONWARNING | MB_YESNO) != IDYES)
				{
					// Cancel
					break;
				}
			}
			else
			{
				// Make sure path exists
				CreateDirectory(path.c_str(), NULL);
			}

			path += L"\\Rainmeter.thm";

			item = GetDlgItem(m_Window, IDC_MANAGETHEMES_EMPTYTHEME_CHECKBOX);
			if (Button_GetCheck(item) != BST_CHECKED)
			{
				if (!CSystem::CopyFiles(Rainmeter->GetIniFile(), path))
				{
					std::wstring text = GetFormattedString(ID_STR_THEMESAVEFAIL, path.c_str());
					Rainmeter->ShowMessage(m_Window, text.c_str(), MB_OK | MB_ICONERROR);
					break;
				}

				// Exclude unused skins
				item = GetDlgItem(m_Window, IDC_MANAGETHEMES_UNUSEDSKINS_CHECKBOX);
				if (Button_GetCheck(item) == BST_CHECKED)
				{
					CConfigParser parser;
					parser.Initialize(path);

					// Remove sections with Active=0
					std::list<std::wstring>::const_iterator iter = parser.GetSections().begin();
					for ( ; iter != parser.GetSections().end(); ++iter)
					{
						if (parser.GetValue(*iter, L"Active", L"") == L"0")
						{
							WritePrivateProfileString((*iter).c_str(), NULL, NULL, path.c_str());
						}
					}
				}

				// Save wallpaper
				item = GetDlgItem(m_Window, IDC_MANAGETHEMES_WALLPAPER_CHECKBOX);
				if (Button_GetCheck(item) == BST_CHECKED)
				{
					// Get current wallpaper
					if (SystemParametersInfo(SPI_GETDESKWALLPAPER, MAX_PATH, &buffer, 0))
					{
						std::wstring::size_type pos = path.find_last_of(L'\\');
						path.replace(pos + 1, path.length() - pos - 1, L"RainThemes.bmp");
						CSystem::CopyFiles((std::wstring)buffer, path);
					}
				}
			}
			else
			{
				// Create empty theme
				HANDLE file = CreateFile(path.c_str(), GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
				if (file == INVALID_HANDLE_VALUE)
				{
					std::wstring text = GetFormattedString(ID_STR_THEMESAVEFAIL, path.c_str());
					Rainmeter->ShowMessage(m_Window, text.c_str(), MB_OK | MB_ICONERROR);
					break;
				}

				CloseHandle(file);
			}

			if (!alreadyExists)
			{
				item = GetDlgItem(m_Window, IDC_MANAGETHEMES_LIST);
				ListBox_AddString(item, theme.c_str());

				Rainmeter->ScanForThemes();
			}
		}
		break;

	case IDC_MANAGETHEMES_LOAD_BUTTON:
		{
			HWND item  = GetDlgItem(m_Window, IDC_MANAGETHEMES_LIST);
			int sel = ListBox_GetCurSel(item);
			Rainmeter->LoadTheme(Rainmeter->m_Themes[sel]);
		}
		break;

	case IDC_MANAGETHEMES_EDIT_BUTTON:
		{
			HWND item  = GetDlgItem(m_Window, IDC_MANAGETHEMES_LIST);
			int sel = ListBox_GetCurSel(item);
			const std::vector<std::wstring>& themes = Rainmeter->GetAllThemes();

			std::wstring args = Rainmeter->GetThemePath();
			args += themes[sel];
			args += L"\\Rainmeter.thm";
			RunFile(Rainmeter->GetSkinEditor().c_str(), args.c_str());
		}
		break;

	case IDC_MANAGETHEMES_DELETE_BUTTON:
		{
			HWND item  = GetDlgItem(m_Window, IDC_MANAGETHEMES_LIST);
			int sel = ListBox_GetCurSel(item);
			std::vector<std::wstring>& themes = const_cast<std::vector<std::wstring>&>(Rainmeter->GetAllThemes());

			std::wstring text = GetFormattedString(ID_STR_THEMEDELETE, themes[sel].c_str());
			if (Rainmeter->ShowMessage(m_Window, text.c_str(), MB_ICONQUESTION | MB_YESNO) != IDYES)
			{
				// Cancel
				break;
			}

			std::wstring folder = Rainmeter->GetThemePath();
			folder += themes[sel];

			if (CSystem::RemoveFolder(folder))
			{
				ListBox_DeleteString(item, sel);

				// Remove theme from vector
				std::vector<std::wstring>::iterator iter = themes.begin();
				for ( ; iter != themes.end(); ++iter)
				{
					if (wcscmp(themes[sel].c_str(), (*iter).c_str()) == 0)
					{
						themes.erase(iter);
						break;
					}
				}

				EnableWindow(GetDlgItem(m_Window, IDC_MANAGETHEMES_LOAD_BUTTON), FALSE);
				EnableWindow(GetDlgItem(m_Window, IDC_MANAGETHEMES_DELETE_BUTTON), FALSE);
				EnableWindow(GetDlgItem(m_Window, IDC_MANAGETHEMES_EDIT_BUTTON), FALSE);
			}
		}
		break;

	default:
		return 1;
	}

	return 0;
}