示例#1
0
文件: ui.cpp 项目: ybznek/miranda-ng
static INT_PTR CALLBACK sttEnterPassword(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
	DlgChangePassParam *param = (DlgChangePassParam*)GetWindowLongPtr(hwndDlg, GWLP_USERDATA);

	switch (uMsg) {
	case WM_INITDIALOG:
		TranslateDialogDefault(hwndDlg);
		SendDlgItemMessage(hwndDlg, IDC_HEADERBAR, WM_SETICON, ICON_SMALL, (LPARAM)LoadIcon(g_hInst, MAKEINTRESOURCE(iconList[0].defIconID)));

		param = (DlgChangePassParam*)lParam;
		SetWindowLongPtr(hwndDlg, GWLP_USERDATA, lParam);

		if (param->wrongPass) {
			if (param->wrongPass > 2) {
				HWND hwndCtrl = GetDlgItem(hwndDlg, IDC_USERPASS);
				EnableWindow(hwndCtrl, FALSE);
				hwndCtrl = GetDlgItem(hwndDlg, IDOK);
				EnableWindow(hwndCtrl, FALSE);
				SetDlgItemText(hwndDlg, IDC_HEADERBAR, TranslateT("Too many errors!"));
			}
			else SetDlgItemText(hwndDlg, IDC_HEADERBAR, TranslateT("Password is not correct!"));
		}
		else SetDlgItemText(hwndDlg, IDC_HEADERBAR, TranslateT("Please type in your password"));

		oldLangID = 0;
		SetTimer(hwndDlg, 1, 200, NULL);
		LanguageChanged(hwndDlg);
		return TRUE;

	case WM_CTLCOLORSTATIC:
		if ((HWND)lParam == GetDlgItem(hwndDlg, IDC_LANG)) {
			SetTextColor((HDC)wParam, GetSysColor(COLOR_HIGHLIGHTTEXT));
			SetBkMode((HDC)wParam, TRANSPARENT);
			return (INT_PTR)GetSysColorBrush(COLOR_HIGHLIGHT);
		}
		return FALSE;

	case WM_COMMAND:
		switch (LOWORD(wParam)) {
		case IDCANCEL:
			EndDialog(hwndDlg, IDCANCEL);
			break;

		case IDOK:
			GetDlgItemText(hwndDlg, IDC_USERPASS, param->newPass, _countof(param->newPass));
			EndDialog(hwndDlg, IDOK);
		}
		break;

	case WM_TIMER:
		LanguageChanged(hwndDlg);
		return FALSE;

	case WM_DESTROY:
		KillTimer(hwndDlg, 1);
		DestroyIcon((HICON)SendMessage(hwndDlg, WM_GETICON, ICON_SMALL, 0));
	}

	return FALSE;
}
示例#2
0
//------------------------------------------------------------------------------
void	TCErisoApp::MessageReceived(BMessage* oMsg)
{
	switch ( oMsg->what ) {
	// 転送&処理
	case FUC_IAP_CHANGED:
		IAPChanged(oMsg);
		BMessenger(mCErisoWin).SendMessage(oMsg);
		break;
	// 自前処理
	case B_LANGUAGE_CHANGED:
		LanguageChanged();
		break;
	case SHINTA_MITEM_SHINTA_COMMON_PREFS_CLICKED:
		MItemSHINTACommonPrefsClicked();
		break;
	case FUC_MITEM_AUTHOR_WEB_CLICKED:
		MItemAuthorWebClicked();
		break;
	case FUC_MITEM_HELP_CLICKED:
		MItemHelpClicked();
		break;
	case MITEM_RANGE_ID_CLICKED:
		MItemRangeIDClicked();
		break;
	default:
		SUPER::MessageReceived(oMsg);
	}
}
示例#3
0
void Application::ChangeLanguage(const QString& file)
{
    QString filename = file;
    if (!filename.endsWith(".qm", Qt::CaseInsensitive))
        filename.append(".qm");
    QString tmp = filename;
    tmp.chop(3);
    QString str = tmp.right(2);
    
    QString name = "data/translations/qt_native_translations/qt_" + str + ".qm";

    // Remove old translators then change them to new. 
    removeTranslator(nativeTranslator); 

    if (QFile::exists(name))
    {
        if (nativeTranslator != 0)
        {
            nativeTranslator->load(name);
            installTranslator(nativeTranslator); 
        }
    }
    else
    {
        if (nativeTranslator != 0 && nativeTranslator->isEmpty())
        {
            installTranslator(nativeTranslator);
        }
        else
        {
            SAFE_DELETE(nativeTranslator);
            nativeTranslator = new QTranslator;
            installTranslator(nativeTranslator); 
        }
    }

    // Remove old translators then change them to new. 
    removeTranslator(appTranslator);
    if (appTranslator->load(filename))
    {
        installTranslator(appTranslator);
        framework->Config()->Set(ConfigAPI::FILE_FRAMEWORK, ConfigAPI::SECTION_FRAMEWORK, "language", file);
    }
    
    emit LanguageChanged();
}
示例#4
0
void MythTranslation::reload()
{
//    if (!d.m_loaded)
//        return;

    // Update our translators if necessary.
    // We need two loops, as the QMap wasn't happy with
    // me changing its contents during my iteration.
    if (LanguageChanged())
    {
        QStringList keys;
        for (TransMap::Iterator it = d.m_translators.begin();
             it != d.m_translators.end();
             ++it)
            keys.append(it.key());

        for (QStringList::Iterator it = keys.begin();
             it != keys.end();
             ++it)
            load(*it);
    }
}
示例#5
0
文件: ui.cpp 项目: ybznek/miranda-ng
static INT_PTR CALLBACK sttChangePassword(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
	DlgChangePassParam *param = (DlgChangePassParam*)GetWindowLongPtr(hwndDlg, GWLP_USERDATA);
	TCHAR buf[100];

	switch (uMsg) {
	case WM_INITDIALOG:
		TranslateDialogDefault(hwndDlg);
		SendDlgItemMessage(hwndDlg, IDC_HEADERBAR, WM_SETICON, ICON_SMALL, (LPARAM)IcoLib_GetIconByHandle(iconList[0].hIcolib, true));

		param = (DlgChangePassParam*)lParam;
		SetWindowLongPtr(hwndDlg, GWLP_USERDATA, lParam);

		oldLangID = 0;
		SetTimer(hwndDlg, 1, 200, NULL);
		LanguageChanged(hwndDlg);
		return TRUE;

	case WM_CTLCOLORSTATIC:
		if ((HWND)lParam == GetDlgItem(hwndDlg, IDC_LANG)) {
			SetTextColor((HDC)wParam, GetSysColor(COLOR_HIGHLIGHTTEXT));
			SetBkMode((HDC)wParam, TRANSPARENT);
			return (INT_PTR)GetSysColorBrush(COLOR_HIGHLIGHT);
		}
		return FALSE;

	case WM_COMMAND:
		switch (LOWORD(wParam)) {
		case IDCANCEL:
			EndDialog(hwndDlg, IDCANCEL);
			break;

		case IDREMOVE:
			if (!CheckOldPassword(hwndDlg, param->db)) {
			LBL_Error:
				SendDlgItemMessage(hwndDlg, IDC_HEADERBAR, WM_NCPAINT, 0, 0);
				SetDlgItemTextA(hwndDlg, IDC_USERPASS1, "");
				SetDlgItemTextA(hwndDlg, IDC_USERPASS2, "");
			}
			else {
				param->db->WriteSignature(dbSignatureU);
				param->db->SetPassword(NULL);
				param->db->StoreKey();
				EndDialog(hwndDlg, IDREMOVE);
			}
			break;

		case IDOK:
			TCHAR buf2[100];
			GetDlgItemText(hwndDlg, IDC_USERPASS1, buf2, _countof(buf2));
			if (mir_tstrlen(buf2) < 3) {
				SetDlgItemText(hwndDlg, IDC_HEADERBAR, TranslateT("Password is too short!"));
				goto LBL_Error;
			}

			GetDlgItemText(hwndDlg, IDC_USERPASS2, buf, _countof(buf));
			if (mir_tstrcmp(buf2, buf)) {
				SetDlgItemText(hwndDlg, IDC_HEADERBAR, TranslateT("Passwords do not match!"));
				goto LBL_Error;
			}

			if (!CheckOldPassword(hwndDlg, param->db))
				goto LBL_Error;

			param->db->WriteSignature(dbSignatureE);
			param->db->SetPassword(buf2);
			param->db->StoreKey();
			SecureZeroMemory(buf2, sizeof(buf2));
			EndDialog(hwndDlg, IDOK);
		}
		break;

	case WM_TIMER:
		LanguageChanged(hwndDlg);
		return FALSE;

	case WM_DESTROY:
		KillTimer(hwndDlg, 1);
		Window_FreeIcon_IcoLib(hwndDlg);
	}

	return FALSE;
}
void
MediaConverterWindow::MessageReceived(BMessage* message)
{
	entry_ref inRef;

	char buffer[40];
	BEntry inEntry;

	switch (message->what) {
		#if B_BEOS_VERSION <= B_BEOS_VERSION_6
		case B_LANGUAGE_CHANGED:
			LanguageChanged();
			break;
		#endif

		case INIT_FORMAT_MENUS:
			BuildFormatMenu();
			if (CountSourceFiles() == 0)
				SetEnabled(false, false);
			break;

		case B_SIMPLE_DATA:
			if (message->WasDropped()) {
				DetachCurrentMessage();
				message->what = B_REFS_RECEIVED;
				BMessenger(be_app).SendMessage(message);
				delete message;
			}
			break;

		case FORMAT_SELECT_MESSAGE:
			BuildAudioVideoMenus();
			break;
		case AUDIO_CODEC_SELECT_MESSAGE:
			break;
		case VIDEO_CODEC_SELECT_MESSAGE:
			break;

		case CONVERT_BUTTON_MESSAGE:
			if (!fConverting) {
				fConvertButton->SetLabel(B_TRANSLATE("Cancel"));
				fConverting = true;
				SetStatusMessage(B_TRANSLATE("Convert"));
				SetEnabled(false, true);
				BMessenger(be_app).SendMessage(START_CONVERSION_MESSAGE);
			} else if (!fCancelling) {
				fCancelling = true;
				SetStatusMessage(B_TRANSLATE("Cancelling" B_UTF8_ELLIPSIS));
				BMessenger(be_app).SendMessage(CANCEL_CONVERSION_MESSAGE);
			}
			break;

		case CONVERSION_DONE_MESSAGE:
		{
			SetStatusMessage(fCancelling ? B_TRANSLATE("Conversion cancelled")
				: B_TRANSLATE("Conversion completed"));
			fConverting = false;
			fCancelling = false;
			bool enable = CountSourceFiles() > 0;
			SetEnabled(enable, enable);
			fConvertButton->SetLabel(B_TRANSLATE("Convert"));
			break;
		}

		case OUTPUT_FOLDER_MESSAGE:
			// Execute Save Panel
			if (fSaveFilePanel == NULL) {
				BButton* selectThisDir;

				BMessage folderSelect(FOLDER_SELECT_MESSAGE);
				fSaveFilePanel = new BFilePanel(B_OPEN_PANEL, NULL, NULL,
					B_DIRECTORY_NODE, true, &folderSelect, NULL, false, true);
				fSaveFilePanel->SetButtonLabel(B_DEFAULT_BUTTON,
					B_TRANSLATE("Select"));
				fSaveFilePanel->SetTarget(this);

				fSaveFilePanel->Window()->Lock();
				fSaveFilePanel->Window()->SetTitle(
					B_TRANSLATE("MediaConverter+:SaveDirectory"));
				BRect buttonRect
					= fSaveFilePanel->Window()->ChildAt(0)->FindView(
						"cancel button")->Frame();
				buttonRect.right  = buttonRect.left - 20;
				buttonRect.left = buttonRect.right - 130;
				selectThisDir = new BButton(buttonRect, NULL,
					B_TRANSLATE("Select this folder"),
					new BMessage(SELECT_THIS_DIR_MESSAGE),
					B_FOLLOW_BOTTOM | B_FOLLOW_RIGHT);
				selectThisDir->SetTarget(this);
				fSaveFilePanel->Window()->ChildAt(0)->AddChild(selectThisDir);
				fSaveFilePanel->Window()->Unlock();

				fSaveFilePanel->SetRefFilter(new DirectoryFilter);
			}
			fSaveFilePanel->Show();
			break;

		case FOLDER_SELECT_MESSAGE:
			// "SELECT" Button at Save Panel Pushed
			fSaveFilePanel->GetNextSelectedRef(&inRef);
			inEntry.SetTo(&inRef, true);
			_SetOutputFolder(inEntry);
			fOutputDirSpecified = true;
			fSaveFilePanel->Rewind();
			break;

		case SELECT_THIS_DIR_MESSAGE:
			// "THIS DIR" Button at Save Panel Pushed
			fSaveFilePanel->GetPanelDirectory(&inRef);
			fSaveFilePanel->Hide();
			inEntry.SetTo(&inRef, true);
			_SetOutputFolder(inEntry);
			fOutputDirSpecified = true;
			break;

		case OPEN_FILE_MESSAGE:
			// Execute Open Panel
			if (!fOpenFilePanel) {
				fOpenFilePanel = new BFilePanel(B_OPEN_PANEL, NULL, NULL,
					B_FILE_NODE, true, NULL, NULL, false, true);
				fOpenFilePanel->SetTarget(this);
			}
			fOpenFilePanel->Show();
			break;

		case B_REFS_RECEIVED:
			// Media Files Seleced by Open Panel
			DetachCurrentMessage();
			message->what = B_REFS_RECEIVED;
			BMessenger(be_app).SendMessage(message);
			// fall through

		case B_CANCEL:
			break;

		case QUIT_MESSAGE:
			MediaConverterWindow::QuitRequested();
			break;

		case PREVIEW_MESSAGE:
		{
			// Build the command line to launch the preview application.
			// TODO: Launch the default app instead of hardcoded MediaPlayer!
			int32 srcIndex = fListView->CurrentSelection();
			BMediaFile* inFile = NULL;
			status_t status = GetSourceFileAt(srcIndex, &inFile, &inRef);

			const char* argv[3];
			BString startPosString;
			BPath path;

			if (status == B_OK) {
				argv[0] = "-pos";
					// NOTE: -pos argument is currently not supported by Haiku
					// MediaPlayer.
				startPosString << fStartDurationTC->Text();
				startPosString << "000";
				argv[1] = startPosString.String();

				status = inEntry.SetTo(&inRef);
			}

			if (status == B_OK) {
				status = inEntry.GetPath(&path);
				if (status == B_OK)
					argv[2] = path.Path();
			}

			if (status == B_OK) {
				status = be_roster->Launch(
					"application/x-vnd.Haiku-MediaPlayer",
					3, (char**)argv, NULL);
			}

			if (status != B_OK && status != B_ALREADY_RUNNING) {
				BString errorString(B_TRANSLATE("Error launching: %strError%"));
				errorString.ReplaceFirst("%strError%", strerror(status));
				BAlert* alert = new BAlert(B_TRANSLATE("Error"),
					errorString.String(), B_TRANSLATE("OK"));
				alert->SetFlags(alert->Flags() | B_CLOSE_ON_ESCAPE);
				alert->Go();
			}
			break;
		}

		case VIDEO_QUALITY_CHANGED_MESSAGE:
		{
			int32 value;
			message->FindInt32("be:value", &value);
			snprintf(buffer, sizeof(buffer),
				B_TRANSLATE("Video quality: %3d%%"), (int8)value);
			fVideoQualitySlider->SetLabel(buffer);
			fVideoQuality = value;
			break;
		}

		case AUDIO_QUALITY_CHANGED_MESSAGE:
		{
			int32 value;
			message->FindInt32("be:value", &value);
			snprintf(buffer, sizeof(buffer),
				B_TRANSLATE("Audio quality: %3d%%"), (int8)value);
			fAudioQualitySlider->SetLabel(buffer);
			fAudioQuality = value;
			break;
		}

		default:
			BWindow::MessageReceived(message);
	}
}
示例#7
0
INT_PTR CALLBACK DlgChangePass(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
	static char* newPass;
	CDbxMmapSA *p_Db = (CDbxMmapSA*)GetWindowLongPtr(hDlg, GWLP_USERDATA);

	switch (uMsg) {
	case WM_INITDIALOG:
		TranslateDialogDefault(hDlg);

		SendMessage(GetDlgItem(hDlg, IDC_HEADERBAR), WM_SETICON, 0, (LPARAM)LoadIcon(g_hInst, MAKEINTRESOURCE(IDI_ICON2)));
		SetWindowText(GetDlgItem(hDlg, IDC_HEADERBAR), TranslateT("Change password"));
		{
			DlgChangePassParam *param = (DlgChangePassParam*)lParam;
			newPass = param->pszNewPass;
			SetWindowLongPtr(hDlg, GWLP_USERDATA, (LPARAM)param->p_Db);
		}
		oldLangID = 0;
		SetTimer(hDlg, 1, 200, NULL);
		LanguageChanged(hDlg);
		return TRUE;

	case WM_CTLCOLORSTATIC:
		if ((HWND)lParam == GetDlgItem(hDlg, IDC_LANG)) {
			SetTextColor((HDC)wParam, GetSysColor(COLOR_HIGHLIGHTTEXT));
			SetBkMode((HDC)wParam, TRANSPARENT);
			return (BOOL)GetSysColorBrush(COLOR_HIGHLIGHT);
		}

		return FALSE;

	case WM_COMMAND:
		switch (LOWORD(wParam)) {
			char pass1[255], pass2[255], oldpass[255];
		case IDOK:
			GetDlgItemTextA(hDlg, IDC_OLDPASS, oldpass, 254);
			if (strcmp(oldpass, p_Db->encryptKey)) {
				SetWindowText(GetDlgItem(hDlg, IDC_HEADERBAR), TranslateT("Wrong password!"));
				SendMessage(GetDlgItem(hDlg, IDC_HEADERBAR), WM_NCPAINT, 0, 0);
				break;
			}

			if (GetDlgItemTextA(hDlg, IDC_NEWPASS1, pass1, 254) < 3) {
				SetWindowText(GetDlgItem(hDlg, IDC_HEADERBAR), TranslateT("Password is too short!"));
				SendMessage(GetDlgItem(hDlg, IDC_HEADERBAR), WM_NCPAINT, 0, 0);
			}
			else {
				GetDlgItemTextA(hDlg, IDC_NEWPASS2, pass2, 254);
				if (!strcmp(pass1, pass2)) {
					strcpy(newPass, pass1);
					EndDialog(hDlg, IDOK);
				}
				else {
					SetWindowText(GetDlgItem(hDlg, IDC_HEADERBAR), TranslateT("Passwords do not match!"));
					SendMessage(GetDlgItem(hDlg, IDC_HEADERBAR), WM_NCPAINT, 0, 0);
				}
			}
			break;

		case IDCANCEL:
			EndDialog(hDlg, IDCANCEL);
			break;

		case IDREMOVE:
			GetDlgItemTextA(hDlg, IDC_OLDPASS, oldpass, 254);
			if (strcmp(oldpass, p_Db->encryptKey)) {
				SetWindowText(GetDlgItem(hDlg, IDC_HEADERBAR), TranslateT("Wrong password!"));
				SendMessage(GetDlgItem(hDlg, IDC_HEADERBAR), WM_NCPAINT, 0, 0);
				break;
			}
			EndDialog(hDlg, IDREMOVE);
		}
		break;

	case WM_TIMER:
		LanguageChanged(hDlg);
		return FALSE;

	case WM_DESTROY:
		KillTimer(hDlg, 1);
		DestroyIcon((HICON)SendMessage(hDlg, WM_GETICON, ICON_SMALL, 0));
		return FALSE;
	}
	return FALSE;
}
示例#8
0
INT_PTR CALLBACK DlgStdNewPass(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
	switch (uMsg) {
	case WM_INITDIALOG:
		TranslateDialogDefault(hDlg);
		SetWindowLongPtr(hDlg, GWLP_USERDATA, (LPARAM)lParam);

		SendMessage(GetDlgItem(hDlg, IDC_HEADERBAR), WM_SETICON, ICON_SMALL, (LPARAM)LoadIcon(g_hInst, MAKEINTRESOURCE(IDI_ICON2)));

		SetWindowText(GetDlgItem(hDlg, IDC_HEADERBAR), TranslateT("Please enter your new password"));

		oldLangID = 0;
		SetTimer(hDlg, 1, 200, NULL);
		LanguageChanged(hDlg);
		return TRUE;

	case WM_CTLCOLORSTATIC:
		if ((HWND)lParam == GetDlgItem(hDlg, IDC_LANG)) {
			SetTextColor((HDC)wParam, GetSysColor(COLOR_HIGHLIGHTTEXT));
			SetBkMode((HDC)wParam, TRANSPARENT);
			return (BOOL)GetSysColorBrush(COLOR_HIGHLIGHT);
		}
		return FALSE;

	case WM_COMMAND:
		switch (LOWORD(wParam)) {
		case IDCANCEL:
			EndDialog(hDlg, IDCANCEL);
			break;

		case IDOK:
			CDbxMmapSA *p_Db = (CDbxMmapSA*)GetWindowLongPtr(hDlg, GWLP_USERDATA);
			char pass1[255], pass2[255];
			if (GetDlgItemTextA(hDlg, IDC_USERPASS1, pass1, 254) < 3) {
				SetWindowText(GetDlgItem(hDlg, IDC_HEADERBAR), TranslateT("Password is too short!"));
				SendMessage(GetDlgItem(hDlg, IDC_HEADERBAR), WM_NCPAINT, 0, 0);
				SetDlgItemTextA(hDlg, IDC_USERPASS1, "");
				SetDlgItemTextA(hDlg, IDC_USERPASS2, "");
			}
			else {
				GetDlgItemTextA(hDlg, IDC_USERPASS2, pass2, 254);
				if (!strcmp(pass1, pass2)) {
					p_Db->encryptKeyLength = strlen(pass1);
					strcpy(p_Db->encryptKey, pass1);
					EndDialog(hDlg, IDOK);
				}
				else {
					SetWindowText(GetDlgItem(hDlg, IDC_HEADERBAR), TranslateT("Passwords do not match!"));
					SendMessage(GetDlgItem(hDlg, IDC_HEADERBAR), WM_NCPAINT, 0, 0);
					SetDlgItemTextA(hDlg, IDC_USERPASS1, "");
					SetDlgItemTextA(hDlg, IDC_USERPASS2, "");
				}
			}
		}
		break;

	case WM_TIMER:
		LanguageChanged(hDlg);
		return FALSE;

	case WM_DESTROY:
		KillTimer(hDlg, 1);
		DestroyIcon((HICON)SendMessage(hDlg, WM_GETICON, ICON_SMALL, 0));
		return FALSE;
	}
	return FALSE;
}
示例#9
0
INT_PTR CALLBACK DlgStdInProc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
	TCHAR tszHeaderTxt[256];

	switch (uMsg) {
	case WM_INITDIALOG:
		TranslateDialogDefault(hDlg);
		{
			HICON hIcon = LoadIcon(g_hInst, MAKEINTRESOURCE(IDI_ICON2));
			SendMessage(GetDlgItem(hDlg, IDC_HEADERBAR), WM_SETICON, ICON_SMALL, (LPARAM)hIcon);

			DlgStdInProcParam *param = (DlgStdInProcParam*)lParam;
			SetWindowLongPtr(hDlg, GWLP_USERDATA, (LPARAM)param->p_Db);

			if (!wrongPass) {
				mir_sntprintf(tszHeaderTxt, SIZEOF(tszHeaderTxt), _T("%s\n%s"), TranslateT("Please type in your password for"), param->pStr);
				SetWindowText(GetDlgItem(hDlg, IDC_HEADERBAR), tszHeaderTxt);
			}
			else {
				if (wrongPass > 2) {
					HWND hwndCtrl = GetDlgItem(hDlg, IDC_USERPASS);
					EnableWindow(hwndCtrl, FALSE);
					hwndCtrl = GetDlgItem(hDlg, IDOK);
					EnableWindow(hwndCtrl, FALSE);
					SetWindowText(GetDlgItem(hDlg, IDC_HEADERBAR), TranslateT("Too many errors!"));
				}
				else SetWindowText(GetDlgItem(hDlg, IDC_HEADERBAR), TranslateT("Password is not correct!"));
			}
		}
		oldLangID = 0;
		SetTimer(hDlg, 1, 200, NULL);
		LanguageChanged(hDlg);
		return TRUE;

	case WM_CTLCOLORSTATIC:
		if ((HWND)lParam == GetDlgItem(hDlg, IDC_LANG)) {
			SetTextColor((HDC)wParam, GetSysColor(COLOR_HIGHLIGHTTEXT));
			SetBkMode((HDC)wParam, TRANSPARENT);
			return (BOOL)GetSysColorBrush(COLOR_HIGHLIGHT);
		}
		return FALSE;

	case WM_COMMAND:
		switch (LOWORD(wParam)) {
		case IDCANCEL:
			EndDialog(hDlg, IDCANCEL);
			break;

		case IDOK:
			CDbxMmapSA *p_Db = (CDbxMmapSA*)GetWindowLongPtr(hDlg, GWLP_USERDATA);
			p_Db->encryptKeyLength = GetDlgItemTextA(hDlg, IDC_USERPASS, p_Db->encryptKey, 254);
			EndDialog(hDlg, IDOK);
		}
		break;

	case WM_TIMER:
		LanguageChanged(hDlg);
		return FALSE;

	case WM_DESTROY:
		KillTimer(hDlg, 1);
		DestroyIcon((HICON)SendMessage(hDlg, WM_GETICON, ICON_SMALL, 0));
	}

	return FALSE;
}
示例#10
0
INT_PTR CALLBACK DlgStdInProc(HWND hDlg, UINT uMsg,WPARAM wParam,LPARAM lParam)
{
	static DWORD dwOldIcon = 0;
	HICON hIcon = 0;

	switch(uMsg){
	case WM_INITDIALOG:
		g_hDlgPass = hDlg;
		hIcon = LoadIcon(g_hInstance, MAKEINTRESOURCE(IDI_DLGPASSWD));
		dwOldIcon = SetClassLongPtr(hDlg, GCLP_HICON, (LONG)hIcon); // set alt+tab icon
		SendDlgItemMessage(hDlg,IDC_EDIT1,EM_LIMITTEXT,MAXPASSLEN,0);

		if (IsAeroMode())
		{
			SetWindowLongPtr(hDlg, GWL_STYLE, GetWindowLongPtr(hDlg, GWL_STYLE) | WS_DLGFRAME | WS_SYSMENU);
			SetWindowLongPtr(hDlg, GWL_EXSTYLE, GetWindowLongPtr(hDlg, GWL_EXSTYLE) | WS_EX_TOOLWINDOW);
			RECT rect;
			GetClientRect(hDlg, &rect);
			SetWindowPos(hDlg, 0, 0, 0, rect.right, rect.bottom + GetSystemMetrics(SM_CYCAPTION), SWP_FRAMECHANGED | SWP_NOMOVE | SWP_NOZORDER);
		}
		SendDlgItemMessage(hDlg, IDC_HEADERBAR, WM_SETICON, 0, (LPARAM)hIcon);
		SetDlgItemText(hDlg, IDC_HEADERBAR, TranslateT("Miranda NG is locked.\nEnter password to unlock it."));

		TranslateDialogDefault(hDlg);
		oldLangID = 0;
		SetTimer(hDlg,1,200,NULL);

		oldLayout = GetKeyboardLayout(0);
		if (MAKELCID((WORD)oldLayout & 0xffffffff,  SORT_DEFAULT) != (LCID)0x00000409)
			ActivateKeyboardLayout((HKL)0x00000409, 0);
		LanguageChanged(hDlg);
		return TRUE;

	case WM_CTLCOLORSTATIC:
		if (GetWindowLongPtr((HWND)lParam, GWLP_ID) != IDC_LANG)
			break;

		SetTextColor((HDC)wParam, GetSysColor(COLOR_HIGHLIGHTTEXT));
		SetBkMode((HDC)wParam, TRANSPARENT);
		return (INT_PTR)GetSysColorBrush(COLOR_HIGHLIGHT);

	case WM_COMMAND:
		{
			UINT uid = LOWORD(wParam);
			if (uid == IDOK){
				char password[MAXPASSLEN + 1] = {0};
				int passlen = GetDlgItemTextA(hDlg,IDC_EDIT1,password,MAXPASSLEN+1);

				if (passlen == 0)
				{
					SetDlgItemText(hDlg, IDC_HEADERBAR, TranslateT("Miranda NG is locked.\nEnter password to unlock it."));
					SendDlgItemMessage(hDlg, IDC_HEADERBAR, WM_NCPAINT, 0, 0);
					break;
				}
				else if (lstrcmpA(password, g_password))
				{
					SetDlgItemText(hDlg, IDC_HEADERBAR, TranslateT("Password is not correct!\nPlease, enter correct password."));
					SendDlgItemMessage(hDlg, IDC_HEADERBAR, WM_NCPAINT, 0, 0);
					SetDlgItemText(hDlg, IDC_EDIT1, _T(""));
					break;
				}
				else EndDialog(hDlg, IDOK);
			}
			else if (uid == IDCANCEL)
				EndDialog(hDlg, IDCANCEL);
		}

	case WM_TIMER:
		LanguageChanged(hDlg);
		break;

	case WM_DESTROY:
		KillTimer(hDlg, 1);
		if (GetKeyboardLayout(0) != oldLayout)
			ActivateKeyboardLayout(oldLayout, 0);
		SetClassLongPtr(hDlg, GCLP_HICON, (long)dwOldIcon);
		DestroyIcon(hIcon);
		break;
	}
	return FALSE;
}