Exemplo n.º 1
0
//=======================================================
//Open URL
//=======================================================
void CYahooProto::OpenURL(const char *url, int autoLogin)
{
	char tUrl[4096];

	debugLogA("[YahooOpenURL] url: %s Auto Login: %d", url, autoLogin);

	if (autoLogin && getByte("MailAutoLogin", 0) && m_bLoggedIn && m_id > 0) {
		char  *y, *t, *u;

		y = yahoo_urlencode(yahoo_get_cookie(m_id, "y"));
		t = yahoo_urlencode(yahoo_get_cookie(m_id, "t"));
		u = yahoo_urlencode(url);
		mir_snprintf(tUrl, 
			"http://msg.edit.yahoo.com/config/reset_cookies?&.y=Y=%s&.t=T=%s&.ver=2&.done=http%%3a//us.rd.yahoo.com/messenger/client/%%3f%s",
			y, t, u);

		FREE(y);
		FREE(t);
		FREE(u);
	}
	else {
		mir_snprintf(tUrl, url);
	}

	debugLogA("[YahooOpenURL] url: %s Final URL: %s", url, tUrl);
	Utils_OpenUrl(tUrl);
}
Exemplo n.º 2
0
void DoOpenUrl(LPSTR tokenResp, LPSTR url)
{
	ptrA encodedUrl(mir_urlEncode(url)), encodedToken(mir_urlEncode(tokenResp));
	size_t size = mir_strlen(TOKEN_AUTH_URL) + 1 + mir_strlen(encodedToken) + mir_strlen(encodedUrl);
	LPSTR composedUrl = (LPSTR)alloca(size);
	mir_snprintf(composedUrl, size, TOKEN_AUTH_URL, encodedToken, encodedUrl);
	Utils_OpenUrl(composedUrl);
}
Exemplo n.º 3
0
void OpenUrlThread(void *param)
{
	OPEN_URL_HEADER* data = (OPEN_URL_HEADER*)param;

	HANDLE hUser = FindNetUserHandle(data->acc);
	if (!hUser || !AuthAndOpen(hUser, data->url, data->mailbox, data->pwd))
		Utils_OpenUrl(data->url);
	free(data);
}
Exemplo n.º 4
0
int CDb3Mmap::CheckDbHeaders(bool bInteractive)
{
	if (memcmp(m_dbHeader.signature, &dbSignatureU, sizeof(m_dbHeader.signature)) &&
		memcmp(m_dbHeader.signature, &dbSignatureE, sizeof(m_dbHeader.signature)))
	{
		if (!memcmp(&m_dbHeader.signature, &dbSignatureIM, sizeof(m_dbHeader.signature)) ||
			!memcmp(&m_dbHeader.signature, &dbSignatureSA, sizeof(m_dbHeader.signature)))
			return EGROKPRF_OBSOLETE;

		if (!memcmp(&m_dbHeader.signature, &dbSignatureSD, sizeof(m_dbHeader.signature))) {
			if (bInteractive)
				if (IDYES == MessageBox(NULL, TranslateTS(tszOldHeaders), TranslateT("Obsolete database format"), MB_YESNO | MB_ICONWARNING)) {
					TCHAR tszCurPath[MAX_PATH];
					GetModuleFileName(NULL, tszCurPath, _countof(tszCurPath));
					TCHAR *p = _tcsrchr(tszCurPath, '\\');
					if (p) *p = 0;

					HKEY hPathSetting;
					if (!RegCreateKey(HKEY_CURRENT_USER, _T("Software\\Miranda NG"), &hPathSetting)) {
						RegSetValue(hPathSetting, _T("InstallPath"), REG_SZ, tszCurPath, sizeof(tszCurPath));
						RegCloseKey(hPathSetting);
					}

					Utils_OpenUrl("http://wiki.miranda-ng.org/index.php?title=Updating_pre-0.94.9_version_to_0.95.1_and_later");
					Sleep(1000);
					exit(0);
				}
			return EGROKPRF_OBSOLETE;
		}
		return EGROKPRF_UNKHEADER;
	}

	switch (m_dbHeader.version) {
	case DB_OLD_VERSION:
	case DB_094_VERSION:
	case DB_095_VERSION:
		return EGROKPRF_OBSOLETE;

	case DB_095_1_VERSION:
		break;

	default:
		return EGROKPRF_VERNEWER;
	}

	if (m_dbHeader.ofsUser == 0)
		return EGROKPRF_DAMAGED;

	return 0;
}
Exemplo n.º 5
0
INT_PTR TwitterProto::VisitHomepage(WPARAM wParam, LPARAM)
{
	MCONTACT hContact = (MCONTACT) wParam;
	DBVARIANT dbv;
	// TODO: remove this
	if (!getString(hContact, TWITTER_KEY_UN, &dbv)) {
		std::string url = profile_base_url("https://twitter.com/") + http::url_encode(dbv.pszVal);
		setString(hContact, "Homepage", url.c_str());

		Utils_OpenUrl(url.c_str());
		db_free(&dbv);
	}

	return 0;
}
Exemplo n.º 6
0
bool CVkProto::RunCaptchaForm(LPCSTR szUrl, CMStringA &result)
{
	debugLogA("CVkProto::RunCaptchaForm: reading picture from %s", szUrl);
	result.Empty();

	CAPTCHA_FORM_PARAMS param = { 0 };
	if (getBool("UseCaptchaAssistant", false)) {
		CMStringA szCaptchaAssistant(FORMAT, "http://ca.tiflohelp.ru/?link=%s", ptrA(ExpUrlEncode(szUrl)));
		Utils_OpenUrl(szCaptchaAssistant);
	}
	else {
		NETLIBHTTPREQUEST req = { sizeof(req) };
		req.requestType = REQUEST_GET;
		req.szUrl = (LPSTR)szUrl;
		req.flags = VK_NODUMPHEADERS;

		NETLIBHTTPREQUEST *reply = (NETLIBHTTPREQUEST*)CallService(MS_NETLIB_HTTPTRANSACTION, (WPARAM)m_hNetlibUser, (LPARAM)&req);
		if (reply == NULL)
			return false;

		if (reply->resultCode != 200) {
			debugLogA("CVkProto::RunCaptchaForm: failed with code %d", reply->resultCode);
			return false;
		}

		IMGSRVC_MEMIO memio = { 0 };
		memio.iLen = reply->dataLength;
		memio.pBuf = reply->pData;
		memio.fif = FIF_UNKNOWN; /* detect */
		param.bmp = (HBITMAP)CallService(MS_IMG_LOADFROMMEM, (WPARAM)&memio);

		BITMAP bmp = { 0 };
		GetObject(param.bmp, sizeof(bmp), &bmp);
		param.w = bmp.bmWidth;
		param.h = bmp.bmHeight;
	}

	CVkCaptchaForm dlg(this, &param);
	if (!dlg.DoModal())
		return false;
	
	debugLogA("CVkProto::RunCaptchaForm: user entered text %s", param.Result);
	result = param.Result;
	return true;
}
Exemplo n.º 7
0
static INT_PTR GoToURLMsgCommand(WPARAM wParam, LPARAM lParam)
{
	ptrA szMsg(db_get_sa(wParam, "CList", "StatusMsg"));

	char *szURL = StrFindURL(szMsg);
	if (szURL != NULL) {
		int i;
		for (i = 0; szURL[i] != ' ' && szURL[i] != '\n' && szURL[i] != '\r' && szURL[i] != '\t' && szURL[i] != '\0'; i++);

		char *szMsgURL = (char *)mir_alloc(i + 1);
		if (szMsgURL) {
			mir_strncpy(szMsgURL, szURL, i + 1);
			Utils_OpenUrl(szMsgURL);
			mir_free(szMsgURL);
		}
	}

	return 0;
}
Exemplo n.º 8
0
INT_PTR CALLBACK ModernOptHome_DlgProc(HWND hwndDlg, UINT  msg, WPARAM wParam, LPARAM lParam)
{
	int i;

	switch (msg) {
	case WM_INITDIALOG:
		TranslateDialogDefault(hwndDlg);
		for (i = 0; i < _countof(g_ModernOptPages); ++i) {
			if (g_ModernOptPages[i].idcButton) {
				HWND hwndCtrl = GetDlgItem(hwndDlg, g_ModernOptPages[i].idcButton);
				if (g_ModernOptPages[i].bShow) {
					HICON hIcon = (HICON)LoadImage(hInst, MAKEINTRESOURCE(g_ModernOptPages[i].iIcon), IMAGE_ICON, 32, 32, LR_DEFAULTCOLOR);
					MDescButton_SetIcon(hwndCtrl, hIcon);
					MDescButton_SetTitle(hwndCtrl, TranslateTS(g_ModernOptPages[i].lpzTitle));
					MDescButton_SetDescription(hwndCtrl, TranslateTS(g_ModernOptPages[i].lpzDescription));
					DestroyIcon(hIcon);
				}
				else ShowWindow(hwndCtrl, SW_HIDE);
		}	}

		return FALSE;

	case WM_COMMAND:
		switch ( LOWORD(wParam)) {
		case IDC_BTN_HELP:
			Utils_OpenUrl("http://miranda-ng.org/");
			break;

		default:
			for (i = 0; i < _countof(g_ModernOptPages); ++i) {
				if (g_ModernOptPages[i].idcButton == LOWORD(wParam))
				{
					CallService(MS_MODERNOPT_SELECTPAGE, i, 0);
					return TRUE;
		}	}	}

	case WM_DESTROY:
		return FALSE;
	}
	return FALSE;
}
Exemplo n.º 9
0
void SearchWord(TCHAR *word, int engine)
{
	char szURL[4096];
	if (word && word[0]) {
		T2Utf wordUTF(word);
		ptrA wordURL(mir_urlEncode(wordUTF));
		switch (engine) {
		case SEARCHENGINE_WIKIPEDIA:
			mir_snprintf(szURL, "http://en.wikipedia.org/wiki/%s", wordURL);
			break;
		case SEARCHENGINE_YAHOO:
			mir_snprintf(szURL, "http://search.yahoo.com/search?p=%s&ei=UTF-8", wordURL);
			break;
		case SEARCHENGINE_FOODNETWORK:
			mir_snprintf(szURL, "http://search.foodnetwork.com/search/delegate.do?fnSearchString=%s", wordURL);
			break;
		case SEARCHENGINE_BING:
			mir_snprintf(szURL, "http://www.bing.com/search?q=%s&form=OSDSRC", wordURL);
			break;
		case SEARCHENGINE_GOOGLE_MAPS:
			mir_snprintf(szURL, "http://maps.google.com/maps?q=%s&ie=utf-8&oe=utf-8", wordURL);
			break;
		case SEARCHENGINE_GOOGLE_TRANSLATE:
			mir_snprintf(szURL, "http://translate.google.com/?q=%s&ie=utf-8&oe=utf-8", wordURL);
			break;
		case SEARCHENGINE_YANDEX:
			mir_snprintf(szURL, "http://yandex.ru/yandsearch?text=%s", wordURL);
			break;
		case SEARCHENGINE_GOOGLE:
		default:
			mir_snprintf(szURL, "http://www.google.com/search?q=%s&ie=utf-8&oe=utf-8", wordURL);
			break;
		}

		Utils_OpenUrl(szURL);
	}
}
Exemplo n.º 10
0
INT_PTR CMraProto::MraWebSearch(WPARAM, LPARAM)
{
    Utils_OpenUrl(MRA_SEARCH_URL);
    return 0;
}
Exemplo n.º 11
0
static INT_PTR WebsiteCommand(WPARAM, LPARAM)
{
	Utils_OpenUrl("http://miranda-ng.org");
	return 0;
}
Exemplo n.º 12
0
static INT_PTR BugCommand(WPARAM, LPARAM)
{
	Utils_OpenUrl("http://trac.miranda-ng.org/newticket");
	return 0;
}
Exemplo n.º 13
0
static INT_PTR CALLBACK ModernOptDlgProc(HWND hwndDlg, UINT  msg, WPARAM wParam, LPARAM lParam)
{
	struct ModernOptionsData *dat = (struct ModernOptionsData *)GetWindowLongPtr(hwndDlg, GWLP_USERDATA);

	int i;
	HWND hwndCtrl;

	switch (msg) {
	case WM_INITDIALOG:
	{
		TranslateDialogDefault(hwndDlg);

		dat = (struct ModernOptionsData *)lParam;
		dat->iPage = -1;

		LOGFONT lf;
		dat->hfntBold = (HFONT)SendMessage(hwndDlg, WM_GETFONT, 0, 0);
		GetObject(dat->hfntBold, sizeof(lf), &lf);
		lf.lfWeight = FW_BOLD;
		dat->hfntBold = CreateFontIndirect(&lf);

		hwndCtrl = GetDlgItem(hwndDlg, IDC_TV_SUBSECTIONS);
		HIMAGELIST himl = ImageList_Create(16, 16, ILC_MASK | ILC_COLOR32, 2, 1);
		TreeView_SetImageList(hwndCtrl, himl, TVSIL_NORMAL);

		for (i = 0; i < dat->pObjectList.getCount(); ++i) {
			struct ModernOptionsObject *obj = (struct ModernOptionsObject *)dat->pObjectList[i];
			if ((obj->optObject.iSection >= 0) && (obj->optObject.iSection < MODERNOPT_PAGE_COUNT))
				g_ModernOptPages[obj->optObject.iSection].bShow = TRUE;
			if (obj->optObject.hIcon)
				obj->iTreeImageIndex = ImageList_AddIcon(himl, obj->optObject.hIcon);
		}

		hwndCtrl = GetDlgItem(hwndDlg, IDC_ICOTABS);
		for (i = 0; i < _countof(g_ModernOptPages); ++i)
			if (g_ModernOptPages[i].bShow && g_ModernOptPages[i].bShowTab)
			{
				HICON hIcon = (HICON)LoadImage(hInst, MAKEINTRESOURCE(g_ModernOptPages[i].iIcon), IMAGE_ICON, 32, 32, LR_DEFAULTCOLOR);
				MIcoTab_AddItem(hwndCtrl, TranslateTS(g_ModernOptPages[i].lpzTitle), hIcon, i, FALSE);
				DestroyIcon(hIcon);
			}

		SetWindowLongPtr(hwndDlg, GWLP_USERDATA, (LONG_PTR)dat);

		if (g_iSectionRestore)
			CallService(MS_MODERNOPT_SELECTPAGE, g_iSectionRestore, 0);
		else
			ModernOptUI_SelectSection(hwndDlg, dat, g_iSectionRestore);

		Utils_RestoreWindowPositionNoSize(hwndDlg, NULL, "Options", "");

		return TRUE;
	}

	case WM_COMMAND:
		switch (LOWORD(wParam)) {
		case IDC_ICOTABS:
			{
				int iPage = MIcoTab_GetItemData(GetDlgItem(hwndDlg, IDC_ICOTABS), lParam);
				ModernOptUI_SelectSection(hwndDlg, dat, iPage);
				SetFocus(GetDlgItem(hwndDlg, IDC_ICOTABS));
			}
			break;

		case IDC_BTN_CLASSICOPT:
			PostMessage(hwndDlg, WM_CLOSE, 0, 0);
			db_set_b(NULL, "Options", "Expert", 1);
			{
				OPENOPTIONSDIALOG ood = { sizeof(ood) };
				Options_Open(&ood);
			}
			break;

		case IDC_BTN_HELP:
			{
				struct ModernOptionsObject *obj = (struct ModernOptionsObject *)dat->pObjectList[dat->iPage];
				if (obj->optObject.lpzHelpUrl)
					Utils_OpenUrl(obj->optObject.lpzHelpUrl);
			}
			break;

		case IDC_BTN_EXPERT:
			if (IsWindowEnabled(GetDlgItem(hwndDlg, IDC_BTN_APPLY))) {
				int idResult = MessageBox(hwndDlg,
					TranslateT("You have some unsaved changes here.\n Do you wish to apply settings before switching?"),
					_T("Miranda NG"), MB_ICONQUESTION | MB_YESNOCANCEL);
				if (idResult == IDCANCEL) break;
				sttNotifyPages(dat, (idResult == IDYES) ? PSN_APPLY : PSN_RESET);
			}

			Utils_SaveWindowPosition(hwndDlg, NULL, "Options", "");
			g_iSectionRestore = dat->iSection;
			{	
				struct ModernOptionsObject *obj = (struct ModernOptionsObject *)dat->pObjectList[dat->iPage];
				if (obj->optObject.lpzClassicGroup || obj->optObject.lpzClassicPage) {
					OPENOPTIONSDIALOG ood = { 0 };
					ood.cbSize = sizeof(ood);
					ood.pszGroup = obj->optObject.lpzClassicGroup;
					ood.pszPage = obj->optObject.lpzClassicPage;
					ood.pszTab = obj->optObject.lpzClassicTab;
					Options_OpenPage(&ood);
				}
				else CallService("Options/OptionsCommand", 0, 0);

				PostMessage(hwndDlg, WM_CLOSE, 0, 0);
			}
			break;

		case IDOK:
			sttNotifyPages(dat, PSN_APPLY);
			PostMessage(hwndDlg, WM_CLOSE, 0, 0);
			break;

		case IDCANCEL:
			sttNotifyPages(dat, PSN_RESET);
			PostMessage(hwndDlg, WM_CLOSE, 0, 0);
			break;

		case IDC_BTN_APPLY:
			EnableWindow(GetDlgItem(hwndDlg,IDC_BTN_APPLY), FALSE);
			sttNotifyPages(dat, PSN_APPLY);
			break;
		}

		return TRUE;

	case PSM_CHANGED:
		EnableWindow(GetDlgItem(hwndDlg, IDC_BTN_APPLY), TRUE);
		for (i = 0; i < dat->pObjectList.getCount(); ++i) {
			struct ModernOptionsObject *obj = (struct ModernOptionsObject *)dat->pObjectList[i];
			if (obj->hwnd && IsWindowVisible(obj->hwnd))
				obj->bChanged = TRUE;
		}
		break;

	case WM_NOTIFY:
		{
			LPNMHDR lpnmhdr = (LPNMHDR)lParam;
 			if (lpnmhdr->idFrom == IDC_TV_SUBSECTIONS ) {
				LPNMTREEVIEW lpnmtv = (LPNMTREEVIEW)lParam;
				if (lpnmhdr->code == TVN_SELCHANGED ) {
					ModernOptUI_ShowPage(hwndDlg, dat, lpnmtv->itemNew.lParam);
					break;
				}
				break;
			}
			return TRUE;
		}

	case WM_CLOSE:
		DestroyWindow(hwndDlg);
		hwndModernOpt = 0;
		return TRUE;

	case WM_DESTROY:
		if (!dat) return TRUE;
		li_List_Destruct(dat->pObjectList, ModernOptionsObject_Dtor);
		DeleteObject(dat->hfntBold);
		ImageList_Destroy(TreeView_SetImageList(GetDlgItem(hwndDlg, IDC_TV_SUBSECTIONS), NULL, TVSIL_NORMAL));
		Utils_SaveWindowPosition(hwndDlg, NULL, "Options", "");
		delete dat;
	}
	return FALSE;
}
Exemplo n.º 14
0
static INT_PTR IndexCommand(WPARAM, LPARAM)
{
	Utils_OpenUrl("http://wiki.miranda-ng.org");
	return 0;
}
Exemplo n.º 15
0
INT_PTR TlenProtocol::MenuHandleInbox(WPARAM, LPARAM)
{
	char szFileName[MAX_PATH];
	DBVARIANT dbv;
	NETLIBHTTPREQUEST req;
	NETLIBHTTPHEADER headers[2];
	NETLIBHTTPREQUEST *resp;
	char *login = NULL, *password = NULL;
	char form[1024];
	char cookie[1024];
	if (!db_get(NULL, m_szModuleName, "LoginName", &dbv)) {
		login = mir_strdup(dbv.pszVal);
		db_free(&dbv);
	}

	if (db_get_b(NULL, m_szModuleName, "SavePassword", TRUE) == TRUE)
		password = db_get_sa(NULL, m_szModuleName, "Password");
	else if (threadData != NULL && mir_strlen(threadData->password) > 0)
		password = mir_strdup(threadData->password);

	memset(&cookie, 0, sizeof(cookie));
	if (login != NULL && password != NULL) {
		mir_snprintf(form, "username=%s&password=%s", login, password);
		headers[0].szName = "Content-Type";
		headers[0].szValue = "application/x-www-form-urlencoded";
		memset(&req, 0, sizeof(req));
		req.cbSize = sizeof(req);
		req.requestType = REQUEST_POST;
		req.flags = 0;
		req.headersCount = 1;
		req.headers = headers;
		req.pData = form;
		req.dataLength = (int)mir_strlen(form);
		req.szUrl = "http://poczta.o2.pl/login.html";
		resp = (NETLIBHTTPREQUEST *)CallService(MS_NETLIB_HTTPTRANSACTION, (WPARAM)m_hNetlibUser, (LPARAM)&req);
		if (resp != NULL) {
			if (resp->resultCode / 100 == 2 || resp->resultCode == 302) {
				int i;
				for (i = 0; i < resp->headersCount; i++) {
					if (strcmpi(resp->headers[i].szName, "Set-Cookie") == 0) {
						char *start = strstr(resp->headers[i].szValue, "ssid=");
						if (start != NULL) {
							char *end = strstr(resp->headers[i].szValue, ";");
							start = start + 5;
							if (end == NULL) {
								end = resp->headers[i].szValue + mir_strlen(resp->headers[i].szValue);
							}
							strncpy(cookie, start, (end - start));
							break;
						}
					}
				}
			}
			CallService(MS_NETLIB_FREEHTTPREQUESTSTRUCT, 0, (LPARAM)resp);
		}
	}
	mir_free(login);
	mir_free(password);

	mir_snprintf(szFileName, "http://poczta.o2.pl/login.html?sid=%s", cookie);
	Utils_OpenUrl(szFileName);
	return 0;
}
Exemplo n.º 16
0
static INT_PTR CALLBACK DlgProcAccMgrUI(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
{
    switch (msg) {
    case WM_INITDIALOG:
        TranslateDialogDefault(hwndDlg);
        {
            SetWindowLongPtr(hwndDlg, GWLP_USERDATA, lParam);

            CMsnProto* proto = (CMsnProto*)lParam;
            SetDlgItemTextA(hwndDlg, IDC_HANDLE, proto->MyOptions.szEmail);

            char tBuffer[MAX_PATH];
            if (!db_get_static(NULL, proto->m_szModuleName, "Password", tBuffer, sizeof(tBuffer))) {
                tBuffer[16] = 0;
                SetDlgItemTextA(hwndDlg, IDC_PASSWORD, tBuffer);
            }
            SendDlgItemMessage(hwndDlg, IDC_PASSWORD, EM_SETLIMITTEXT, 16, 0);

            DBVARIANT dbv;
            if (!proto->getTString("Place", &dbv)) {
                SetDlgItemText(hwndDlg, IDC_PLACE, dbv.ptszVal);
                db_free(&dbv);
            }
        }
        return TRUE;

    case WM_COMMAND:
        if (LOWORD(wParam) == IDC_NEWMSNACCOUNTLINK) {
            Utils_OpenUrl("https://signup.live.com");
            return TRUE;
        }

        if (HIWORD(wParam) == EN_CHANGE && (HWND)lParam == GetFocus()) {
            switch (LOWORD(wParam)) {
            case IDC_HANDLE:
            case IDC_PASSWORD:
                SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
            }
        }
        break;

    case WM_NOTIFY:
        if (((LPNMHDR)lParam)->code == (UINT)PSN_APPLY) {
            char  password[100], szEmail[MSN_MAX_EMAIL_LEN];
            DBVARIANT dbv;

            CMsnProto* proto = (CMsnProto*)GetWindowLongPtr(hwndDlg, GWLP_USERDATA);

            GetDlgItemTextA(hwndDlg, IDC_HANDLE, szEmail, _countof(szEmail));
            if (mir_strcmp(szEmail, proto->MyOptions.szEmail)) {
                mir_strcpy(proto->MyOptions.szEmail, szEmail);
                proto->setString("e-mail", szEmail);
                proto->setString("wlid", szEmail);
                proto->setDword("netId", (proto->MyOptions.netId = proto->GetMyNetID()));
            }

            GetDlgItemTextA(hwndDlg, IDC_PASSWORD, password, _countof(password));
            if (!proto->getString("Password", &dbv)) {
                if (mir_strcmp(password, dbv.pszVal))
                    proto->setString("Password", password);
                db_free(&dbv);
            }
            else proto->setString("Password", password);

            TCHAR szPlace[64];
            GetDlgItemText(hwndDlg, IDC_PLACE, szPlace, _countof(szPlace));
            if (szPlace[0])
                proto->setTString("Place", szPlace);
            else
                proto->delSetting("Place");

            return TRUE;
        }
        break;
    }

    return FALSE;
}
Exemplo n.º 17
0
INT_PTR CALLBACK DlgProcPopSkinsOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
{
	static bool bDlgInit = false;	// some controls send WM_COMMAND before or during WM_INITDIALOG
	static HANDLE hhkFontsReload = 0;
	static OPTTREE_OPTION *skinOptions = NULL;
	static int skinOptionsCount = 0;

	if (skinOptions) {
		int index = -1;
		OptTree_ProcessMessage(hwndDlg, msg, wParam, lParam, &index, IDC_SKIN_LIST_OPT, skinOptions, skinOptionsCount);
		if (index != -1) {
			if (mir_tstrcmp(skinOptions[index].pszSettingName, _T("Skin options")) == 0) {
				const PopupSkin *skin = 0;
				if (skin = skins.getSkin(PopupOptions.SkinPack)) {
					skin->setFlag(skinOptions[index].Data, skinOptions[index].bState ? true : false);
				}
			}
			else if (mir_tstrcmp(skinOptions[index].pszSettingName, _T("Global settings")) == 0) {
				switch (skinOptions[index].dwFlag) {
				case (1 << 0) :
					PopupOptions.DisplayTime = skinOptions[index].bState;
					break;
				case (1 << 1) :
					PopupOptions.DropShadow = skinOptions[index].bState;
					break;
				case (1 << 2) :
					PopupOptions.EnableFreeformShadows = skinOptions[index].bState;
					break;
				case (1 << 3) :
					PopupOptions.EnableAeroGlass = skinOptions[index].bState;
					break;
				case (1 << 4) :
					PopupOptions.UseWinColors = skinOptions[index].bState;
					break;
				case (1 << 5) :
					PopupOptions.UseMText = skinOptions[index].bState;
					break;
				}
			}
			updatePreviewImage(GetDlgItem(hwndDlg, IDC_PREVIEWBOX));
			return FALSE;
		}
	}

	switch (msg) {
	case WM_INITDIALOG:
		{
			// Skin List
			HWND hCtrl = GetDlgItem(hwndDlg, IDC_SKINLIST);
			ListBox_ResetContent(hCtrl);
			for (const Skins::SKINLIST *sl = skins.getSkinList(); sl; sl = sl->next) {
				DWORD dwIndex = ListBox_AddString(hCtrl, sl->name);
				ListBox_SetItemData(hCtrl, dwIndex, sl->name);
			}
			ListBox_SetCurSel(hCtrl, ListBox_FindString(hCtrl, 0, PopupOptions.SkinPack));

			// Skin List reload button
			SendDlgItemMessage(hwndDlg, IDC_BTN_RELOAD, BUTTONSETASFLATBTN, TRUE, 0);
			SendDlgItemMessage(hwndDlg, IDC_BTN_RELOAD, BM_SETIMAGE, IMAGE_ICON, (LPARAM)LoadIconEx(IDI_RELOAD));
			SendDlgItemMessage(hwndDlg, IDC_BTN_RELOAD, BUTTONADDTOOLTIP, (WPARAM)Translate("Refresh List"), 0);

			// Skin Option List
			SkinOptionList_Update(skinOptions, &skinOptionsCount, hwndDlg);

			// PreviewBox
			mir_subclassWindow(GetDlgItem(hwndDlg, IDC_PREVIEWBOX), WndProcPreviewBox);
			updatePreviewImage(GetDlgItem(hwndDlg, IDC_PREVIEWBOX));

			// hooks
			hhkFontsReload = HookEventMessage(ME_FONT_RELOAD, hwndDlg, WM_USER);

			TranslateDialogDefault(hwndDlg);
			bDlgInit = true;
		}
		return TRUE;

	case WM_USER:
		updatePreviewImage(GetDlgItem(hwndDlg, IDC_PREVIEWBOX));
		return TRUE;

	case WM_COMMAND:
		{
			HWND hCtrl = NULL;
			UINT idCtrl = LOWORD(wParam);
			switch (HIWORD(wParam)) {
			case BN_KILLFOCUS:		// Button controls
			case BN_SETFOCUS:		// Button controls
				return TRUE;

			case BN_CLICKED:		// Button controls
				switch (idCtrl) {
				case IDC_PREVIEW:
					PopupPreview();
					break;

				case IDC_GETSKINS:
					Utils_OpenUrl("http://miranda-ng.org/addons/category/13");
					break;

				case IDC_BTN_RELOAD:
					LPTSTR pszOldSkin = NEWTSTR_ALLOCA(PopupOptions.SkinPack);
					skins.load();
					hCtrl = GetDlgItem(hwndDlg, IDC_SKINLIST);
					ListBox_ResetContent(hCtrl);
					for (const Skins::SKINLIST *sl = skins.getSkinList(); sl; sl = sl->next) {
						DWORD dwIndex = ListBox_AddString(hCtrl, sl->name);
						ListBox_SetItemData(hCtrl, dwIndex, sl->name);
					}
					ListBox_SetCurSel(hCtrl, ListBox_FindString(hCtrl, 0, PopupOptions.SkinPack));

					// make shure we have select skin (ListBox_SetCurSel may be fail)
					TCHAR szNewSkin[128];
					ListBox_GetText(hCtrl, ListBox_GetCurSel(hCtrl), &szNewSkin);
					if (mir_tstrcmp(pszOldSkin, szNewSkin) != 0) {
						mir_free(PopupOptions.SkinPack);
						PopupOptions.SkinPack = mir_tstrdup(szNewSkin);
					}

					const PopupSkin *skin = 0;
					if (skin = skins.getSkin(PopupOptions.SkinPack)) {
						// update Skin Option List from reload SkinPack
						bDlgInit = false;
						bDlgInit = SkinOptionList_Update(skinOptions, &skinOptionsCount, hwndDlg);
					}

					SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
					break;
				}
				updatePreviewImage(GetDlgItem(hwndDlg, IDC_PREVIEWBOX));
				break;

			case CBN_SELCHANGE:		// combo box controls
				switch (idCtrl) {
				case IDC_SKINLIST:
					{
						// Skin list change
						mir_free(PopupOptions.SkinPack);
						PopupOptions.SkinPack = mir_tstrdup((TCHAR *)SendDlgItemMessage(
							hwndDlg,
							IDC_SKINLIST,
							LB_GETITEMDATA,
							(WPARAM)SendDlgItemMessage(hwndDlg, IDC_SKINLIST, LB_GETCURSEL, 0, 0),
							0));
						const PopupSkin *skin = 0;
						if (skin = skins.getSkin(PopupOptions.SkinPack)) {
							mir_free(PopupOptions.SkinPack);
							PopupOptions.SkinPack = mir_tstrdup(skin->getName());

							// update Skin Option List
							bDlgInit = false;
							bDlgInit = SkinOptionList_Update(skinOptions, &skinOptionsCount, hwndDlg);
						}
						updatePreviewImage(GetDlgItem(hwndDlg, IDC_PREVIEWBOX));
					}
					SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
					break;
				}// end switch(idCtrl)
				break;
			}// end switch (HIWORD(wParam))
			break;
		}//  end WM_COMMAND

	case WM_NOTIFY:
		if (!bDlgInit) return FALSE;
		switch (((LPNMHDR)lParam)->idFrom) {
		case 0:
			switch (((LPNMHDR)lParam)->code) {
			case PSN_RESET:
				LoadOption_Skins();
				return TRUE;

			case PSN_APPLY:
				{
					// skin pack
					db_set_ts(NULL, MODULNAME, "SkinPack", PopupOptions.SkinPack);
					// skin options
					const PopupSkin *skin = 0;
					if (skin = skins.getSkin(PopupOptions.SkinPack))
						skin->saveOpts();
					skins.freeAllButActive();
					// more Skin options
					db_set_b(NULL, MODULNAME, "DisplayTime", PopupOptions.DisplayTime);
					db_set_b(NULL, MODULNAME, "DropShadow", PopupOptions.DropShadow);
					db_set_b(NULL, MODULNAME, "EnableShadowRegion", PopupOptions.EnableFreeformShadows);
					db_set_b(NULL, MODULNAME, "EnableAeroGlass", PopupOptions.EnableAeroGlass);
					db_set_b(NULL, MODULNAME, "UseMText", PopupOptions.UseMText);
				}// end PSN_APPLY:
				return TRUE;
			}// switch (((LPNMHDR)lParam)->code)
			break;
		}// end switch (((LPNMHDR)lParam)->idFrom)
		return FALSE;

	case WM_DESTROY:
		if (wndPreview) {
			delete wndPreview;
			wndPreview = NULL;
			gPreviewOk = false;
		}
		if (hhkFontsReload) UnhookEvent(hhkFontsReload);
		if (skinOptions) {
			for (int i = 0; i < skinOptionsCount; ++i) {
				mir_free(skinOptions[i].pszOptionName);
				mir_free(skinOptions[i].pszSettingName);
			}
			mir_free(skinOptions);
			skinOptions = NULL;
			skinOptionsCount = 0;
		}
		return TRUE;
	}// end switch (msg)
	return FALSE;
}
Exemplo n.º 18
0
INT_PTR CALLBACK DlgProcContainerOptions(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
{
	HWND hwndTree = GetDlgItem(hwndDlg, IDC_SECTIONTREE);
	TContainerData *pContainer = (TContainerData*)GetWindowLongPtr(hwndDlg, GWLP_USERDATA);

	switch (msg) {
	case WM_INITDIALOG: {
		TVINSERTSTRUCT 	tvis = { 0 };
		int nr_layouts = 0;
		const TSideBarLayout *sblayouts = CSideBar::getLayouts(nr_layouts);

		SetWindowLongPtr(hwndDlg, GWLP_USERDATA, (LONG_PTR)lParam);
		pContainer = (TContainerData*)lParam;
		pContainer->hWndOptions = hwndDlg;
		TranslateDialogDefault(hwndDlg);
		SetWindowText(hwndDlg, TranslateT("Container options"));
		TCHAR szNewTitle[128];
		mir_sntprintf(szNewTitle, _T("%s"), !mir_tstrcmp(pContainer->szName, _T("default")) ?
			TranslateT("Default container") : pContainer->szName);
		SetDlgItemText(hwndDlg, IDC_HEADERBAR, szNewTitle);
		Utils::enableDlgControl(hwndDlg, IDC_O_HIDETITLE, !CSkin::m_frameSkins);
		CheckDlgButton(hwndDlg, IDC_CNTPRIVATE, pContainer->settings->fPrivate ? BST_CHECKED : BST_UNCHECKED);

		SendDlgItemMessage(hwndDlg, IDC_TABMODE, CB_INSERTSTRING, -1, (LPARAM)TranslateT("Tabs at the top"));
		SendDlgItemMessage(hwndDlg, IDC_TABMODE, CB_INSERTSTRING, -1, (LPARAM)TranslateT("Tabs at the bottom"));
		SendDlgItemMessage(hwndDlg, IDC_TABMODE, CB_INSERTSTRING, -1, (LPARAM)TranslateT("Switch bar on the left side"));
		SendDlgItemMessage(hwndDlg, IDC_TABMODE, CB_INSERTSTRING, -1, (LPARAM)TranslateT("Switch bar on the right side"));

		SendDlgItemMessage(hwndDlg, IDC_AVATARMODE, CB_INSERTSTRING, -1, (LPARAM)TranslateT("Globally on"));
		SendDlgItemMessage(hwndDlg, IDC_AVATARMODE, CB_INSERTSTRING, -1, (LPARAM)TranslateT("On, if present"));
		SendDlgItemMessage(hwndDlg, IDC_AVATARMODE, CB_INSERTSTRING, -1, (LPARAM)TranslateT("Globally OFF"));
		SendDlgItemMessage(hwndDlg, IDC_AVATARMODE, CB_INSERTSTRING, -1, (LPARAM)TranslateT("On, if present, always in bottom display"));

		SendDlgItemMessage(hwndDlg, IDC_OWNAVATARMODE, CB_INSERTSTRING, -1, (LPARAM)TranslateT("On, if present"));
		SendDlgItemMessage(hwndDlg, IDC_OWNAVATARMODE, CB_INSERTSTRING, -1, (LPARAM)TranslateT("Don't show them"));

		for (int i = 0; i < nr_layouts; i++)
			SendDlgItemMessage(hwndDlg, IDC_SBARLAYOUT, CB_INSERTSTRING, -1, (LPARAM)TranslateTS(sblayouts[i].szName));

		/* bits 24 - 31 of dwFlagsEx hold the side bar layout id */
		SendDlgItemMessage(hwndDlg, IDC_SBARLAYOUT, CB_SETCURSEL, (WPARAM)((pContainer->settings->dwFlagsEx & 0xff000000) >> 24), 0);


		SendMessage(hwndDlg, DM_SC_INITDIALOG, 0, (LPARAM)pContainer->settings);
		SendDlgItemMessage(hwndDlg, IDC_TITLEFORMAT, EM_LIMITTEXT, TITLE_FORMATLEN - 1, 0);
		SetDlgItemText(hwndDlg, IDC_TITLEFORMAT, pContainer->settings->szTitleFormat);
		SetDlgItemText(hwndDlg, IDC_THEME, pContainer->szRelThemeFile);
		for (int i = 0; i < NR_O_PAGES; i++) {
			tvis.hParent = NULL;
			tvis.hInsertAfter = TVI_LAST;
			tvis.item.mask = TVIF_TEXT | TVIF_PARAM;
			tvis.item.pszText = TranslateTS(o_pages[i].szTitle);
			tvis.item.lParam = i;
			HTREEITEM hItem = TreeView_InsertItem(hwndTree, &tvis);
			if (i == 0)
				SendMessage(hwndTree, TVM_SELECTITEM, TVGN_CARET, (LPARAM)hItem);
			for (int j = 0; j < NR_O_OPTIONSPERPAGE && o_pages[i].uIds[j] != 0; j++)
				Utils::showDlgControl(hwndDlg, o_pages[i].uIds[j], SW_HIDE);
			ShowPage(hwndDlg, i, FALSE);
		}
		SendMessage(hwndDlg, WM_SETICON, ICON_SMALL, (LPARAM)Skin_LoadIcon(SKINICON_EVENT_MESSAGE));
		SendMessage(hwndDlg, WM_SETICON, ICON_BIG, (LPARAM)Skin_LoadIcon(SKINICON_EVENT_MESSAGE, true));
		ShowPage(hwndDlg, 0, TRUE);
		SetFocus(hwndTree);
		Utils::enableDlgControl(hwndDlg, IDC_APPLY, false);

		HFONT hFont = (HFONT)SendDlgItemMessage(hwndDlg, IDC_DESC, WM_GETFONT, 0, 0);
		LOGFONT lf = { 0 };

		GetObject(hFont, sizeof(lf), &lf);
		lf.lfHeight = (int)(lf.lfHeight * 1.2);
		hFont = CreateFontIndirect(&lf);

		SendDlgItemMessage(hwndDlg, IDC_TITLEBOX, WM_SETFONT, (WPARAM)hFont, TRUE);

		if (pContainer->isCloned && pContainer->hContactFrom != 0) {
			Utils::showDlgControl(hwndDlg, IDC_CNTPRIVATE, SW_HIDE);
			Utils::showDlgControl(hwndDlg, IDC_O_CNTPRIVATE, SW_HIDE);
		}
		return FALSE;
	}

	case WM_CTLCOLOREDIT:
	case WM_CTLCOLORSTATIC:
	{
		HWND hwndChild = (HWND)lParam;
		UINT id = GetDlgCtrlID(hwndChild);

		if (hwndChild == GetDlgItem(hwndDlg, IDC_TITLEBOX))
			::SetTextColor((HDC)wParam, RGB(60, 60, 150));
		else if (hwndChild == GetDlgItem(hwndDlg, IDC_DESC))
			::SetTextColor((HDC)wParam, RGB(160, 50, 50));
		
		if (id == IDC_TSLABEL_REOPENWARN)
			break;
		SetBkColor((HDC)wParam, GetSysColor(COLOR_WINDOW));
		return (INT_PTR)GetSysColorBrush(COLOR_WINDOW);
	}

	case WM_NOTIFY:
		if (wParam == IDC_SECTIONTREE && ((LPNMHDR)lParam)->code == TVN_SELCHANGED) {
			NMTREEVIEW *pmtv = (NMTREEVIEW *)lParam;

			ShowPage(hwndDlg, pmtv->itemOld.lParam, 0);
			ShowPage(hwndDlg, pmtv->itemNew.lParam, 1);
		}
		break;

	case WM_HSCROLL:
		if ((HWND)lParam == GetDlgItem(hwndDlg, IDC_TRANSPARENCY_ACTIVE) || (HWND)lParam == GetDlgItem(hwndDlg, IDC_TRANSPARENCY_INACTIVE))
			Utils::enableDlgControl(hwndDlg, IDC_APPLY, true);
		break;

	case WM_COMMAND:
		switch (LOWORD(wParam)) {
		case IDC_CNTPRIVATE: {

			if (IsDlgButtonChecked(hwndDlg, IDC_CNTPRIVATE)) {
				Utils::ReadPrivateContainerSettings(pContainer, true);
				pContainer->settings->fPrivate = true;
			}
			else {
				if (pContainer->settings != &PluginConfig.globalContainerSettings) {
					char szCname[40];
					mir_snprintf(szCname, "%s%d_Blob", CNT_BASEKEYNAME, pContainer->iContainerIndex);
					pContainer->settings->fPrivate = false;
					db_set_blob(0, SRMSGMOD_T, szCname, pContainer->settings, sizeof(TContainerSettings));
					mir_free(pContainer->settings);
				}
				pContainer->settings = &PluginConfig.globalContainerSettings;
				pContainer->settings->fPrivate = false;
			}
			SendMessage(hwndDlg, DM_SC_INITDIALOG, 0, (LPARAM)pContainer->settings);
			goto do_apply;
		}
		case IDC_TRANSPARENCY: {
			bool isTrans = IsDlgButtonChecked(hwndDlg, IDC_TRANSPARENCY) != 0;
			Utils::enableDlgControl(hwndDlg, IDC_TRANSPARENCY_ACTIVE, isTrans);
			Utils::enableDlgControl(hwndDlg, IDC_TRANSPARENCY_INACTIVE, isTrans);
			goto do_apply;
		}
		case IDC_SECTIONTREE:
		case IDC_DESC:
			return 0;
		case IDC_SAVESIZEASGLOBAL: {
			WINDOWPLACEMENT wp = { 0 };

			wp.length = sizeof(wp);
			if (GetWindowPlacement(pContainer->hwnd, &wp)) {
				db_set_dw(0, SRMSGMOD_T, "splitx", wp.rcNormalPosition.left);
				db_set_dw(0, SRMSGMOD_T, "splity", wp.rcNormalPosition.top);
				db_set_dw(0, SRMSGMOD_T, "splitwidth", wp.rcNormalPosition.right - wp.rcNormalPosition.left);
				db_set_dw(0, SRMSGMOD_T, "splitheight", wp.rcNormalPosition.bottom - wp.rcNormalPosition.top);
			}
			break;
		}
		case IDC_O_ENABLESOUNDS:
			SendMessage(hwndDlg, DM_SC_CONFIG, 0, 0);
			break;
		case IDC_TITLEFORMAT:
			if (HIWORD(wParam) != EN_CHANGE || (HWND)lParam != GetFocus())
				return TRUE;
			goto do_apply;
		case IDC_SELECTTHEME: {
			const wchar_t *szFileName = GetThemeFileName(0);

			if (PathFileExists(szFileName)) {
				SetDlgItemText(hwndDlg, IDC_THEME, szFileName);
				goto do_apply;
			}
			break;
		}

		case IDC_O_HELP_TITLEFORMAT:
			Utils_OpenUrl("http://wiki.miranda-ng.org/index.php?title=Plugin:TabSRMM/en/Title_bar_formatting");
			break;

		case IDOK:
		case IDC_APPLY: {

			SendMessage(hwndDlg, DM_SC_BUILDLIST, 0, (LPARAM)pContainer->settings);

			pContainer->settings->dwTransparency = MAKELONG((WORD)SendDlgItemMessage(hwndDlg, IDC_TRANSPARENCY_ACTIVE, TBM_GETPOS, 0, 0),
				(WORD)SendDlgItemMessage(hwndDlg, IDC_TRANSPARENCY_INACTIVE, TBM_GETPOS, 0, 0));

			pContainer->settings->avatarMode = (WORD)SendDlgItemMessage(hwndDlg, IDC_AVATARMODE, CB_GETCURSEL, 0, 0);
			pContainer->settings->ownAvatarMode = (WORD)SendDlgItemMessage(hwndDlg, IDC_OWNAVATARMODE, CB_GETCURSEL, 0, 0);

			GetDlgItemText(hwndDlg, IDC_TITLEFORMAT, pContainer->settings->szTitleFormat, TITLE_FORMATLEN);
			pContainer->settings->szTitleFormat[TITLE_FORMATLEN - 1] = 0;

			pContainer->szRelThemeFile[0] = pContainer->szAbsThemeFile[0] = 0;

			if (GetWindowTextLength(GetDlgItem(hwndDlg, IDC_THEME)) > 0) {
				wchar_t szFinalThemeFile[MAX_PATH], szFilename[MAX_PATH];

				GetDlgItemText(hwndDlg, IDC_THEME, szFilename, _countof(szFilename));
				szFilename[MAX_PATH - 1] = 0;
				PathToAbsoluteT(szFilename, szFinalThemeFile, M.getDataPath());

				if (mir_tstrcmp(szFilename, pContainer->szRelThemeFile))
					pContainer->fPrivateThemeChanged = TRUE;

				if (PathFileExists(szFinalThemeFile))
					_tcsncpy_s(pContainer->szRelThemeFile, szFilename, _TRUNCATE);
				else
					pContainer->szRelThemeFile[0] = 0;
			}
			else {
				pContainer->szRelThemeFile[0] = 0;
				pContainer->fPrivateThemeChanged = TRUE;
			}

			Utils::SettingsToContainer(pContainer);

			if (BST_UNCHECKED == IsDlgButtonChecked(hwndDlg, IDC_CNTPRIVATE)) {
				ReloadGlobalContainerSettings(true);
				::db_set_blob(0, SRMSGMOD_T, CNT_KEYNAME, &PluginConfig.globalContainerSettings, sizeof(TContainerSettings));
			}
			else {
				char *szSetting = "CNTW_";
				Utils::SaveContainerSettings(pContainer, szSetting);
			}

			SendMessage(pContainer->hwnd, DM_CONFIGURECONTAINER, 0, 0);
			BroadCastContainer(pContainer, DM_SETINFOPANEL, 0, 0);

			ShowWindow(pContainer->hwnd, SW_HIDE);
			{
				RECT	rc;

				GetWindowRect(pContainer->hwnd, &rc);
				SetWindowPos(pContainer->hwnd, 0, rc.left, rc.top, (rc.right - rc.left) - 1, (rc.bottom - rc.top) - 1, SWP_NOZORDER | SWP_DRAWFRAME | SWP_FRAMECHANGED);
				SetWindowPos(pContainer->hwnd, 0, rc.left, rc.top, (rc.right - rc.left), (rc.bottom - rc.top), SWP_NOZORDER | SWP_DRAWFRAME | SWP_SHOWWINDOW);
			}

			if (LOWORD(wParam) == IDOK)
				DestroyWindow(hwndDlg);
			else
				Utils::enableDlgControl(hwndDlg, IDC_APPLY, false);

			break;
		}
		case IDCANCEL:
			DestroyWindow(hwndDlg);
			return TRUE;

		default:
		do_apply : Utils::enableDlgControl(hwndDlg, IDC_APPLY, true);
			break;
		}
		break;
	case DM_SC_INITDIALOG: {
		TContainerSettings* cs = (TContainerSettings *)lParam;

		DWORD dwFlags = cs->dwFlags;
		DWORD dwTransparency = cs->dwTransparency;
		DWORD dwFlagsEx = cs->dwFlagsEx;
		BOOL fAllowTrans = FALSE;

		if (PluginConfig.m_WinVerMajor >= 6)
			fAllowTrans = TRUE;
		else
			fAllowTrans = (!CSkin::m_skinEnabled);

		MY_CheckDlgButton(hwndDlg, IDC_O_HIDETITLE, dwFlags & CNT_NOTITLE);
		MY_CheckDlgButton(hwndDlg, IDC_O_DONTREPORT, dwFlags & CNT_DONTREPORT);
		MY_CheckDlgButton(hwndDlg, IDC_O_NOTABS, dwFlags & CNT_HIDETABS);
		MY_CheckDlgButton(hwndDlg, IDC_O_STICKY, dwFlags & CNT_STICKY);
		MY_CheckDlgButton(hwndDlg, IDC_O_FLASHNEVER, dwFlags & CNT_NOFLASH);
		MY_CheckDlgButton(hwndDlg, IDC_O_FLASHALWAYS, dwFlags & CNT_FLASHALWAYS);
		MY_CheckDlgButton(hwndDlg, IDC_O_FLASHDEFAULT, !((dwFlags & CNT_NOFLASH) || (dwFlags & CNT_FLASHALWAYS)));
		MY_CheckDlgButton(hwndDlg, IDC_TRANSPARENCY, dwFlags & CNT_TRANSPARENCY);
		MY_CheckDlgButton(hwndDlg, IDC_DONTREPORTUNFOCUSED2, dwFlags & CNT_DONTREPORTUNFOCUSED);
		MY_CheckDlgButton(hwndDlg, IDC_DONTREPORTFOCUSED2, dwFlags & CNT_DONTREPORTFOCUSED);
		MY_CheckDlgButton(hwndDlg, IDC_ALWAYSPOPUPSINACTIVE, dwFlags & CNT_ALWAYSREPORTINACTIVE);
		MY_CheckDlgButton(hwndDlg, IDC_CNTNOSTATUSBAR, dwFlags & CNT_NOSTATUSBAR);
		MY_CheckDlgButton(hwndDlg, IDC_HIDEMENUBAR, dwFlags & CNT_NOMENUBAR);
		MY_CheckDlgButton(hwndDlg, IDC_HIDETOOLBAR, dwFlags & CNT_HIDETOOLBAR);
		MY_CheckDlgButton(hwndDlg, IDC_BOTTOMTOOLBAR, dwFlags & CNT_BOTTOMTOOLBAR);
		MY_CheckDlgButton(hwndDlg, IDC_UIDSTATUSBAR, dwFlags & CNT_UINSTATUSBAR);
		MY_CheckDlgButton(hwndDlg, IDC_VERTICALMAX, dwFlags & CNT_VERTICALMAX);
		MY_CheckDlgButton(hwndDlg, IDC_AUTOSPLITTER, dwFlags & CNT_AUTOSPLITTER);
		MY_CheckDlgButton(hwndDlg, IDC_AVATARSONTASKBAR, dwFlags & CNT_AVATARSONTASKBAR);
		MY_CheckDlgButton(hwndDlg, IDC_INFOPANEL, dwFlags & CNT_INFOPANEL);
		MY_CheckDlgButton(hwndDlg, IDC_USEGLOBALSIZE, dwFlags & CNT_GLOBALSIZE);

		MY_CheckDlgButton(hwndDlg, IDC_FLASHICON, dwFlagsEx & TCF_FLASHICON);
		MY_CheckDlgButton(hwndDlg, IDC_FLASHLABEL, dwFlagsEx & TCF_FLASHLABEL);
		MY_CheckDlgButton(hwndDlg, IDC_CLOSEBUTTONONTABS, dwFlagsEx & TCF_CLOSEBUTTON);

		MY_CheckDlgButton(hwndDlg, IDC_SINGLEROWTAB, dwFlagsEx & TCF_SINGLEROWTABCONTROL);
		MY_CheckDlgButton(hwndDlg, IDC_BUTTONTABS, dwFlagsEx & TCF_FLAT);

		MY_CheckDlgButton(hwndDlg, IDC_O_ENABLESOUNDS, !(dwFlags & CNT_NOSOUND));
		MY_CheckDlgButton(hwndDlg, IDC_O_SOUNDSMINIMIZED, dwFlagsEx & CNT_EX_SOUNDS_MINIMIZED);
		MY_CheckDlgButton(hwndDlg, IDC_O_SOUNDSUNFOCUSED, dwFlagsEx & CNT_EX_SOUNDS_UNFOCUSED);
		MY_CheckDlgButton(hwndDlg, IDC_O_SOUNDSINACTIVE, dwFlagsEx & CNT_EX_SOUNDS_INACTIVETABS);
		MY_CheckDlgButton(hwndDlg, IDC_O_SOUNDSFOCUSED, dwFlagsEx & CNT_EX_SOUNDS_FOCUSED);

		SendMessage(hwndDlg, DM_SC_CONFIG, 0, 0);

		if (!(dwFlagsEx & (TCF_SBARLEFT | TCF_SBARRIGHT)))
			SendDlgItemMessage(hwndDlg, IDC_TABMODE, CB_SETCURSEL, dwFlags & CNT_TABSBOTTOM ? 1 : 0, 0);
		else
			SendDlgItemMessage(hwndDlg, IDC_TABMODE, CB_SETCURSEL, dwFlagsEx & TCF_SBARLEFT ? 2 : 3, 0);

		if (LOBYTE(LOWORD(GetVersion())) >= 5 && fAllowTrans)
			CheckDlgButton(hwndDlg, IDC_TRANSPARENCY, dwFlags & CNT_TRANSPARENCY ? BST_CHECKED : BST_UNCHECKED);
		else
			CheckDlgButton(hwndDlg, IDC_TRANSPARENCY, BST_UNCHECKED);

		Utils::enableDlgControl(hwndDlg, IDC_TRANSPARENCY, PluginConfig.m_WinVerMajor >= 5 && fAllowTrans);

		bool isTrans = IsDlgButtonChecked(hwndDlg, IDC_TRANSPARENCY) != 0;
		Utils::enableDlgControl(hwndDlg, IDC_TRANSPARENCY_ACTIVE, isTrans);
		Utils::enableDlgControl(hwndDlg, IDC_TRANSPARENCY_INACTIVE, isTrans);

		SendDlgItemMessage(hwndDlg, IDC_TRANSPARENCY_ACTIVE, TBM_SETRANGE, 0, (LPARAM)MAKELONG(50, 255));
		SendDlgItemMessage(hwndDlg, IDC_TRANSPARENCY_INACTIVE, TBM_SETRANGE, 0, (LPARAM)MAKELONG(50, 255));

		SendDlgItemMessage(hwndDlg, IDC_TRANSPARENCY_ACTIVE, TBM_SETPOS, TRUE, (LPARAM)LOWORD(dwTransparency));
		SendDlgItemMessage(hwndDlg, IDC_TRANSPARENCY_INACTIVE, TBM_SETPOS, TRUE, (LPARAM)HIWORD(dwTransparency));

		Utils::enableDlgControl(hwndDlg, IDC_O_DONTREPORT, !nen_options.bWindowCheck);
		Utils::enableDlgControl(hwndDlg, IDC_DONTREPORTUNFOCUSED2, !nen_options.bWindowCheck);
		Utils::enableDlgControl(hwndDlg, IDC_DONTREPORTFOCUSED2, !nen_options.bWindowCheck);
		Utils::enableDlgControl(hwndDlg, IDC_ALWAYSPOPUPSINACTIVE, !nen_options.bWindowCheck);

		SendDlgItemMessage(hwndDlg, IDC_AVATARMODE, CB_SETCURSEL, (WPARAM)cs->avatarMode, 0);
		SendDlgItemMessage(hwndDlg, IDC_OWNAVATARMODE, CB_SETCURSEL, (WPARAM)cs->ownAvatarMode, 0);

		Utils::showDlgControl(hwndDlg, IDC_O_EXPLAINGLOBALNOTIFY, nen_options.bWindowCheck ? SW_SHOW : SW_HIDE);

		SendDlgItemMessage(hwndDlg, IDC_AUTOCLOSETABSPIN, UDM_SETRANGE, 0, MAKELONG(1000, 0));
		SendDlgItemMessage(hwndDlg, IDC_AUTOCLOSETABSPIN, UDM_SETPOS, 0, (LPARAM)cs->autoCloseSeconds);
		break;
	}

	case DM_SC_CONFIG: {
		bool bEnable = IsDlgButtonChecked(hwndDlg, IDC_O_ENABLESOUNDS) != 0;
		Utils::enableDlgControl(hwndDlg, IDC_O_SOUNDSINACTIVE, bEnable);
		Utils::enableDlgControl(hwndDlg, IDC_O_SOUNDSUNFOCUSED, bEnable);
		Utils::enableDlgControl(hwndDlg, IDC_O_SOUNDSMINIMIZED, bEnable);
		Utils::enableDlgControl(hwndDlg, IDC_O_SOUNDSFOCUSED, bEnable);
		return 0;
	}

	case DM_SC_BUILDLIST: {
		DWORD dwNewFlags = 0, dwNewFlagsEx = 0;
		TContainerSettings* cs = (TContainerSettings *)lParam;

		dwNewFlags = (IsDlgButtonChecked(hwndDlg, IDC_O_HIDETITLE) ? CNT_NOTITLE : 0) |
			(IsDlgButtonChecked(hwndDlg, IDC_O_DONTREPORT) ? CNT_DONTREPORT : 0) |
			(IsDlgButtonChecked(hwndDlg, IDC_O_NOTABS) ? CNT_HIDETABS : 0) |
			(IsDlgButtonChecked(hwndDlg, IDC_O_STICKY) ? CNT_STICKY : 0) |
			(IsDlgButtonChecked(hwndDlg, IDC_O_FLASHALWAYS) ? CNT_FLASHALWAYS : 0) |
			(IsDlgButtonChecked(hwndDlg, IDC_O_FLASHNEVER) ? CNT_NOFLASH : 0) |
			(IsDlgButtonChecked(hwndDlg, IDC_TRANSPARENCY) ? CNT_TRANSPARENCY : 0) |
			(IsDlgButtonChecked(hwndDlg, IDC_DONTREPORTUNFOCUSED2) ? CNT_DONTREPORTUNFOCUSED : 0) |
			(IsDlgButtonChecked(hwndDlg, IDC_DONTREPORTFOCUSED2) ? CNT_DONTREPORTFOCUSED : 0) |
			(IsDlgButtonChecked(hwndDlg, IDC_ALWAYSPOPUPSINACTIVE) ? CNT_ALWAYSREPORTINACTIVE : 0) |
			(IsDlgButtonChecked(hwndDlg, IDC_CNTNOSTATUSBAR) ? CNT_NOSTATUSBAR : 0) |
			(IsDlgButtonChecked(hwndDlg, IDC_HIDEMENUBAR) ? CNT_NOMENUBAR : 0) |
			(IsDlgButtonChecked(hwndDlg, IDC_HIDETOOLBAR) ? CNT_HIDETOOLBAR : 0) |
			(IsDlgButtonChecked(hwndDlg, IDC_BOTTOMTOOLBAR) ? CNT_BOTTOMTOOLBAR : 0) |
			(IsDlgButtonChecked(hwndDlg, IDC_UIDSTATUSBAR) ? CNT_UINSTATUSBAR : 0) |
			(IsDlgButtonChecked(hwndDlg, IDC_USEGLOBALSIZE) ? CNT_GLOBALSIZE : 0) |
			(IsDlgButtonChecked(hwndDlg, IDC_INFOPANEL) ? CNT_INFOPANEL : 0) |
			(IsDlgButtonChecked(hwndDlg, IDC_O_ENABLESOUNDS) ? 0 : CNT_NOSOUND) |
			(IsDlgButtonChecked(hwndDlg, IDC_AVATARSONTASKBAR) ? CNT_AVATARSONTASKBAR : 0) |
			(IsDlgButtonChecked(hwndDlg, IDC_VERTICALMAX) ? CNT_VERTICALMAX : 0) |
			(IsDlgButtonChecked(hwndDlg, IDC_AUTOSPLITTER) ? CNT_AUTOSPLITTER : 0) |
			(CNT_NEWCONTAINERFLAGS);

		LRESULT iTabMode = SendDlgItemMessage(hwndDlg, IDC_TABMODE, CB_GETCURSEL, 0, 0);
		LRESULT iTabLayout = SendDlgItemMessage(hwndDlg, IDC_SBARLAYOUT, CB_GETCURSEL, 0, 0);

		dwNewFlagsEx = 0;

		if (iTabMode < 2)
			dwNewFlags = ((iTabMode == 1) ? (dwNewFlags | CNT_TABSBOTTOM) : (dwNewFlags & ~CNT_TABSBOTTOM));
		else {
			dwNewFlags &= ~CNT_TABSBOTTOM;
			dwNewFlagsEx = iTabMode == 2 ? TCF_SBARLEFT : TCF_SBARRIGHT;
		}

		dwNewFlagsEx |= ((IsDlgButtonChecked(hwndDlg, IDC_FLASHICON) ? TCF_FLASHICON : 0) |
			(IsDlgButtonChecked(hwndDlg, IDC_FLASHLABEL) ? TCF_FLASHLABEL : 0) |
			(IsDlgButtonChecked(hwndDlg, IDC_BUTTONTABS) ? TCF_FLAT : 0) |
			(IsDlgButtonChecked(hwndDlg, IDC_CLOSEBUTTONONTABS) ? TCF_CLOSEBUTTON : 0) |
			(IsDlgButtonChecked(hwndDlg, IDC_SINGLEROWTAB) ? TCF_SINGLEROWTABCONTROL : 0) |
			(IsDlgButtonChecked(hwndDlg, IDC_O_SOUNDSMINIMIZED) ? CNT_EX_SOUNDS_MINIMIZED : 0) |
			(IsDlgButtonChecked(hwndDlg, IDC_O_SOUNDSUNFOCUSED) ? CNT_EX_SOUNDS_UNFOCUSED : 0) |
			(IsDlgButtonChecked(hwndDlg, IDC_O_SOUNDSFOCUSED) ? CNT_EX_SOUNDS_FOCUSED : 0) |
			(IsDlgButtonChecked(hwndDlg, IDC_O_SOUNDSINACTIVE) ? CNT_EX_SOUNDS_INACTIVETABS : 0)
			);

		/* bits 24 - 31 of dwFlagsEx hold the sidebar layout id */
		dwNewFlagsEx |= ((int)((iTabLayout << 24) & 0xff000000));

		if (IsDlgButtonChecked(hwndDlg, IDC_O_FLASHDEFAULT))
			dwNewFlags &= ~(CNT_FLASHALWAYS | CNT_NOFLASH);

		cs->dwFlags = dwNewFlags;
		cs->dwFlagsEx = dwNewFlagsEx;
		cs->autoCloseSeconds = (WORD)SendDlgItemMessage(hwndDlg, IDC_AUTOCLOSETABSPIN, UDM_GETPOS, 0, 0);
		break;
	}
	case WM_DESTROY: {
		pContainer->hWndOptions = 0;
		SetWindowLongPtr(hwndDlg, GWLP_USERDATA, 0);

		HFONT hFont = (HFONT)SendDlgItemMessage(hwndDlg, IDC_TITLEBOX, WM_GETFONT, 0, 0);
		DeleteObject(hFont);
		break;
	}
	}
	return FALSE;
}
Exemplo n.º 19
0
INT_PTR CIcqProto::OpenWebProfile(WPARAM hContact, LPARAM)
{
	Utils_OpenUrl(CMStringA(FORMAT, "http://www.icq.com/people/%d", getContactUin(hContact)));
	return 0;
}
Exemplo n.º 20
0
INT_PTR CALLBACK DlgLangpackOpt(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
{
	HWND hwndList = GetDlgItem(hwndDlg, IDC_LANGUAGES);

	switch (msg) {
	case WM_INITDIALOG:
		TranslateDialogDefault(hwndDlg);
		ComboBox_ResetContent(hwndList);
		EnumLangpacks(InsertPackItemEnumProc, (WPARAM)hwndList, (LPARAM)0);
		return TRUE;

	case WM_COMMAND:
		switch (LOWORD(wParam)) {
		case IDC_LANGEMAIL:
			{
				char buf[512];
				mir_strcpy(buf, "mailto:");
				if (GetDlgItemTextA(hwndDlg, LOWORD(wParam), &buf[7], _countof(buf) - 7))
					Utils_OpenUrl(buf);
			}
			break;

		case IDC_MORELANG:
			Utils_OpenUrl("http://wiki.miranda-ng.org/index.php?title=Langpacks/en#Download");
			break;

		case IDC_LANGUAGES:
			if (HIWORD(wParam) == CBN_SELCHANGE) {
				int idx = ComboBox_GetCurSel(hwndList);
				LANGPACK_INFO *pack = (LANGPACK_INFO*)ComboBox_GetItemData(hwndList, idx);
				DisplayPackInfo(hwndDlg, pack);
				if (!(pack->flags & LPF_ENABLED))
					SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
				EnableWindow(GetDlgItem(hwndDlg, IDC_RELOAD), (pack->flags & LPF_ENABLED) && !(pack->flags & LPF_DEFAULT));
			}
			break;

		case IDC_RELOAD:
			{
				EnableWindow(GetDlgItem(hwndDlg, IDC_RELOAD), FALSE);
				int idx = ComboBox_GetCurSel(hwndList);
				LANGPACK_INFO *pack = (LANGPACK_INFO*)ComboBox_GetItemData(hwndList, idx);
				ReloadLangpack(pack->tszFullPath);
				DisplayPackInfo(hwndDlg, pack);
				EnableWindow(GetDlgItem(hwndDlg, IDC_RELOAD), TRUE);
			}
			break;
		}
		break;

	case WM_NOTIFY:
		if (LPNMHDR(lParam)->code == PSN_APPLY) {
			TCHAR tszPath[MAX_PATH]; tszPath[0] = 0;
			int idx = ComboBox_GetCurSel(hwndList);
			int count = ComboBox_GetCount(hwndList);
			for (int i = 0; i < count; i++) {
				LANGPACK_INFO *pack = (LANGPACK_INFO*)ComboBox_GetItemData(hwndList, i);
				if (i == idx) {
					db_set_ts(NULL, "Langpack", "Current", pack->tszFileName);
					mir_tstrcpy(tszPath, pack->tszFullPath);
					pack->flags |= LPF_ENABLED;
				}
				else pack->flags &= ~LPF_ENABLED;
			}

			if (tszPath[0]) {
				ReloadLangpack(tszPath);

				if (LPPSHNOTIFY(lParam)->lParam == IDC_APPLY) {
					HWND hwndParent = GetParent(hwndDlg);
					PostMessage(hwndParent, WM_CLOSE, 1, 0);
					mir_forkthread(ReloadOptions, hwndParent);
				}
			}
		}
		break;

	case WM_DESTROY:
		int count = ListBox_GetCount(hwndList);
		for (int i = 0; i < count; i++)
			delete (LANGPACK_INFO*)ListBox_GetItemData(hwndList, i);
		ComboBox_ResetContent(hwndList);
		return TRUE;
	}
	return FALSE;
}
Exemplo n.º 21
0
INT_PTR CALLBACK DlgPluginOpt(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
{
	switch (msg) {
	case WM_INITDIALOG:
		TranslateDialogDefault(hwndDlg);
		timerID = 0;
		{
			HWND hwndList = GetDlgItem(hwndDlg, IDC_PLUGLIST);
			mir_subclassWindow(hwndList, PluginListWndProc);

			HIMAGELIST hIml = ImageList_Create(16, 16, ILC_MASK | ILC_COLOR32, 4, 0);
			ImageList_AddIcon_IconLibLoaded(hIml, SKINICON_OTHER_UNICODE);
			ImageList_AddIcon_IconLibLoaded(hIml, SKINICON_OTHER_ANSI);
			ImageList_AddIcon_IconLibLoaded(hIml, SKINICON_OTHER_LOADED);
			ImageList_AddIcon_IconLibLoaded(hIml, SKINICON_OTHER_NOTLOADED);
			ImageList_AddIcon_IconLibLoaded(hIml, SKINICON_OTHER_LOADEDGRAY);
			ImageList_AddIcon_IconLibLoaded(hIml, SKINICON_OTHER_NOTLOADEDGRAY);
			ListView_SetImageList(hwndList, hIml, LVSIL_SMALL);

			LVCOLUMN col;
			col.mask = LVCF_TEXT | LVCF_WIDTH;
			col.pszText = _T("");
			col.cx = 40;
			ListView_InsertColumn(hwndList, 0, &col);

			col.pszText = TranslateT("Plugin");
			col.cx = 180;
			ListView_InsertColumn(hwndList, 1, &col);

			col.pszText = TranslateT("Name");
			col.cx = 180;//max = 220;
			ListView_InsertColumn(hwndList, 2, &col);

			col.pszText = TranslateT("Version");
			col.cx = 75;
			ListView_InsertColumn(hwndList, 3, &col);

			ListView_SetExtendedListViewStyleEx(hwndList, 0, LVS_EX_SUBITEMIMAGES | LVS_EX_CHECKBOXES | LVS_EX_LABELTIP | LVS_EX_FULLROWSELECT);
			// scan the plugin dir for plugins, cos
			arPluginList.destroy();
			szFilter.Empty();
			enumPlugins(dialogListPlugins, (WPARAM)hwndDlg, (LPARAM)hwndList);
			// sort out the headers

			ListView_SetColumnWidth(hwndList, 1, LVSCW_AUTOSIZE); // dll name
			int w = ListView_GetColumnWidth(hwndList, 1);
			if (w > 110) {
				ListView_SetColumnWidth(hwndList, 1, w = 110);
			}
			int max = w < 110 ? 189 + 110 - w : 189;
			ListView_SetColumnWidth(hwndList, 3, LVSCW_AUTOSIZE); // short name
			w = ListView_GetColumnWidth(hwndList, 2);
			if (w > max)
				ListView_SetColumnWidth(hwndList, 2, max);

			ListView_SortItems(hwndList, SortPlugins, (LPARAM)hwndDlg);
		}
		return TRUE;

	case WM_NOTIFY:
		if (lParam) {
			NMLISTVIEW *hdr = (NMLISTVIEW *)lParam;
			if (hdr->hdr.code == LVN_ITEMCHANGED && IsWindowVisible(hdr->hdr.hwndFrom)) {
				if (hdr->uOldState != 0 && (hdr->uNewState == 0x1000 || hdr->uNewState == 0x2000)) {
					HWND hwndList = GetDlgItem(hwndDlg, IDC_PLUGLIST);

					LVITEM it;
					it.mask = LVIF_PARAM | LVIF_STATE;
					it.iItem = hdr->iItem;
					if (!ListView_GetItem(hwndList, &it))
						break;

					PluginListItemData *dat = (PluginListItemData*)it.lParam;
					if (dat->flags & STATIC_PLUGIN) {
						ListView_SetItemState(hwndList, hdr->iItem, 0x3000, LVIS_STATEIMAGEMASK);
						return FALSE;
					}
					// find all another standard plugins by mask and disable them
					if ((hdr->uNewState == 0x2000) && dat->stdPlugin != 0) {
						for (int iRow = 0; iRow != -1; iRow = ListView_GetNextItem(hwndList, iRow, LVNI_ALL)) {
							if (iRow != hdr->iItem) { // skip the plugin we're standing on
								LVITEM dt;
								dt.mask = LVIF_PARAM;
								dt.iItem = iRow;
								if (ListView_GetItem(hwndList, &dt)) {
									PluginListItemData *dat2 = (PluginListItemData*)dt.lParam;
									if (dat2->stdPlugin & dat->stdPlugin) {// mask differs
										// the lParam is unset, so when the check is unset the clist block doesnt trigger
										int iSave = dat2->stdPlugin;
										dat2->stdPlugin = 0;
										ListView_SetItemState(hwndList, iRow, 0x1000, LVIS_STATEIMAGEMASK);
										dat2->stdPlugin = iSave;
									}
								}
							}
						}
					}

					if (bOldMode)
						ShowWindow(GetDlgItem(hwndDlg, IDC_RESTART), TRUE); // this here only in "ghazan mode"
					SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
					break;
				}

				if (hdr->iItem != -1) {
					int sel = hdr->uNewState & LVIS_SELECTED;
					HWND hwndList = GetDlgItem(hwndDlg, IDC_PLUGLIST);
					LVITEM lvi = { 0 };
					lvi.mask = LVIF_PARAM;
					lvi.iItem = hdr->iItem;
					if (ListView_GetItem(hwndList, &lvi)) {
						PluginListItemData *dat = (PluginListItemData*)lvi.lParam;

						TCHAR buf[1024];
						ListView_GetItemText(hwndList, hdr->iItem, 2, buf, _countof(buf));
						SetDlgItemText(hwndDlg, IDC_PLUGININFOFRAME, sel ? buf : _T(""));

						ptrT tszAuthor(latin2t(sel ? dat->author : NULL));
						SetDlgItemText(hwndDlg, IDC_PLUGINAUTHOR, tszAuthor);

						ptrT tszEmail(latin2t(sel ? dat->authorEmail : NULL));
						SetDlgItemText(hwndDlg, IDC_PLUGINEMAIL, tszEmail);

						ptrT p(Langpack_PcharToTchar(dat->description));
						SetDlgItemText(hwndDlg, IDC_PLUGINLONGINFO, sel ? p : _T(""));

						ptrT tszCopyright(latin2t(sel ? dat->copyright : NULL));
						SetDlgItemText(hwndDlg, IDC_PLUGINCPYR, tszCopyright);

						ptrT tszUrl(latin2t(sel ? dat->homepage : NULL));
						SetDlgItemText(hwndDlg, IDC_PLUGINURL, tszUrl);

						if (!equalUUID(miid_last, dat->uuid)) {
							char szUID[128];
							uuidToString(dat->uuid, szUID, sizeof(szUID));
							SetDlgItemTextA(hwndDlg, IDC_PLUGINPID, sel ? szUID : "");
						}
						else SetDlgItemText(hwndDlg, IDC_PLUGINPID, sel ? TranslateT("<none>") : _T(""));
					}
				}
			}

			if (hdr->hdr.code == PSN_APPLY) {
				bool needRestart = false;
				TCHAR bufRestart[1024];
				int bufLen = mir_sntprintf(bufRestart, _T("%s\n"), TranslateT("Miranda NG must be restarted to apply changes for these plugins:"));

				HWND hwndList = GetDlgItem(hwndDlg, IDC_PLUGLIST);
				for (int iRow = 0; iRow != -1;) {
					TCHAR buf[1024];
					ListView_GetItemText(hwndList, iRow, 1, buf, _countof(buf));
					int iState = ListView_GetItemState(hwndList, iRow, LVIS_STATEIMAGEMASK);
					SetPluginOnWhiteList(buf, (iState & 0x2000) ? 1 : 0);

					if (!bOldMode && iState != 0x3000) {
						LVITEM lvi = { 0 };
						lvi.mask = LVIF_IMAGE | LVIF_PARAM;
						lvi.stateMask = -1;
						lvi.iItem = iRow;
						lvi.iSubItem = 0;
						if (ListView_GetItem(hwndList, &lvi)) {
							lvi.mask = LVIF_IMAGE;

							PluginListItemData *dat = (PluginListItemData*)lvi.lParam;
							if (iState == 0x2000) {
								// enabling plugin
								if (lvi.iImage == 3 || lvi.iImage == 5) {
									if (lvi.iImage == 3 && LoadPluginDynamically(dat)) {
										lvi.iImage = 2;
										ListView_SetItem(hwndList, &lvi);
									}
									else {
										bufLen += mir_sntprintf(bufRestart + bufLen, _countof(bufRestart) - bufLen, _T(" - %s\n"), buf);
										needRestart = true;
									}
								}
							}
							else {
								// disabling plugin
								if (lvi.iImage == 2 || lvi.iImage == 4) {
									if (lvi.iImage == 2 && UnloadPluginDynamically(dat)) {
										lvi.iImage = 3;
										ListView_SetItem(hwndList, &lvi);
									}
									else {
										bufLen += mir_sntprintf(bufRestart + bufLen, _countof(bufRestart) - bufLen, _T(" - %s\n"), buf);
										needRestart = true;
									}
								}
							}
						}
					}

					iRow = ListView_GetNextItem(hwndList, iRow, LVNI_ALL);
				}
				LoadStdPlugins();

				ShowWindow(GetDlgItem(hwndDlg, IDC_RESTART), needRestart);
				if (needRestart) {
					mir_sntprintf(bufRestart + bufLen, _countof(bufRestart) - bufLen, _T("\n%s"), TranslateT("Do you want to restart it now?"));
					if (MessageBox(NULL, bufRestart, _T("Miranda NG"), MB_ICONWARNING | MB_YESNO) == IDYES)
						CallService(MS_SYSTEM_RESTART, 1, 0);
				}
			}
		}
		break;

	case WM_COMMAND:
		if (HIWORD(wParam) == STN_CLICKED) {
			switch (LOWORD(wParam)) {
			case IDC_GETMOREPLUGINS:
				Utils_OpenUrl("http://miranda-ng.org/downloads/");
				break;

			case IDC_PLUGINEMAIL:
			case IDC_PLUGINURL:
				char buf[512];
				char *p = &buf[7];
				mir_strcpy(buf, "mailto:");
				if (GetDlgItemTextA(hwndDlg, LOWORD(wParam), p, _countof(buf) - 7))
					Utils_OpenUrl(LOWORD(wParam) == IDC_PLUGINEMAIL ? buf : p);
				break;
			}
		}
		break;

	case WM_DESTROY:
		arPluginList.destroy();
		RemoveAllItems(GetDlgItem(hwndDlg, IDC_PLUGLIST));
		break;
	}
	return FALSE;
}
Exemplo n.º 22
0
INT_PTR CALLBACK OptionsProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
{
	switch (msg) {
	case WM_INITDIALOG:
		TranslateDialogDefault(hwndDlg);
		{
			SYSTEMTIME systime = { 0 };

			SendDlgItemMessage(hwndDlg, IDC_MAXCHANNEL, CB_RESETCONTENT, 0, 0);
			for (int i = 1; i <= MAXCHAN; i++)
				SendDlgItemMessage(hwndDlg, IDC_MAXCHANNEL, CB_ADDSTRING, 0, (LPARAM)_itot(i, tmp, 10));

			SendDlgItemMessage(hwndDlg, IDC_MAXCHANNEL, CB_SETCURSEL, sndLimSnd - 1, 0);

			SetDlgItemText(hwndDlg, IDC_CURRPATH, CurrBassPath);

			hwndOptSlider = GetDlgItem(hwndDlg, IDC_VOLUME);
			SendDlgItemMessage(hwndDlg, IDC_VOLUME, TBM_SETRANGE, FALSE, MAKELONG(SLIDER_MIN, SLIDER_MAX));
			SendDlgItemMessage(hwndDlg, IDC_VOLUME, TBM_SETPOS, TRUE, Volume);
			SendDlgItemMessage(hwndDlg, IDC_VOLUME, TBM_SETPAGESIZE, 0, 5);

			systime.wHour = HIBYTE(TimeWrd1);
			systime.wMinute = LOBYTE(TimeWrd1);
			systime.wYear = 2000;
			systime.wMonth = 1;
			systime.wDay = 1;
			SendDlgItemMessage(hwndDlg, IDC_TIME1, DTM_SETFORMAT, 0, (LPARAM)_T("HH:mm"));
			SendDlgItemMessage(hwndDlg, IDC_TIME1, DTM_SETSYSTEMTIME, GDT_VALID, (LPARAM)&systime);
			systime.wHour = HIBYTE(TimeWrd2);
			systime.wMinute = LOBYTE(TimeWrd2);
			SendDlgItemMessage(hwndDlg, IDC_TIME2, DTM_SETFORMAT, 0, (LPARAM)_T("HH:mm"));
			SendDlgItemMessage(hwndDlg, IDC_TIME2, DTM_SETSYSTEMTIME, GDT_VALID, (LPARAM)&systime);

			CheckDlgButton(hwndDlg, IDC_PREVIEW, EnPreview ? BST_CHECKED : BST_UNCHECKED);

			for (int i = IDC_CHECKBOX1; i < IDC_CHECKBOX10 + 1; i++)
				if (StatMask & (1 << (i - IDC_CHECKBOX1)))
					CheckDlgButton(hwndDlg, i, BST_CHECKED);

			if (QuietTime) {
				EnableWindow(GetDlgItem(hwndDlg, IDC_TIME1), TRUE);
				EnableWindow(GetDlgItem(hwndDlg, IDC_TIME2), TRUE);
				CheckDlgButton(hwndDlg, IDC_QUIETTIME, BST_CHECKED);
			}

			if (hBass == NULL) {
				EnableWindow(GetDlgItem(hwndDlg, IDC_VOLUME), FALSE);
				EnableWindow(GetDlgItem(hwndDlg, IDC_MAXCHANNEL), FALSE);
				EnableWindow(GetDlgItem(hwndDlg, IDC_OUTDEVICE), FALSE);
				EnableWindow(GetDlgItem(hwndDlg, IDC_QUIETTIME), FALSE);
				EnableWindow(GetDlgItem(hwndDlg, IDC_PREVIEW), FALSE);

				for (int i = IDC_CHECKBOX1; i < IDC_CHECKBOX10 + 1; i++)
					EnableWindow(GetDlgItem(hwndDlg, i), FALSE);
			}
			else {
				DBVARIANT dbv = { 0 }; BASS_DEVICEINFO info; DWORD bassver = BASS_GetVersion();

				mir_sntprintf(tmp, _countof(tmp), TranslateT("un4seen's bass version: %d.%d.%d.%d"), bassver >> 24, (bassver >> 16) & 0xff, (bassver >> 8) & 0xff, bassver & 0xff);
				SetDlgItemText(hwndDlg, IDC_BASSVERSION, tmp);

				SendDlgItemMessage(hwndDlg, IDC_OUTDEVICE, CB_RESETCONTENT, 0, 0);
				SendDlgItemMessage(hwndDlg, IDC_OUTDEVICE, CB_ADDSTRING, 0, (LPARAM)TranslateT("--default device--"));
				SendDlgItemMessage(hwndDlg, IDC_OUTDEVICE, CB_SETCURSEL, 0, 0);
				db_get_ts(NULL, ModuleName, OPT_OUTDEVICE, &dbv);
				for (int i = 1; BASS_GetDeviceInfo(i + newBass, &info); i++) {
					SendDlgItemMessage(hwndDlg, IDC_OUTDEVICE, CB_ADDSTRING, 0, _A2T(info.name));
					if (!mir_tstrcmp(dbv.ptszVal, _A2T(info.name)))
						SendDlgItemMessage(hwndDlg, IDC_OUTDEVICE, CB_SETCURSEL, i, 0);
				}
				db_free(&dbv);
			}
		}
		return TRUE;

	case WM_HSCROLL:
		if (hBass != NULL)
			if (LOWORD(wParam) == SB_ENDSCROLL || LOWORD(wParam) == SB_THUMBTRACK) {
				Volume = SendDlgItemMessage(hwndDlg, IDC_VOLUME, TBM_GETPOS, 0, 0);
				BASS_SetConfig(BASS_CONFIG_GVOL_STREAM, Volume * 100);
				SendMessage(hwndSlider, TBM_SETPOS, TRUE, Volume);
				Preview = TRUE;
				if (EnPreview)
					SkinPlaySound("AlertMsg");
				SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
			}
		break;

	case WM_NOTIFY:
		switch (((LPNMHDR)lParam)->code) {
		case PSN_APPLY:
			if (hBass != NULL) {
				SYSTEMTIME systime = { 0 };

				GetDlgItemText(hwndDlg, IDC_OUTDEVICE, tmp, _countof(tmp));
				db_set_ts(NULL, ModuleName, OPT_OUTDEVICE, tmp);

				Volume = (DWORD)SendDlgItemMessage(hwndDlg, IDC_VOLUME, TBM_GETPOS, 0, 0);
				db_set_b(NULL, ModuleName, OPT_VOLUME, Volume);

				sndLimSnd = SendDlgItemMessage(hwndDlg, IDC_MAXCHANNEL, CB_GETCURSEL, 0, 0) + 1;
				if (sndLimSnd > MAXCHAN)
					sndLimSnd = MAXCHAN;
				db_set_b(NULL, ModuleName, OPT_MAXCHAN, sndLimSnd);

				QuietTime = IsDlgButtonChecked(hwndDlg, IDC_QUIETTIME) == BST_CHECKED;
				db_set_b(NULL, ModuleName, OPT_QUIETTIME, QuietTime);

				SendDlgItemMessage(hwndDlg, IDC_TIME1, DTM_GETSYSTEMTIME, 0, (LPARAM)&systime);
				TimeWrd1 = MAKEWORD(systime.wMinute, systime.wHour);
				db_set_w(NULL, ModuleName, OPT_TIME1, TimeWrd1);

				SendDlgItemMessage(hwndDlg, IDC_TIME2, DTM_GETSYSTEMTIME, 0, (LPARAM)&systime);
				TimeWrd2 = MAKEWORD(systime.wMinute, systime.wHour);
				db_set_w(NULL, ModuleName, OPT_TIME2, TimeWrd2);

				EnPreview = IsDlgButtonChecked(hwndDlg, IDC_PREVIEW) == BST_CHECKED;
				db_set_b(NULL, ModuleName, OPT_PREVIEW, EnPreview);

				StatMask = 0;
				for (int i = IDC_CHECKBOX10; i > IDC_CHECKBOX1 - 1; i--) {
					StatMask <<= 1;
					if (IsDlgButtonChecked(hwndDlg, i) == BST_CHECKED)
						StatMask |= 1;
				}

				db_set_w(NULL, ModuleName, OPT_STATUS, StatMask);

				device = SendDlgItemMessage(hwndDlg, IDC_OUTDEVICE, CB_GETCURSEL, 0, 0);
				if (device == 0)
					device = -1;
				else
					device += newBass;
			}
			return 1;

		case PSN_RESET:
			if (hBass != NULL)
				BASS_SetConfig(BASS_CONFIG_GVOL_STREAM, Volume * 100);
			return 1;

		case DTN_DATETIMECHANGE:
			SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
			return 1;
		}
		break;

	case WM_COMMAND:
		switch (LOWORD(wParam)) {
		case IDC_QUIETTIME:
			{
				BOOL b = IsDlgButtonChecked(hwndDlg, IDC_QUIETTIME) == BST_CHECKED;
				EnableWindow(GetDlgItem(hwndDlg, IDC_TIME1), b);
				EnableWindow(GetDlgItem(hwndDlg, IDC_TIME2), b);
			}
		case IDC_MAXCHANNEL:
		case IDC_OUTDEVICE:
		case IDC_CHECKBOX1:
		case IDC_CHECKBOX2:
		case IDC_CHECKBOX3:
		case IDC_CHECKBOX4:
		case IDC_CHECKBOX5:
		case IDC_CHECKBOX6:
		case IDC_CHECKBOX7:
		case IDC_CHECKBOX8:
		case IDC_CHECKBOX9:
		case IDC_CHECKBOX10:
		case IDC_PREVIEW:
			SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
			break;

		case IDC_GETBASS:
			Utils_OpenUrl("http://www.un4seen.com/");
			break;
		}
		break;
	}
	return 0;
}
Exemplo n.º 23
0
INT_PTR CALLBACK DlgSkinOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
{
	switch (msg) {
	case WM_DESTROY:
		if (hPreviewBitmap)
			ske_UnloadGlyphImage(hPreviewBitmap);
		break;

	case WM_INITDIALOG:
		TranslateDialogDefault(hwndDlg);
		SetDlgItemText(hwndDlg, IDC_SKINFOLDERLABEL, SkinsFolder);
		{
			HTREEITEM it = FillAvailableSkinList(hwndDlg);
			TreeView_SelectItem(GetDlgItem(hwndDlg, IDC_TREE1), it);
		}
		return 0;

	case WM_COMMAND:
		switch (LOWORD(wParam)) {
		case IDC_COLOUR_MENUNORMAL:
		case IDC_COLOUR_MENUSELECTED:
		case IDC_COLOUR_FRAMES:
		case IDC_COLOUR_STATUSBAR:
			SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
			break;

		case IDC_BUTTON_INFO:
			{
				HTREEITEM hti = TreeView_GetSelection(GetDlgItem(hwndDlg, IDC_TREE1));
				if (hti == nullptr)
					return 0;

				TVITEM tvi = { 0 };
				tvi.hItem = hti;
				tvi.mask = TVIF_HANDLE | TVIF_PARAM;
				TreeView_GetItem(GetDlgItem(hwndDlg, IDC_TREE1), &tvi);
				SkinListData *sd = (SkinListData*)(tvi.lParam);
				if (!sd)
					return 0;

				wchar_t Author[255], URL[MAX_PATH], Contact[255], Description[400], text[2000];
				if (!wcschr(sd->File, '%')) {
					GetPrivateProfileString(L"Skin_Description_Section", L"Author", TranslateT("( unknown )"), Author, _countof(Author), sd->File);
					GetPrivateProfileString(L"Skin_Description_Section", L"URL", L"", URL, _countof(URL), sd->File);
					GetPrivateProfileString(L"Skin_Description_Section", L"Contact", L"", Contact, _countof(Contact), sd->File);
					GetPrivateProfileString(L"Skin_Description_Section", L"Description", L"", Description, _countof(Description), sd->File);
					mir_snwprintf(text, TranslateT("%s\n\n%s\n\nAuthor(s):\t %s\nContact:\t %s\nWeb:\t %s\n\nFile:\t %s"),
						sd->Name, Description, Author, Contact, URL, sd->File);
				}
				else {
					mir_snwprintf(text, TranslateT("%s\n\n%s\n\nAuthor(s): %s\nContact:\t %s\nWeb:\t %s\n\nFile:\t %s"),
						TranslateT("reVista for Modern v0.5"),
						TranslateT("This is second default Modern Contact list skin in Vista Aero style"),
						TranslateT("Angeli-Ka (graphics), FYR (template)"),
						L"JID: [email protected]",
						L"fyr.mirandaim.ru",
						TranslateT("Inside library"));
				}
				MessageBox(hwndDlg, text, TranslateT("Skin information"), MB_OK | MB_ICONINFORMATION);
			}
			break;

		case IDC_BUTTON_APPLY_SKIN:
			if (HIWORD(wParam) == BN_CLICKED) {
				HTREEITEM hti = TreeView_GetSelection(GetDlgItem(hwndDlg, IDC_TREE1));
				if (hti == nullptr)
					return 0;

				TVITEM tvi = { 0 };
				tvi.hItem = hti;
				tvi.mask = TVIF_HANDLE | TVIF_PARAM;
				TreeView_GetItem(GetDlgItem(hwndDlg, IDC_TREE1), &tvi);
				SkinListData *sd = (SkinListData*)(tvi.lParam);
				if (!sd)
					return 0;

				ske_LoadSkinFromIniFile(sd->File, FALSE);
				ske_LoadSkinFromDB();
				Clist_Broadcast(INTM_RELOADOPTIONS, 0, 0);
				Sync(CLUIFrames_OnClistResize_mod, 0, 0);
				ske_RedrawCompleteWindow();
				Sync(CLUIFrames_OnClistResize_mod, 0, 0);

				RECT rc = {};
				GetWindowRect(g_clistApi.hwndContactList, &rc);
				Sync(CLUIFrames_OnMoving, g_clistApi.hwndContactList, &rc);

				if (g_hCLUIOptionsWnd) {
					SendDlgItemMessage(g_hCLUIOptionsWnd, IDC_LEFTMARGINSPIN, UDM_SETPOS, 0, db_get_b(0, "CLUI", "LeftClientMargin", SETTING_LEFTCLIENTMARIGN_DEFAULT));
					SendDlgItemMessage(g_hCLUIOptionsWnd, IDC_RIGHTMARGINSPIN, UDM_SETPOS, 0, db_get_b(0, "CLUI", "RightClientMargin", SETTING_RIGHTCLIENTMARIGN_DEFAULT));
					SendDlgItemMessage(g_hCLUIOptionsWnd, IDC_TOPMARGINSPIN, UDM_SETPOS, 0, db_get_b(0, "CLUI", "TopClientMargin", SETTING_TOPCLIENTMARIGN_DEFAULT));
					SendDlgItemMessage(g_hCLUIOptionsWnd, IDC_BOTTOMMARGINSPIN, UDM_SETPOS, 0, db_get_b(0, "CLUI", "BottomClientMargin", SETTING_BOTTOMCLIENTMARIGN_DEFAULT));
				}
			}
			break;

		case IDC_GETSKINS:
			if (HIWORD(wParam) == BN_CLICKED)
				Utils_OpenUrl("https://miranda-ng.org/addons/category/17");
			break;


		case IDC_BUTTON_RESCAN:
			if (HIWORD(wParam) == BN_CLICKED) {
				HTREEITEM it = FillAvailableSkinList(hwndDlg);
				HWND wnd = GetDlgItem(hwndDlg, IDC_TREE1);
				TreeView_SelectItem(wnd, it);
			}
		}
		break;

	case WM_DRAWITEM:
		if (wParam == IDC_PREVIEW) {
			// TODO:Draw hPreviewBitmap here
			HBRUSH hbr = CreateSolidBrush(GetSysColor(COLOR_3DFACE));
			DRAWITEMSTRUCT *dis = (DRAWITEMSTRUCT*)lParam;
			int mWidth = dis->rcItem.right - dis->rcItem.left;
			int mHeight = dis->rcItem.bottom - dis->rcItem.top;
			HDC memDC = CreateCompatibleDC(dis->hDC);
			HBITMAP hbmp = ske_CreateDIB32(mWidth, mHeight);
			HBITMAP holdbmp = (HBITMAP)SelectObject(memDC, hbmp);
			RECT workRect = dis->rcItem;
			OffsetRect(&workRect, -workRect.left, -workRect.top);
			FillRect(memDC, &workRect, hbr);
			DeleteObject(hbr);
			if (hPreviewBitmap) {
				// variables
				BITMAP bmp = {};
				GetObject(hPreviewBitmap, sizeof(bmp), &bmp);

				// GetSize
				float xScale = 1, yScale = 1;
				int wWidth = workRect.right - workRect.left;
				int wHeight = workRect.bottom - workRect.top;
				if (wWidth < bmp.bmWidth)
					xScale = (float)wWidth / bmp.bmWidth;
				if (wHeight < bmp.bmHeight)
					yScale = (float)wHeight / bmp.bmHeight;
				xScale = min(xScale, yScale);
				yScale = xScale;
				int dWidth = (int)(xScale*bmp.bmWidth);
				int dHeight = (int)(yScale*bmp.bmHeight);
				
				// CalcPosition
				POINT imgPos = { 0 };
				imgPos.x = workRect.left + ((wWidth - dWidth) >> 1);
				imgPos.y = workRect.top + ((wHeight - dHeight) >> 1);
				
				// DrawImage
				DrawAvatarImageWithGDIp(memDC, imgPos.x, imgPos.y, dWidth, dHeight, hPreviewBitmap, 0, 0, bmp.bmWidth, bmp.bmHeight, 8, 255);
			}
			BitBlt(dis->hDC, dis->rcItem.left, dis->rcItem.top, mWidth, mHeight, memDC, 0, 0, SRCCOPY);
			SelectObject(memDC, holdbmp);
			DeleteObject(hbmp);
			DeleteDC(memDC);
		}
		break;

	case WM_NOTIFY:
		switch (((LPNMHDR)lParam)->idFrom) {
		case 0:
			if (((LPNMHDR)lParam)->code == PSN_APPLY) {
				Clist_Broadcast(INTM_RELOADOPTIONS, 0, 0);
				NotifyEventHooks(g_CluiData.hEventBkgrChanged, 0, 0);
				Clist_Broadcast(INTM_INVALIDATE, 0, 0);
				RedrawWindow(GetParent(g_clistApi.hwndContactTree), nullptr, nullptr, RDW_INVALIDATE | RDW_FRAME | RDW_ALLCHILDREN);
			}
			break;

		case IDC_TREE1:
			NMTREEVIEW *nmtv = (NMTREEVIEW*)lParam;
			if (nmtv == nullptr)
				return 0;

			if (nmtv->hdr.code == TVN_SELCHANGED) {
				if (hPreviewBitmap) {
					ske_UnloadGlyphImage(hPreviewBitmap);
					hPreviewBitmap = nullptr;
				}

				if (nmtv->itemNew.lParam) {
					SkinListData *sd = (SkinListData*)nmtv->itemNew.lParam;

					wchar_t buf[MAX_PATH];
					PathToRelativeW(sd->File, buf);
					SetDlgItemText(hwndDlg, IDC_EDIT_SKIN_FILENAME, buf);

					wchar_t prfn[MAX_PATH] = { 0 }, imfn[MAX_PATH] = { 0 }, skinfolder[MAX_PATH] = { 0 };
					GetPrivateProfileString(L"Skin_Description_Section", L"Preview", L"", imfn, _countof(imfn), sd->File);
					IniParser::GetSkinFolder(sd->File, skinfolder);
					mir_snwprintf(prfn, L"%s\\%s", skinfolder, imfn);
					PathToAbsoluteW(prfn, imfn);
					hPreviewBitmap = ske_LoadGlyphImage(imfn);

					EnableWindow(GetDlgItem(hwndDlg, IDC_BUTTON_APPLY_SKIN), TRUE);
					EnableWindow(GetDlgItem(hwndDlg, IDC_BUTTON_INFO), TRUE);
					if (hPreviewBitmap)
						InvalidateRect(GetDlgItem(hwndDlg, IDC_PREVIEW), nullptr, TRUE);
					else { // prepare text
						HTREEITEM hti = TreeView_GetSelection(GetDlgItem(hwndDlg, IDC_TREE1));
						if (hti == nullptr)
							return 0;

						TVITEM tvi = { 0 };
						tvi.hItem = hti;
						tvi.mask = TVIF_HANDLE | TVIF_PARAM;
						TreeView_GetItem(GetDlgItem(hwndDlg, IDC_TREE1), &tvi);
						SkinListData *sd2 = (SkinListData*)(tvi.lParam);
						if (!sd2)
							return 0;

						wchar_t Author[255], URL[MAX_PATH], Contact[255], Description[400], text[2000];
						if (!wcschr(sd2->File, '%')) {
							GetPrivateProfileString(L"Skin_Description_Section", L"Author", TranslateT("( unknown )"), Author, _countof(Author), sd2->File);
							GetPrivateProfileString(L"Skin_Description_Section", L"URL", L"", URL, _countof(URL), sd2->File);
							GetPrivateProfileString(L"Skin_Description_Section", L"Contact", L"", Contact, _countof(Contact), sd2->File);
							GetPrivateProfileString(L"Skin_Description_Section", L"Description", L"", Description, _countof(Description), sd2->File);
							mir_snwprintf(text, TranslateT("Preview is not available\n\n%s\n----------------------\n\n%s\n\nAUTHOR(S):\n%s\n\nCONTACT:\n%s\n\nHOMEPAGE:\n%s"),
								sd2->Name, Description, Author, Contact, URL);
						}
						else {
							mir_snwprintf(text, TranslateT("%s\n\n%s\n\nAUTHORS:\n%s\n\nCONTACT:\n%s\n\nWEB:\n%s\n\n\n"),
								TranslateT("reVista for Modern v0.5"),
								TranslateT("This is second default Modern Contact list skin in Vista Aero style"),
								TranslateT("graphics by Angeli-Ka\ntemplate by FYR"),
								L"JID: [email protected]",
								L"fyr.mirandaim.ru");
						}
						ShowWindow(GetDlgItem(hwndDlg, IDC_PREVIEW), SW_HIDE);
						ShowWindow(GetDlgItem(hwndDlg, IDC_STATIC_INFO), SW_SHOW);
						SetDlgItemText(hwndDlg, IDC_STATIC_INFO, text);
					}
				}
				else {
					// no selected
					SetDlgItemText(hwndDlg, IDC_EDIT_SKIN_FILENAME, TranslateT("Select skin from list"));
					EnableWindow(GetDlgItem(hwndDlg, IDC_BUTTON_APPLY_SKIN), FALSE);
					EnableWindow(GetDlgItem(hwndDlg, IDC_BUTTON_INFO), FALSE);
					SetDlgItemText(hwndDlg, IDC_STATIC_INFO, TranslateT("Please select skin to apply"));
					ShowWindow(GetDlgItem(hwndDlg, IDC_PREVIEW), SW_HIDE);
				}
				ShowWindow(GetDlgItem(hwndDlg, IDC_PREVIEW), hPreviewBitmap ? SW_SHOW : SW_HIDE);
				return 0;
			}
			else if (nmtv->hdr.code == TVN_DELETEITEM) {
				mir_free_and_nil(nmtv->itemOld.lParam);
				return 0;
			}
			break;
		}
	}
Exemplo n.º 24
0
INT_PTR CALLBACK DlgProcUrlRecv(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
{
	struct UrlRcvData *dat = (struct UrlRcvData *)GetWindowLongPtr(hwndDlg, GWLP_USERDATA);

	switch (msg) {
	case WM_INITDIALOG:
		TranslateDialogDefault(hwndDlg);
		Window_SetIcon_IcoLib(hwndDlg, SKINICON_EVENT_URL);
		Button_SetIcon_IcoLib(hwndDlg, IDC_ADD, SKINICON_OTHER_ADDCONTACT, LPGEN("Add contact permanently to list"));
		Button_SetIcon_IcoLib(hwndDlg, IDC_DETAILS, SKINICON_OTHER_USERDETAILS, LPGEN("View user's details"));
		Button_SetIcon_IcoLib(hwndDlg, IDC_HISTORY, SKINICON_OTHER_HISTORY, LPGEN("View user's history"));
		Button_SetIcon_IcoLib(hwndDlg, IDC_USERMENU, SKINICON_OTHER_DOWNARROW, LPGEN("User menu"));

		dat = (struct UrlRcvData*)mir_alloc(sizeof(struct UrlRcvData));
		SetWindowLongPtr(hwndDlg, GWLP_USERDATA, (LONG_PTR)dat);

		dat->hContact = ((CLISTEVENT*)lParam)->hContact;
		dat->hDbEvent = ((CLISTEVENT*)lParam)->hDbEvent;

		WindowList_Add(hUrlWindowList, hwndDlg, dat->hContact);
		{
			DBEVENTINFO dbei = { sizeof(dbei) };
			dbei.cbBlob = db_event_getBlobSize(dat->hDbEvent);
			dbei.pBlob = (PBYTE)mir_alloc(dbei.cbBlob);
			db_event_get(dat->hDbEvent, &dbei);
			SetDlgItemTextA(hwndDlg, IDC_URL, (char*)dbei.pBlob);
			SetDlgItemTextA(hwndDlg, IDC_MSG, (char*)dbei.pBlob+mir_strlen((char*)dbei.pBlob)+1);
			mir_free(dbei.pBlob);

			db_event_markRead(dat->hContact, dat->hDbEvent);

			TCHAR *contactName = pcli->pfnGetContactDisplayName(dat->hContact, 0), msg[128];
			mir_sntprintf(msg, _countof(msg), TranslateT("URL from %s"), contactName);
			SetWindowText(hwndDlg, msg);
			SetDlgItemText(hwndDlg, IDC_FROM, contactName);
			SendDlgItemMessage(hwndDlg, IDOK, BUTTONSETARROW, 1, 0);

			TCHAR str[128];
			TimeZone_PrintTimeStamp(NULL, dbei.timestamp, _T("t d"), str, _countof(str), 0);
			SetDlgItemText(hwndDlg, IDC_DATE, str);
		}

		// From message dlg
		if ( !db_get_b(dat->hContact, "CList", "NotOnList", 0))
			ShowWindow(GetDlgItem(hwndDlg, IDC_ADD), SW_HIDE);

		SendMessage(hwndDlg, DM_UPDATETITLE, 0, 0);
		// From message dlg end

		Utils_RestoreWindowPositionNoSize(hwndDlg, NULL, "SRUrl", "recv");
		return TRUE;

	case WM_MEASUREITEM:
		return Menu_MeasureItem((LPMEASUREITEMSTRUCT)lParam);

	case WM_DRAWITEM:
		{
			LPDRAWITEMSTRUCT dis = (LPDRAWITEMSTRUCT)lParam;
			if (dis->hwndItem == GetDlgItem(hwndDlg, IDC_PROTOCOL)) {
				char *szProto = GetContactProto(dat->hContact);
				if (szProto) {
					HICON hIcon = (HICON)CallProtoService(szProto, PS_LOADICON, PLI_PROTOCOL|PLIF_SMALL, 0);
					if (hIcon) {
						DrawIconEx(dis->hDC, dis->rcItem.left, dis->rcItem.top, hIcon, GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), 0, NULL, DI_NORMAL);
						DestroyIcon(hIcon);
					}
				}
			}
		}
		return Menu_DrawItem((LPDRAWITEMSTRUCT)lParam);

	case DM_UPDATETITLE:
		sttUpdateTitle(hwndDlg, dat->hContact);
		break;

	case WM_COMMAND:
		if (!dat)
			break;
		if (CallService(MS_CLIST_MENUPROCESSCOMMAND, MAKEWPARAM(LOWORD(wParam), MPCF_CONTACTMENU), (LPARAM)dat->hContact))
			break;
		switch(LOWORD(wParam)) {
		case IDOK:
			{
				RECT rc;
				char url[256];

				HMENU hMenu = LoadMenu(hInst, MAKEINTRESOURCE(IDR_CONTEXT));
				HMENU hSubMenu = GetSubMenu(hMenu, 6);
				TranslateMenu(hSubMenu);
				GetWindowRect((HWND)lParam, &rc);
				GetDlgItemTextA(hwndDlg, IDC_URL, url, _countof(url));
				switch(TrackPopupMenu(hSubMenu, TPM_RETURNCMD, rc.left, rc.bottom, 0, hwndDlg, NULL)) {
					case IDM_OPENNEW:
						Utils_OpenUrl(url);
						break;
					case IDM_OPENEXISTING:
						Utils_OpenUrl(url);
						break;
					case IDM_COPYLINK:
					{
						if ( !OpenClipboard(hwndDlg)) break;
						EmptyClipboard();
						HGLOBAL hData = GlobalAlloc(GMEM_MOVEABLE, mir_strlen(url)+1);
						mir_strcpy((char*)GlobalLock(hData), url);
						GlobalUnlock(hData);
						SetClipboardData(CF_TEXT, hData);
						CloseClipboard();
						break;
					}
				}
                DestroyMenu(hMenu);
			}
			return TRUE;

		case IDC_USERMENU:
			{
				RECT rc;
				HMENU hMenu = Menu_BuildContactMenu(dat->hContact);
				GetWindowRect(GetDlgItem(hwndDlg, IDC_USERMENU), &rc);
				TrackPopupMenu(hMenu, 0, rc.left, rc.bottom, 0, hwndDlg, NULL);
				DestroyMenu(hMenu);
			}
			break;

		case IDC_HISTORY:
			CallService(MS_HISTORY_SHOWCONTACTHISTORY, (WPARAM)dat->hContact, 0);
			break;

		case IDC_DETAILS:
			CallService(MS_USERINFO_SHOWDIALOG, (WPARAM)dat->hContact, 0);
			break;

		case IDC_ADD:
			{
				ADDCONTACTSTRUCT acs = {0};
				acs.hContact = dat->hContact;
				acs.handleType = HANDLE_CONTACT;
				CallService(MS_ADDCONTACT_SHOW, (WPARAM)hwndDlg, (LPARAM)&acs);
			}
			if ( !db_get_b(dat->hContact, "CList", "NotOnList", 0)) {
				ShowWindow(GetDlgItem(hwndDlg, IDC_ADD), FALSE);
			}
			break;

		case IDC_REPLY:
			CallService(MS_MSG_SENDMESSAGE, (WPARAM)dat->hContact, 0);
			//fall through
		case IDCANCEL:
			DestroyWindow(hwndDlg);
			return TRUE;
		}
		break;

	case WM_DESTROY:
		Window_FreeIcon_IcoLib(hwndDlg);
		Button_FreeIcon_IcoLib(hwndDlg, IDC_ADD);
		Button_FreeIcon_IcoLib(hwndDlg, IDC_DETAILS);
		Button_FreeIcon_IcoLib(hwndDlg, IDC_HISTORY);
		Button_FreeIcon_IcoLib(hwndDlg, IDC_USERMENU);

		WindowList_Remove(hUrlWindowList, hwndDlg);
		mir_free(dat);
		Utils_SaveWindowPosition(hwndDlg, NULL, "SRUrl", "recv");
		break;
	}
	return FALSE;
}
Exemplo n.º 25
0
INT_PTR CALLBACK DlgProcDisplayData(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
{
	DBVARIANT dbv;
	RECT rc;
	TCHAR url[300];
	MCONTACT hContact;

	switch (msg) {
	case WM_INITDIALOG:
		TranslateDialogDefault(hwndDlg);
		{
			MCONTACT hContact2 = lParam;

			SetWindowLongPtr(hwndDlg, GWLP_USERDATA, (LONG_PTR) hContact2);
			WindowList_Add(hWindowList, hwndDlg, hContact2);

			url[0] = '\0';
			if (!db_get_ts(hContact2, MODULENAME, URL_KEY, &dbv)) {
				_tcsncpy_s(url, dbv.ptszVal, _TRUNCATE);
				db_free(&dbv);
			}
			SetDlgItemText(hwndDlg, IDC_OPEN_URL, FixButtonText(url, _countof(url)));

			char preservename[100];
			if (!db_get_s(hContact2, MODULENAME, PRESERVE_NAME_KEY, &dbv)) {
				strncpy_s(preservename, _countof(preservename), dbv.pszVal, _TRUNCATE);
				db_free(&dbv);
			}
			else preservename[0] = 0;
			SetWindowTextA(hwndDlg, preservename);

			SendMessage(hwndDlg, WM_SETICON, ICON_SMALL, (LPARAM) LoadIcon(hInst, MAKEINTRESOURCE(IDI_SITE)));

			// //////
			COLORREF colour = BackgoundClr;
			COLORREF txtcolor;
			SendDlgItemMessage(hwndDlg, IDC_DATA, EM_SETBKGNDCOLOR, 0, colour);

			SendDlgItemMessage(hwndDlg, IDC_UPDATE_BUTTON, BM_SETIMAGE, IMAGE_ICON, (LPARAM) LoadImage(hInst, MAKEINTRESOURCE(IDI_UPDATE), IMAGE_ICON, GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), 0));
			SendDlgItemMessage(hwndDlg, IDC_UPDATE_BUTTON, BUTTONADDTOOLTIP, (WPARAM) TranslateT("Update data"), BATF_TCHAR);

			SendDlgItemMessage(hwndDlg, IDC_FIND_BUTTON, BM_SETIMAGE, IMAGE_ICON, (LPARAM) LoadImage(hInst, MAKEINTRESOURCE(IDI_FIND), IMAGE_ICON, GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), 0));
			SendDlgItemMessage(hwndDlg, IDC_FIND_BUTTON, BUTTONADDTOOLTIP, (WPARAM) TranslateT("Find"), BATF_TCHAR);

			SendDlgItemMessage(hwndDlg, IDC_OPTIONS_BUTTON, BM_SETIMAGE, IMAGE_ICON, (LPARAM) LoadImage(hInst, MAKEINTRESOURCE(IDI_OPTIONS), IMAGE_ICON, GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), 0));
			SendDlgItemMessage(hwndDlg, IDC_OPTIONS_BUTTON, BUTTONADDTOOLTIP, (WPARAM) TranslateT("Contact options"), BATF_TCHAR);

			SendDlgItemMessage(hwndDlg, IDC_ALERT_BUTTON, BM_SETIMAGE, IMAGE_ICON, (LPARAM) LoadImage(hInst, MAKEINTRESOURCE(IDI_ALERT), IMAGE_ICON, GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), 0));
			SendDlgItemMessage(hwndDlg, IDC_ALERT_BUTTON, BUTTONADDTOOLTIP, (WPARAM) TranslateT("Alert options"), BATF_TCHAR);

			SendDlgItemMessage(hwndDlg, IDC_STOP, BM_SETIMAGE, IMAGE_ICON, (LPARAM) LoadImage(hInst, MAKEINTRESOURCE(IDI_STOP), IMAGE_ICON, GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), 0));
			SendDlgItemMessage(hwndDlg, IDC_STOP, BUTTONADDTOOLTIP, (WPARAM) TranslateT("Stop processing"), BATF_TCHAR);

			SendDlgItemMessage(hwndDlg, IDC_OPEN_URL, BUTTONADDTOOLTIP, (WPARAM) TranslateT("Click here to open this URL in a browser window."), BATF_TCHAR);

			if (!db_get_b(hContact2, MODULENAME, ON_TOP_KEY, 0)) {
				SendDlgItemMessage(hwndDlg, IDC_STICK_BUTTON, BM_SETIMAGE, IMAGE_ICON, (LPARAM) LoadImage(hInst, MAKEINTRESOURCE(IDI_UNSTICK), IMAGE_ICON, GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), 0));
				SendDlgItemMessage(hwndDlg, IDC_STICK_BUTTON, BUTTONADDTOOLTIP, (WPARAM) TranslateT("Stick to the front"), BATF_TCHAR);
			}
			else {
				SendDlgItemMessage(hwndDlg, IDC_STICK_BUTTON, BM_SETIMAGE, IMAGE_ICON, (LPARAM) LoadImage(hInst, MAKEINTRESOURCE(IDI_STICK), IMAGE_ICON, GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), 0));
				SendDlgItemMessage(hwndDlg, IDC_STICK_BUTTON, BUTTONADDTOOLTIP, (WPARAM) TranslateT("Disable stick to the front"), BATF_TCHAR);
			}

			SendDlgItemMessage(hwndDlg, IDC_DATA, WM_SETFONT, (WPARAM) h_font, 1);

			txtcolor = TextClr;

			SetDlgItemText(hwndDlg, IDC_DATA, _T(""));

			InvalidateRect(hwndDlg, NULL, 1);

			SendDlgItemMessage(hwndDlg, IDC_DATA, EM_AUTOURLDETECT, 1, 0);
			int mask = (int)SendDlgItemMessage(hwndDlg, IDC_DATA, EM_GETEVENTMASK, 0, 0);

			SendDlgItemMessage(hwndDlg, IDC_DATA, EM_SETEVENTMASK, 0, mask | ENM_LINK | ENM_MOUSEEVENTS);

			SendDlgItemMessage(hwndDlg, IDC_STICK_BUTTON, BUTTONSETASFLATBTN, 0, 0);
			SendDlgItemMessage(hwndDlg, IDC_UPDATE_BUTTON, BUTTONSETASFLATBTN, 0, 0);
			SendDlgItemMessage(hwndDlg, IDC_FIND_BUTTON, BUTTONSETASFLATBTN, 0, 0);
			SendDlgItemMessage(hwndDlg, IDC_OPTIONS_BUTTON, BUTTONSETASFLATBTN, 0, 0);
			SendDlgItemMessage(hwndDlg, IDC_ALERT_BUTTON, BUTTONSETASFLATBTN, 0, 0);
			SendDlgItemMessage(hwndDlg, IDC_STOP, BUTTONSETASFLATBTN, 0, 0);

			SendDlgItemMessage(hwndDlg, IDC_OPEN_URL, BUTTONSETASFLATBTN, 0, 0);

			HDC hdc = GetDC(GetDlgItem(hwndDlg, IDC_STATUSBAR));
			SelectObject(hdc, (HFONT) SendDlgItemMessage(hwndDlg, IDC_STATUSBAR, WM_GETFONT, 0, 0));
			SIZE textSize;
			GetTextExtentPoint32(hdc, tszSizeString, _countof(tszSizeString), &textSize);
			int partWidth[2] = { textSize.cx, -1 };
			ReleaseDC(GetDlgItem(hwndDlg, IDC_STATUSBAR), hdc);

			SendDlgItemMessage(hwndDlg, IDC_STATUSBAR, SB_SETPARTS, _countof(partWidth), (LPARAM)partWidth);
			SendDlgItemMessage(hwndDlg, IDC_STATUSBAR, SB_SETTEXT, 1 | SBT_OWNERDRAW, 0);

			if ( db_get_b(NULL, MODULENAME, SAVE_INDIVID_POS_KEY, 0))
				Utils_RestoreWindowPosition(hwndDlg, hContact2, MODULENAME, "WV");
		}
		break;

	case WM_NOTIFY:
		switch (((NMHDR *) lParam)->code) {
		case EN_MSGFILTER:
			switch (((MSGFILTER *) lParam)->msg) {
			case WM_RBUTTONUP:
				{
					POINT  pt;
					CHARRANGE sel, all = {0, -1};

					HMENU hSubMenu = GetSubMenu(hMenu, 0);
					TranslateMenu(hSubMenu);
					SendMessage(((NMHDR *) lParam)->hwndFrom, EM_EXGETSEL, 0, (LPARAM) & sel);

					EnableMenuItem(hSubMenu, IDM_COPY, MF_ENABLED);
					EnableMenuItem(hSubMenu, IDM_CUT, MF_ENABLED);
					EnableMenuItem(hSubMenu, IDM_DELETE, MF_ENABLED);

					if (sel.cpMin == sel.cpMax) {
						EnableMenuItem(hSubMenu, IDM_COPY, MF_BYCOMMAND | MF_GRAYED);
						EnableMenuItem(hSubMenu, IDM_CUT, MF_BYCOMMAND | MF_GRAYED);
						EnableMenuItem(hSubMenu, IDM_DELETE, MF_BYCOMMAND | MF_GRAYED);
					}
					pt.x = (short) LOWORD(((ENLINK *) lParam)->lParam);
					pt.y = (short) HIWORD(((ENLINK *) lParam)->lParam);
					ClientToScreen(((NMHDR *) lParam)->hwndFrom, &pt);
					switch (TrackPopupMenu(hSubMenu, TPM_RETURNCMD, pt.x, pt.y, 0, hwndDlg, NULL)) {
					case IDM_COPY:
						SendMessage(((NMHDR *) lParam)->hwndFrom, WM_COPY, 0, 0);
						break;

					case IDM_COPYALL:
						SendMessage(((NMHDR *) lParam)->hwndFrom, EM_EXSETSEL, 0, (LPARAM) & all);
						SendMessage(((NMHDR *) lParam)->hwndFrom, WM_COPY, 0, 0);
						SendMessage(((NMHDR *) lParam)->hwndFrom, EM_EXSETSEL, 0, (LPARAM) & sel);
						break;

					case IDM_SELECTALL:
						SendMessage(((NMHDR *) lParam)->hwndFrom, EM_EXSETSEL, 0, (LPARAM) & all);
						break;

					case IDM_CUT:
						SendMessage(((NMHDR *) lParam)->hwndFrom, WM_CUT, 0, 0);
						break;

					case IDM_PASTE:
						SendMessage(((NMHDR *) lParam)->hwndFrom, WM_PASTE, 0, 0);
						break;

					case IDM_DELETE:
						SendMessage(((NMHDR *) lParam)->hwndFrom, WM_CLEAR, 0, 0);
						break;

					case IDM_CLEAR_ALL:
						SetDlgItemTextA(hwndDlg, IDC_DATA, "");
						SetFocus(GetDlgItem(hwndDlg, IDC_DATA));
						break;
					}
				}
			}
			break;

		case EN_LINK:
			switch (((ENLINK *) lParam)->msg) {
			case WM_RBUTTONDOWN:
			case WM_LBUTTONUP:
				CHARRANGE sel;
				SendDlgItemMessage(hwndDlg, IDC_DATA, EM_EXGETSEL, 0, (LPARAM) & sel);
				if (sel.cpMin != sel.cpMax)
					break;

				TEXTRANGEA tr;
				tr.chrg = ((ENLINK *) lParam)->chrg;
				tr.lpstrText = (char*)malloc(tr.chrg.cpMax - tr.chrg.cpMin + 8);

				SendDlgItemMessage(hwndDlg, IDC_DATA, EM_GETTEXTRANGE, 0, (LPARAM) & tr);
				if (strchr(tr.lpstrText, '@') != NULL && strchr(tr.lpstrText, ':') == NULL && strchr(tr.lpstrText, '/') == NULL) {
					memmove(tr.lpstrText + 7, tr.lpstrText, tr.chrg.cpMax - tr.chrg.cpMin + 1);
					memcpy(tr.lpstrText, "mailto:", 7);
				}

				Utils_OpenUrl(tr.lpstrText);
				SetFocus(GetDlgItem(hwndDlg, IDC_DATA));

				free(tr.lpstrText);
				break;
			}
		}
		break; // notify

	case WM_COMMAND:
		switch (LOWORD(wParam)) {
		case IDC_OPEN_URL:
			GetDlgItemText(hwndDlg, IDC_OPEN_URL, url, _countof(url));
			Utils_OpenUrlT(url);  
			db_set_w(wParam, MODULENAME, "Status", ID_STATUS_ONLINE); 
			break;

		case IDC_UPDATE_BUTTON:
			if (hContact = FindContactByUrl(hwndDlg)) {
				EnableWindow(GetDlgItem(hwndDlg, IDC_UPDATE_BUTTON), 0);
				UpdateMenuCommand(wParam, lParam, hContact);
			}
			break;

		case IDC_STOP:
			if (hContact = FindContactByUrl(hwndDlg))
				db_set_b(hContact, MODULENAME, STOP_KEY, 1); 
			break;

		case IDC_STICK_BUTTON:
			if (hContact = FindContactByUrl(hwndDlg))
				OnTopMenuCommand(wParam, lParam, hContact);
			{
				TCHAR *ptszToolTip;
				HWND hTopmost;
				if (!db_get_b(hContact, MODULENAME, ON_TOP_KEY, 0)) {
					hTopmost = HWND_NOTOPMOST;
					ptszToolTip = TranslateT("Stick to the front");
				}
				else {
					hTopmost = HWND_TOPMOST;
					ptszToolTip = TranslateT("Disable stick to the front");
				}
				SendDlgItemMessage(hwndDlg, IDC_STICK_BUTTON, BM_SETIMAGE, IMAGE_ICON, (LPARAM)LoadImage(hInst, MAKEINTRESOURCE(IDI_UNSTICK), IMAGE_ICON, GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), 0));
				SendDlgItemMessage(hwndDlg, IDC_STICK_BUTTON, BUTTONADDTOOLTIP, (WPARAM)ptszToolTip, BATF_TCHAR);
				SetWindowPos(hwndDlg, hTopmost, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE);
			}
			break;

		case IDC_FIND_BUTTON:
			{
				HWND hwndFind = CreateDialogParam(hInst, MAKEINTRESOURCE(IDD_FIND), hwndDlg, DlgProcFind, (LPARAM) wParam);
				ShowWindow(hwndFind, SW_SHOW);
				EnableWindow(GetDlgItem(hwndDlg, IDC_FIND_BUTTON), 0);
			}
			break;

		case IDC_OPTIONS_BUTTON:
			if (hContact = FindContactByUrl(hwndDlg)) {
				ContactHwnd = CreateDialogParam(hInst, MAKEINTRESOURCE(IDD_CONTACT_OPT), hwndDlg, DlgProcContactOpt, (LPARAM) hContact);
				ShowWindow(ContactHwnd, SW_SHOW);
				SetActiveWindow(ContactHwnd);
				EnableWindow(GetDlgItem(hwndDlg, IDC_OPTIONS_BUTTON), 0);
				EnableWindow(GetDlgItem(hwndDlg, IDC_ALERT_BUTTON), 0);
			}
			break;

		case IDC_ALERT_BUTTON:
			if (hContact = FindContactByUrl(hwndDlg)) {
				HWND hwndAlertOpt = CreateDialogParam(hInst, MAKEINTRESOURCE(IDD_ALRT_OPT), hwndDlg, DlgProcAlertOpt, (LPARAM) hContact);
				ShowWindow(hwndAlertOpt, SW_SHOW);
				SetActiveWindow(hwndAlertOpt);
				EnableWindow(GetDlgItem(hwndDlg, IDC_ALERT_BUTTON), 0);
				EnableWindow(GetDlgItem(hwndDlg, IDC_OPTIONS_BUTTON), 0);
			}
			break;

		case IDOK:
		case IDCANCEL:
			if (hwndDlg != NULL)
				DestroyWindow(hwndDlg);
			return TRUE;
		}
		break;

	case WM_CLOSE:
		if (Yposition == -32000)
			Yposition = 100;

		if (Xposition == -32000)
			Xposition = 100;

		SavewinSettings();

		if (hContact = FindContactByUrl(hwndDlg))
			Utils_SaveWindowPosition(hwndDlg, hContact, MODULENAME, "WV");

		if (hwndDlg != NULL)
			DestroyWindow(hwndDlg);
		return 0;

	case WM_DESTROY:
		WindowList_Remove(hWindowList, hwndDlg);
		return 0;

	case WM_SIZE:
		Utils_ResizeDialog(hwndDlg, hInst, MAKEINTRESOURCEA(IDD_DISPLAY_DATA), DataDialogResize);
		InvalidateRect(hwndDlg, NULL, TRUE);

		// global
		GetWindowRect(hwndDlg, &rc);
		Xposition = rc.left;
		Yposition = rc.top;
		WindowHeight = rc.bottom - rc.top;
		WindowWidth = rc.right - rc.left;
		break;

	case WM_MOVE:
		if (!IsIconic(hwndDlg) && !IsZoomed(hwndDlg)) {
			GetWindowRect(hwndDlg, &rc);
			// global
			Xposition = rc.left;
			Yposition = rc.top;
			WindowHeight = rc.bottom - rc.top;
			WindowWidth = rc.right - rc.left;

			if ((GetAsyncKeyState(VK_CONTROL) & 0x8000))
				break;

			ValidatePosition(hwndDlg);
		}
	}
	return FALSE;
}
Exemplo n.º 26
0
INT_PTR CALLBACK DlgUpdate(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
{
	HWND hwndList = GetDlgItem(hDlg, IDC_LIST_UPDATES);

	switch (message) {
	case WM_INITDIALOG:
		TranslateDialogDefault(hDlg);
		SetWindowLongPtr(hDlg, GWLP_USERDATA, 0);
		SendMessage(hwndList, LVM_SETEXTENDEDLISTVIEWSTYLE, 0, LVS_EX_FULLROWSELECT | LVS_EX_CHECKBOXES);
		{
			LVCOLUMN lvc = { 0 };
			// Initialize the LVCOLUMN structure.
			// The mask specifies that the format, width, text, and
			// subitem members of the structure are valid.
			lvc.mask = LVCF_FMT | LVCF_WIDTH | LVCF_TEXT | LVCF_SUBITEM;
			lvc.fmt = LVCFMT_LEFT;

			lvc.iSubItem = 0;
			lvc.pszText = TranslateT("Component Name");
			lvc.cx = 145; // width of column in pixels
			ListView_InsertColumn(hwndList, 0, &lvc);

			lvc.iSubItem = 1;
			lvc.pszText = TranslateT("Current Version");
			lvc.cx = 95; // width of column in pixels
			ListView_InsertColumn(hwndList, 1, &lvc);

			lvc.iSubItem = 2;
			lvc.pszText = TranslateT("New Version");
			lvc.cx = 82; // width of column in pixels
			ListView_InsertColumn(hwndList, 2, &lvc);

			//enumerate plugins, fill in list
			//bool one_enabled = false;
			ListView_DeleteAllItems(hwndList);

			LVITEM lvI = { 0 };

			// Some code to create the list-view control.
			// Initialize LVITEM members that are common to all
			// items.
			lvI.mask = LVIF_TEXT | LVIF_PARAM | LVIF_NORECOMPUTE;// | LVIF_IMAGE;

			vector<FILEINFO> &todo = *(vector<FILEINFO> *)lParam;
			for (int i = 0; i < (int)todo.size(); ++i) {
				lvI.mask = LVIF_TEXT | LVIF_PARAM;// | LVIF_IMAGE;
				lvI.iSubItem = 0;
				lvI.lParam = (LPARAM)&todo[i];
				lvI.pszText = todo[i].tszDescr;
				lvI.iItem = i;
				ListView_InsertItem(hwndList, &lvI);

				lvI.mask = LVIF_TEXT;// | LVIF_IMAGE;

				lvI.iSubItem = 1;
				lvI.pszText = todo[i].tszCurVer;
				ListView_SetItem(hwndList, &lvI);

				lvI.iSubItem = 2;
				lvI.pszText = todo[i].tszNewVer;
				ListView_SetItem(hwndList, &lvI);

				ListView_SetCheckState(hwndList, lvI.iItem, true);
				todo[i].enabled = true;
			}
			HWND hwOk = GetDlgItem(hDlg, IDOK);
			EnableWindow(hwOk, true/*one_enabled ? TRUE : FALSE*/);
			// do this after filling list - enables 'ITEMCHANGED' below
			SetWindowLongPtr(hDlg, GWLP_USERDATA, lParam);
			Utils_RestoreWindowPositionNoSize(hDlg, 0, MODNAME, "ConfirmWindow");
		}
		return TRUE;

	case WM_NOTIFY:
		if (((LPNMHDR)lParam)->hwndFrom == hwndList) {
			switch (((LPNMHDR)lParam)->code) {
			case LVN_ITEMCHANGED:
				if (GetWindowLongPtr(hDlg, GWLP_USERDATA)) {
					NMLISTVIEW *nmlv = (NMLISTVIEW *)lParam;

					LVITEM lvI = { 0 };

					lvI.iItem = nmlv->iItem;
					lvI.iSubItem = 0;
					lvI.mask = LVIF_PARAM;
					ListView_GetItem(hwndList, &lvI);

					vector<FILEINFO> &todo = *(vector<FILEINFO> *)GetWindowLongPtr(hDlg, GWLP_USERDATA);
					if ((nmlv->uNewState ^ nmlv->uOldState) & LVIS_STATEIMAGEMASK) {
						todo[lvI.iItem].enabled = ListView_GetCheckState(hwndList, nmlv->iItem);

						bool enableOk = false;
						for (int i = 0; i < (int)todo.size(); ++i) {
							if (todo[i].enabled) {
								enableOk = true;
								break;
							}
						}
						HWND hwOk = GetDlgItem(hDlg, IDOK);
						EnableWindow(hwOk, enableOk ? TRUE : FALSE);
					}
					if (nmlv->uNewState & LVIS_SELECTED) {
						if (mir_tstrcmp(todo[lvI.iItem].tszInfoURL, _T("")))
							EnableWindow(GetDlgItem(hDlg, IDC_INFO), TRUE);
						else
							EnableWindow(GetDlgItem(hDlg, IDC_INFO), FALSE);
						SetDlgItemText(hDlg, IDC_MESSAGE, TranslateTS(todo[lvI.iItem].tszMessage));
					}
				}
				break;
			}
		}
		break;

	case WM_COMMAND:
		if (HIWORD(wParam) == BN_CLICKED) {
			switch (LOWORD(wParam)) {
			case IDOK:
			{
				vector<FILEINFO> &todo = *(vector<FILEINFO> *)GetWindowLongPtr(hDlg, GWLP_USERDATA);
				ShowWindow(hDlg, SW_HIDE);
				TCHAR tszBuff[2048] = { 0 }, tszFileDest[MAX_PATH] = { 0 }, tszFilePathDest[MAX_PATH] = { 0 }, tszFilePathBack[MAX_PATH] = { 0 }, tszFileName[MAX_PATH] = { 0 };
				TCHAR* tszExt = NULL;
				char szKey[64] = { 0 };
				vector<int> arFileType;
				vector<tString> arFilePath;
				vector<tString> arFileName;
				vector<tString> arAdvFolder;
				vector<tString> arExt;
				STARTUPINFO si;
				PROCESS_INFORMATION pi;

				SetWindowLongPtr(hDlg, GWLP_USERDATA, 0);
				Utils_SaveWindowPosition(hDlg, NULL, MODNAME, "ConfirmWindow");

				arFileType.clear();
				arFilePath.clear();
				arFileName.clear();
				arAdvFolder.clear();
				arExt.clear();
				for (int i = 0; i < (int)todo.size(); ++i) {
					if (todo[i].enabled) {
						switch (todo[i].FileType) {
						case 1:
							mir_sntprintf(tszFileDest, _T("%s\\Pack"), tszRoot);
							CreateDirectory(tszFileDest, NULL);
							break;
						case 2:
							mir_sntprintf(tszFileDest, _T("%s\\Plugins"), tszRoot);
							CreateDirectory(tszFileDest, NULL);
							break;
						case 3:
							mir_sntprintf(tszFileDest, _T("%s\\Icons"), tszRoot);
							CreateDirectory(tszFileDest, NULL);
							break;
						case 4:
							mir_sntprintf(tszFileDest, _T("%s\\Others"), tszRoot);
							CreateDirectory(tszFileDest, NULL);
							break;
						case 5:
							mir_sntprintf(tszFileDest, _T("%s\\Others"), tszRoot);
							CreateDirectory(tszFileDest, NULL);
							break;
						default:
							mir_tstrncpy(tszFileDest, tszRoot, _countof(tszFileDest));
							break;
						}
						mir_sntprintf(tszBuff, _T("%s\\Backups"), tszRoot);
						CreateDirectory(tszBuff, NULL);
						mir_tstrncpy(tszFileName, todo[i].File.tszDiskPath, _countof(tszFileName));
						mir_sntprintf(todo[i].File.tszDiskPath, _T("%s\\%s"), tszFileDest, tszFileName);
						UpdatesCount++;

						tszExt = &todo[i].File.tszDownloadURL[mir_tstrlen(todo[i].File.tszDownloadURL) - 5];
						if (mir_tstrcmp(tszExt, _T(".html")) == 0) {
							char* szUrl = mir_t2a(todo[i].File.tszDownloadURL);
							Utils_OpenUrl(szUrl);
							mir_free(szUrl);
						}
						else {
							// download update
							pFileUrl = &todo[i].File;
							Title = TranslateT("Pack Updater");
							if (todo[i].FileType == 1)
								Text = TranslateT("Downloading pack updates...");
							else
								Text = TranslateT("Downloading update...");
							DlgDownloadProc();
							if (!DlgDld) {
								if (UpdatesCount)
									UpdatesCount--;
								continue;
							}
						}
						mir_tstrncpy(todo[i].tszCurVer, todo[i].tszNewVer, _countof(todo[i].tszCurVer));
						mir_snprintf(szKey, "File_%d_CurrentVersion", todo[i].FileNum);
						db_set_ts(NULL, MODNAME, szKey, todo[i].tszCurVer);
						arFileType.push_back(todo[i].FileType);
						arFilePath.push_back(todo[i].File.tszDiskPath);
						arFileName.push_back(tszFileName);
						arAdvFolder.push_back(todo[i].tszAdvFolder);
						arExt.push_back(tszExt);
						if (todo[i].FileType == 1)
							i = (int)todo.size();
					}
				}

				if (UpdatesCount > 1 && mir_tstrcmp(arExt[0].c_str(), _T(".html")) != 0)
					mir_tstrncpy(tszBuff, TranslateT("Downloads complete. Start updating? All your data will be saved and Miranda NG will be closed."), _countof(tszBuff));
				else if (UpdatesCount == 1 && mir_tstrcmp(arExt[0].c_str(), _T(".html")) != 0)
					mir_tstrncpy(tszBuff, TranslateT("Download complete. Start updating? All your data will be saved and Miranda NG will be closed."), _countof(tszBuff));
				if (UpdatesCount > 0 && mir_tstrcmp(arExt[0].c_str(), _T(".html")) != 0) {
					INT rc = -1;
					Title = TranslateT("Pack Updater");
					Text = tszBuff;
					if (ServiceExists(MS_POPUP_ADDPOPUPT) && ServiceExists(MS_POPUP_REGISTERACTIONS) && db_get_b(NULL, "Popup", "ModuleIsEnabled", 1) && db_get_b(NULL, MODNAME, "Popups0", DEFAULT_POPUP_ENABLED) && (db_get_dw(NULL, "Popup", "Actions", 0) & 1))
						rc = DialogBox(hInst, MAKEINTRESOURCE(IDD_POPUPDUMMI), NULL, DlgMsgPop);
					else
						rc = MessageBox(NULL, tszBuff, Title, MB_YESNO | MB_ICONQUESTION);
					if (rc == IDYES) {
						for (int i = 0; i < UpdatesCount; i++) {
							TCHAR* tszUtilRootPlug = NULL;
							TCHAR* tszUtilRootIco = NULL;
							TCHAR* tszUtilRoot = NULL;
							TCHAR  tszCurrentDir[MAX_PATH];

							switch (arFileType[i]) {
							case 0:
								break;
							case 1:
								if (Reminder == 2)
									db_set_b(NULL, MODNAME, "Reminder", 1);
								memset(&si, 0, sizeof(STARTUPINFO));
								memset(&pi, 0, sizeof(PROCESS_INFORMATION));
								si.cb = sizeof(STARTUPINFO);
								{
									_tcsncpy_s(tszCurrentDir, arFilePath[i].c_str(), _TRUNCATE);
									TCHAR *p = _tcsrchr(tszCurrentDir, '\\');
									if (p) *p = 0;
								}
								CreateProcess(arFilePath[i].c_str(), _T(""), NULL, NULL, FALSE, NULL, NULL, tszCurrentDir, &si, &pi);
								i = UpdatesCount;
								CallFunctionAsync(ExitMe, 0);
								break;
							case 2:
								tszUtilRootPlug = Utils_ReplaceVarsT(_T("%miranda_path%\\Plugins"));
								if (mir_tstrcmp(arAdvFolder[i].c_str(), _T("")) == 0)
									mir_sntprintf(tszFilePathDest, _T("%s\\%s"), tszUtilRootPlug, arFileName[i].c_str());
								else
									mir_sntprintf(tszFilePathDest, _T("%s\\%s\\%s"), tszUtilRootPlug, arAdvFolder[i].c_str(), arFileName[i].c_str());
								mir_sntprintf(tszFilePathBack, _T("%s\\Backups\\%s"), tszRoot, arFileName[i].c_str());
								MoveFile(tszFilePathDest, tszFilePathBack);
								MoveFile(arFilePath[i].c_str(), tszFilePathDest);
								mir_free(tszUtilRootPlug);
								if (i == UpdatesCount - 1)
									CallFunctionAsync(RestartMe, 0);
								break;
							case 3:
								tszUtilRootIco = Utils_ReplaceVarsT(_T("%miranda_path%\\Icons"));
								if (mir_tstrcmp(arAdvFolder[i].c_str(), _T("")) == 0)
									mir_sntprintf(tszFilePathDest, _T("%s\\%s"), tszUtilRootIco, arFileName[i].c_str());
								else
									mir_sntprintf(tszFilePathDest, _T("%s\\%s\\%s"), tszUtilRootIco, arAdvFolder[i].c_str(), arFileName[i].c_str());
								mir_sntprintf(tszFilePathBack, _T("%s\\Backups\\%s"), tszRoot, arFileName[i].c_str());
								MoveFile(tszFilePathDest, tszFilePathBack);
								MoveFile(arFilePath[i].c_str(), tszFilePathDest);
								mir_free(tszUtilRootIco);
								if (i == UpdatesCount - 1)
									CallFunctionAsync(RestartMe, 0);
								break;
							case 4:
								tszUtilRoot = Utils_ReplaceVarsT(_T("%miranda_path%"));
								if (mir_tstrcmp(arAdvFolder[i].c_str(), _T("")) == 0)
									mir_sntprintf(tszFilePathDest, _T("%s\\%s"), tszUtilRoot, arFileName[i].c_str());
								else
									mir_sntprintf(tszFilePathDest, _T("%s\\%s\\%s"), tszUtilRoot, arAdvFolder[i].c_str(), arFileName[i].c_str());
								mir_sntprintf(tszFilePathBack, _T("%s\\Backups\\%s"), tszRoot, arFileName[i].c_str());
								MoveFile(tszFilePathDest, tszFilePathBack);
								MoveFile(arFilePath[i].c_str(), tszFilePathDest);
								mir_free(tszUtilRoot);
								if (i == UpdatesCount - 1)
									CallFunctionAsync(RestartMe, 0);
								break;
							case 5:
								tszUtilRoot = Utils_ReplaceVarsT(_T("%miranda_path%"));
								if (mir_tstrcmp(arAdvFolder[i].c_str(), _T("")) == 0)
									mir_sntprintf(tszFilePathDest, _T("%s\\%s"), tszUtilRoot, arFileName[i].c_str());
								else
									mir_sntprintf(tszFilePathDest, _T("%s\\%s\\%s"), tszUtilRoot, arAdvFolder[i].c_str(), arFileName[i].c_str());
								mir_sntprintf(tszFilePathBack, _T("%s\\Backups\\%s"), tszRoot, arFileName[i].c_str());
								MoveFile(tszFilePathDest, tszFilePathBack);
								MoveFile(arFilePath[i].c_str(), tszFilePathDest);
								mir_free(tszUtilRoot);
								break;
							}
						}
					}
					else { //reminder for not installed pack update
						if (Reminder && (UpdatesCount == 1) && (arFileType[0] == 1))
							db_set_b(NULL, MODNAME, "Reminder", 2);
						mir_sntprintf(tszBuff, TranslateT("You have chosen not to install the pack update immediately.\nYou can install it manually from this location:\n\n%s"), arFilePath[0].c_str());
						Title = TranslateT("Pack Updater");
						Text = tszBuff;
						if (ServiceExists(MS_POPUP_ADDPOPUPT) && db_get_b(NULL, "Popup", "ModuleIsEnabled", 1) && db_get_b(NULL, MODNAME, "Popups2", DEFAULT_POPUP_ENABLED)) {
							Number = 2;
							show_popup(0, Title, Text, Number, 0);
						}
						else if (db_get_b(NULL, MODNAME, "Popups2M", DEFAULT_MESSAGE_ENABLED))
							MessageBox(NULL, Text, Title, MB_ICONINFORMATION);
					}
				}
			}
			EndDialog(hDlg, IDOK);
			return TRUE;

			case IDCANCEL:
				SetWindowLongPtr(hDlg, GWLP_USERDATA, 0);
				Utils_SaveWindowPosition(hDlg, NULL, MODNAME, "ConfirmWindow");
				EndDialog(hDlg, IDCANCEL);
				return TRUE;

			case IDC_INFO:
				int sel = ListView_GetSelectionMark(hwndList);
				vector<FILEINFO> &todo = *(vector<FILEINFO> *)GetWindowLongPtr(hDlg, GWLP_USERDATA);
				Utils_OpenUrlT(todo[sel].tszInfoURL);
			}
			break;
		}
	}
	return FALSE;
}
Exemplo n.º 27
0
static INT_PTR CALLBACK DlgProcIcqOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
{
	CIcqProto *ppro = (CIcqProto*)GetWindowLongPtr( hwndDlg, GWLP_USERDATA );

	switch (msg) {
	case WM_INITDIALOG:
		TranslateDialogDefault(hwndDlg);

		ppro = (CIcqProto*)lParam;
		SetWindowLongPtr(hwndDlg, GWLP_USERDATA, lParam);
		{
			DWORD dwUin = ppro->getContactUin(NULL);
			if (dwUin)
				SetDlgItemInt(hwndDlg, IDC_ICQNUM, dwUin, FALSE);
			else // keep it empty when no UIN entered
				SetDlgItemTextA(hwndDlg, IDC_ICQNUM, "");

			SendDlgItemMessage(hwndDlg, IDC_PASSWORD, EM_LIMITTEXT, PASSWORDMAXLEN - 1, 0);

			// bit of a security hole here, since it's easy to extract a password from an edit box
			char pszPwd[PASSWORDMAXLEN];
			if (ppro->GetUserStoredPassword(pszPwd, sizeof(pszPwd)))
				SetDlgItemTextA(hwndDlg, IDC_PASSWORD, pszPwd);

			LoadDBCheckState(ppro, hwndDlg, IDC_SSL, "SecureConnection", DEFAULT_SECURE_CONNECTION);
			LoadDBCheckState(ppro, hwndDlg, IDC_MD5LOGIN, "SecureLogin", DEFAULT_SECURE_LOGIN);
			LoadDBCheckState(ppro, hwndDlg, IDC_LEGACY, "LegacyFix", DEFAULT_LEGACY_FIX);

			char szServer[MAX_PATH];
			if (!ppro->getSettingStringStatic(NULL, "OscarServer", szServer, MAX_PATH))
				SetDlgItemTextA(hwndDlg, IDC_ICQSERVER, szServer);
			else
				SetDlgItemTextA(hwndDlg, IDC_ICQSERVER, IsDlgButtonChecked(hwndDlg, IDC_SSL) ? DEFAULT_SERVER_HOST_SSL : DEFAULT_SERVER_HOST);

			SetDlgItemInt(hwndDlg, IDC_ICQPORT, ppro->getWord("OscarPort", IsDlgButtonChecked(hwndDlg, IDC_SSL) ? DEFAULT_SERVER_PORT_SSL : DEFAULT_SERVER_PORT), FALSE);
			LoadDBCheckState(ppro, hwndDlg, IDC_KEEPALIVE, "KeepAlive", DEFAULT_KEEPALIVE_ENABLED);
			SendDlgItemMessage(hwndDlg, IDC_LOGLEVEL, TBM_SETRANGE, FALSE, MAKELONG(0, 4));
			SendDlgItemMessage(hwndDlg, IDC_LOGLEVEL, TBM_SETPOS, TRUE, 4 - ppro->getByte("ShowLogLevel", LOG_WARNING));
			SetDlgItemText(hwndDlg, IDC_LEVELDESCR, TranslateTS(szLogLevelDescr[4 - SendDlgItemMessage(hwndDlg, IDC_LOGLEVEL, TBM_GETPOS, 0, 0)]));
			ShowDlgItem(hwndDlg, IDC_RECONNECTREQD, SW_HIDE);
			LoadDBCheckState(ppro, hwndDlg, IDC_NOERRMULTI, "IgnoreMultiErrorBox", 0);
		}
		return TRUE;

	case WM_HSCROLL:
		SetDlgItemText(hwndDlg, IDC_LEVELDESCR, TranslateTS(szLogLevelDescr[4 - SendDlgItemMessage(hwndDlg, IDC_LOGLEVEL, TBM_GETPOS, 0, 0)]));
		OptDlgChanged(hwndDlg);
		break;

	case WM_COMMAND:
		switch (LOWORD(wParam)) {
		case IDC_LOOKUPLINK:
			Utils_OpenUrl(URL_FORGOT_PASSWORD);
			return TRUE;

		case IDC_NEWUINLINK:
			Utils_OpenUrl(URL_REGISTER);
			return TRUE;

		case IDC_RESETSERVER:
			SetDlgItemInt(hwndDlg, IDC_ICQPORT, IsDlgButtonChecked(hwndDlg, IDC_SSL) ? DEFAULT_SERVER_PORT_SSL : DEFAULT_SERVER_PORT, FALSE);

		case IDC_SSL:
			SetDlgItemTextA(hwndDlg, IDC_ICQSERVER, IsDlgButtonChecked(hwndDlg, IDC_SSL) ? DEFAULT_SERVER_HOST_SSL : DEFAULT_SERVER_HOST);
			SetDlgItemInt(hwndDlg, IDC_ICQPORT, IsDlgButtonChecked(hwndDlg, IDC_SSL) ? DEFAULT_SERVER_PORT_SSL : DEFAULT_SERVER_PORT, FALSE);
			OptDlgChanged(hwndDlg);
			return TRUE;
		}

		if (ppro->icqOnline() && LOWORD(wParam) != IDC_NOERRMULTI) {
			char szClass[80];
			GetClassNameA((HWND)lParam, szClass, sizeof(szClass));

			if (mir_strcmpi(szClass, "EDIT") || HIWORD(wParam) == EN_CHANGE)
				ShowDlgItem(hwndDlg, IDC_RECONNECTREQD, SW_SHOW);
		}

		if ((LOWORD(wParam) == IDC_ICQNUM || LOWORD(wParam) == IDC_PASSWORD || LOWORD(wParam) == IDC_ICQSERVER || LOWORD(wParam) == IDC_ICQPORT) &&
			 (HIWORD(wParam) != EN_CHANGE || (HWND)lParam != GetFocus())) {
			return 0;
		}

		OptDlgChanged(hwndDlg);
		break;

	case WM_NOTIFY:
		switch (((LPNMHDR)lParam)->code) {
		case PSN_APPLY:
			char str[128];

			ppro->setDword(UNIQUEIDSETTING, GetDlgItemInt(hwndDlg, IDC_ICQNUM, NULL, FALSE));
			GetDlgItemTextA(hwndDlg, IDC_PASSWORD, str, _countof(ppro->m_szPassword));
			if (mir_strlen(str)) {
				mir_strcpy(ppro->m_szPassword, str);
				ppro->m_bRememberPwd = true;
			}
			else ppro->m_bRememberPwd = ppro->getByte("RememberPass", 0);
			ppro->setString("Password", str);

			GetDlgItemTextA(hwndDlg, IDC_ICQSERVER, str, _countof(str));
			ppro->setString("OscarServer", str);

			ppro->setWord("OscarPort", (WORD)GetDlgItemInt(hwndDlg, IDC_ICQPORT, NULL, FALSE));

			StoreDBCheckState(ppro, hwndDlg, IDC_KEEPALIVE, "KeepAlive");
			StoreDBCheckState(ppro, hwndDlg, IDC_SSL, "SecureConnection");
			StoreDBCheckState(ppro, hwndDlg, IDC_MD5LOGIN, "SecureLogin");
			StoreDBCheckState(ppro, hwndDlg, IDC_LEGACY, "LegacyFix");
			StoreDBCheckState(ppro, hwndDlg, IDC_NOERRMULTI, "IgnoreMultiErrorBox");
			ppro->setByte("ShowLogLevel", (BYTE)(4 - SendDlgItemMessage(hwndDlg, IDC_LOGLEVEL, TBM_GETPOS, 0, 0)));
			return true;
		}
		break;
	}

	return FALSE;
}
Exemplo n.º 28
0
//============  WEATHER INI SETUP DIALOG  ============
//
static INT_PTR CALLBACK DlgProcSetup(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
{
	switch (msg) {
	case WM_INITDIALOG:
		TranslateDialogDefault(hwndDlg);

		// make the buttons flat
		SendDlgItemMessage(hwndDlg, IDC_STEP1, BUTTONSETASFLATBTN, TRUE, 0);
		SendDlgItemMessage(hwndDlg, IDC_STEP2, BUTTONSETASFLATBTN, TRUE, 0);
		SendDlgItemMessage(hwndDlg, IDC_STEP3, BUTTONSETASFLATBTN, TRUE, 0);
		SendDlgItemMessage(hwndDlg, IDC_STEP4, BUTTONSETASFLATBTN, TRUE, 0);

		// set icons
		Window_SetIcon_IcoLib(hwndDlg, GetIconHandle("main"));

		WindowList_Add(hWindowList, hwndDlg, NULL);
		ShowWindow(hwndDlg, SW_SHOW);
		break;

	case WM_COMMAND:
		switch (LOWORD(wParam)) {
		case IDC_STEP1:
			// update current data
			Utils_OpenUrl("http://miranda-ng.org/");
			break;

		case IDC_STEP2:
		{
			TCHAR szPath[1024];
			GetModuleFileName(GetModuleHandle(NULL), szPath, _countof(szPath));
			TCHAR *chop = _tcsrchr(szPath, '\\');
			if (chop) {
				*chop = '\0';
				mir_tstrncat(szPath, _T("\\Plugins\\weather\\"), _countof(szPath) - mir_tstrlen(szPath));
				if (_tmkdir(szPath) == 0)
					ShellExecute((HWND)lParam, _T("open"), szPath, _T(""), _T(""), SW_SHOW);
			}
			break;
		}

		case IDC_STEP3:
			if (LoadWIData(false))
				MessageBox(NULL,
					TranslateT("All update data has been reloaded."),
					TranslateT("Weather Protocol"), MB_OK | MB_ICONINFORMATION);
			break;

		case IDC_STEP4:
			WeatherAdd(0, 0);
			// fall through
		case IDCANCEL:
			// close the info window
			DestroyWindow(hwndDlg);
			break;
		}
		break;

	case WM_CLOSE:
		DestroyWindow(hwndDlg);
		break;

	case WM_DESTROY:
		Window_FreeIcon_IcoLib(hwndDlg);
		break;
	}
	return FALSE;
}
Exemplo n.º 29
0
static INT_PTR CALLBACK DlgProcMsnOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
{
    switch (msg) {
    case WM_INITDIALOG:
        TranslateDialogDefault(hwndDlg);
        {
            SetWindowLongPtr(hwndDlg, GWLP_USERDATA, lParam);
            CMsnProto* proto = (CMsnProto*)lParam;

            SetDlgItemTextA(hwndDlg, IDC_HANDLE, proto->MyOptions.szEmail);

            char tBuffer[MAX_PATH];
            if (!db_get_static(NULL, proto->m_szModuleName, "Password", tBuffer, sizeof(tBuffer))) {
                tBuffer[16] = 0;
                SetDlgItemTextA(hwndDlg, IDC_PASSWORD, tBuffer);
            }
            SendDlgItemMessage(hwndDlg, IDC_PASSWORD, EM_SETLIMITTEXT, 16, 0);

            HWND wnd = GetDlgItem(hwndDlg, IDC_HANDLE2);
            DBVARIANT dbv;
            if (!proto->getTString("Nick", &dbv)) {
                SetWindowText(wnd, dbv.ptszVal);
                db_free(&dbv);
            }
            EnableWindow(wnd, proto->msnLoggedIn);
            EnableWindow(GetDlgItem(hwndDlg, IDC_MOBILESEND), proto->msnLoggedIn &&
                         proto->getByte("MobileEnabled", 0) && proto->getByte("MobileAllowed", 0));

            CheckDlgButton(hwndDlg, IDC_MOBILESEND, proto->getByte("MobileAllowed", 0) ? BST_CHECKED : BST_UNCHECKED);
            CheckDlgButton(hwndDlg, IDC_SENDFONTINFO, proto->getByte("SendFontInfo", 1) ? BST_CHECKED : BST_UNCHECKED);
            CheckDlgButton(hwndDlg, IDC_MANAGEGROUPS, proto->getByte("ManageServer", 1) ? BST_CHECKED : BST_UNCHECKED);

            int tValue = proto->getByte("RunMailerOnHotmail", 0);
            CheckDlgButton(hwndDlg, IDC_RUN_APP_ON_HOTMAIL, tValue ? BST_CHECKED : BST_UNCHECKED);
            EnableWindow(GetDlgItem(hwndDlg, IDC_MAILER_APP), tValue);
            EnableWindow(GetDlgItem(hwndDlg, IDC_ENTER_MAILER_APP), tValue);

            if (!db_get_static(NULL, proto->m_szModuleName, "MailerPath", tBuffer, sizeof(tBuffer)))
                SetDlgItemTextA(hwndDlg, IDC_MAILER_APP, tBuffer);

            if (!proto->msnLoggedIn) {
                EnableWindow(GetDlgItem(hwndDlg, IDC_MANAGEGROUPS), FALSE);
                EnableWindow(GetDlgItem(hwndDlg, IDC_DISABLE_ANOTHER_CONTACTS), FALSE);
            }
            else CheckDlgButton(hwndDlg, IDC_DISABLE_ANOTHER_CONTACTS, proto->msnOtherContactsBlocked ? BST_CHECKED : BST_UNCHECKED);
        }
        return TRUE;

    case WM_COMMAND:
        if (LOWORD(wParam) == IDC_NEWMSNACCOUNTLINK) {
            Utils_OpenUrl("https://signup.live.com");
            return TRUE;
        }

        if (HIWORD(wParam) == EN_CHANGE && (HWND)lParam == GetFocus()) {
            switch (LOWORD(wParam)) {
            case IDC_HANDLE:
            case IDC_PASSWORD:
            case IDC_HANDLE2:
            case IDC_GATEWAYSERVER:
            case IDC_YOURHOST:
            case IDC_DIRECTSERVER:
                SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
            }
        }

        if (HIWORD(wParam) == BN_CLICKED) {
            switch (LOWORD(wParam)) {
            case IDC_SENDFONTINFO:
            case IDC_DISABLE_ANOTHER_CONTACTS:
            case IDC_MOBILESEND:
                SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
                break;

            case IDC_MANAGEGROUPS:
                if (IsDlgButtonChecked(hwndDlg, IDC_MANAGEGROUPS)) {
                    if (IDYES == MessageBox(hwndDlg,
                                            TranslateT("Server groups import may change your contact list layout after next login. Do you want to upload your groups to the server?"),
                                            TranslateT("MSN Protocol"), MB_YESNOCANCEL)) {
                        CMsnProto* proto = (CMsnProto*)GetWindowLongPtr(hwndDlg, GWLP_USERDATA);
                        proto->MSN_UploadServerGroups(NULL);
                    }
                }
                SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
                break;

            case IDC_RUN_APP_ON_HOTMAIL:
            {
                BOOL tIsChosen = IsDlgButtonChecked(hwndDlg, IDC_RUN_APP_ON_HOTMAIL);
                EnableWindow(GetDlgItem(hwndDlg, IDC_MAILER_APP), tIsChosen);
                EnableWindow(GetDlgItem(hwndDlg, IDC_ENTER_MAILER_APP), tIsChosen);
                SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
            }
            break;

            case IDC_ENTER_MAILER_APP:
                char szFile[MAX_PATH + 2];
                {
                    HWND tEditField = GetDlgItem(hwndDlg, IDC_MAILER_APP);

                    GetWindowTextA(tEditField, szFile, _countof(szFile));

                    size_t tSelectLen = 0;

                    if (szFile[0] == '\"') {
                        char* p = strchr(szFile + 1, '\"');
                        if (p != NULL) {
                            *p = '\0';
                            memmove(szFile, szFile + 1, mir_strlen(szFile));
                            tSelectLen += 2;
                            goto LBL_Continue;
                        }
                    }

                    char* p = strchr(szFile, ' ');
                    if (p != NULL) *p = '\0';
LBL_Continue:
                    tSelectLen += mir_strlen(szFile);

                    OPENFILENAMEA ofn = { 0 };
                    ofn.lStructSize = sizeof(ofn);
                    ofn.hwndOwner = hwndDlg;
                    ofn.nMaxFile = _countof(szFile);
                    ofn.lpstrFile = szFile;
                    ofn.Flags = OFN_FILEMUSTEXIST | OFN_NOCHANGEDIR;
                    if (GetOpenFileNameA(&ofn) != TRUE)
                        break;

                    if (strchr(szFile, ' ') != NULL) {
                        char tmpBuf[MAX_PATH + 2];
                        mir_snprintf(tmpBuf, _countof(tmpBuf), "\"%s\"", szFile);
                        mir_strcpy(szFile, tmpBuf);
                    }

                    SendMessage(tEditField, EM_SETSEL, 0, tSelectLen);
                    SendMessageA(tEditField, EM_REPLACESEL, TRUE, LPARAM(szFile));
                    SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
                }
            }
        }
        break;

    case WM_NOTIFY:
        if (((LPNMHDR)lParam)->code == (UINT)PSN_APPLY) {
            bool reconnectRequired = false;
            TCHAR screenStr[MAX_PATH];
            char  password[100], szEmail[MSN_MAX_EMAIL_LEN];
            DBVARIANT dbv;

            CMsnProto* proto = (CMsnProto*)GetWindowLongPtr(hwndDlg, GWLP_USERDATA);

            GetDlgItemTextA(hwndDlg, IDC_HANDLE, szEmail, _countof(szEmail));
            if (mir_strcmp(_strlwr(szEmail), proto->MyOptions.szEmail)) {
                reconnectRequired = true;
                mir_strcpy(proto->MyOptions.szEmail, szEmail);
                proto->setString("e-mail", szEmail);
                proto->setString("wlid", szEmail);
                proto->setDword("netId", (proto->MyOptions.netId = proto->GetMyNetID()));
            }

            GetDlgItemTextA(hwndDlg, IDC_PASSWORD, password, _countof(password));
            if (!proto->getString("Password", &dbv)) {
                if (mir_strcmp(password, dbv.pszVal)) {
                    reconnectRequired = true;
                    proto->setString("Password", password);
                }
                db_free(&dbv);
            }
            else {
                reconnectRequired = true;
                proto->setString("Password", password);
            }

#ifdef OBSOLETE
            GetDlgItemText(hwndDlg, IDC_HANDLE2, screenStr, _countof(screenStr));
            if (!proto->getTString("Nick", &dbv)) {
                if (mir_tstrcmp(dbv.ptszVal, screenStr))
                    proto->MSN_SendNickname(screenStr);
                db_free(&dbv);
            }
            else proto->MSN_SendNickname(screenStr);

            BYTE mblsnd = IsDlgButtonChecked(hwndDlg, IDC_MOBILESEND) == BST_CHECKED;
            if (mblsnd != proto->getByte("MobileAllowed", 0)) {
                proto->msnNsThread->sendPacket("PRP", "MOB %c", mblsnd ? 'Y' : 'N');
                proto->MSN_SetServerStatus(proto->m_iStatus);
            }

            unsigned tValue = IsDlgButtonChecked(hwndDlg, IDC_DISABLE_ANOTHER_CONTACTS);
            if (tValue != proto->msnOtherContactsBlocked && proto->msnLoggedIn) {
                proto->msnOtherContactsBlocked = tValue;
                proto->msnNsThread->sendPacket("BLP", tValue ? "BL" : "AL");
                proto->MSN_ABUpdateAttr(NULL, "MSN.IM.BLP", tValue ? "0" : "1");
                break;
            }
#endif

            proto->setByte("SendFontInfo", (BYTE)IsDlgButtonChecked(hwndDlg, IDC_SENDFONTINFO));
            proto->setByte("RunMailerOnHotmail", (BYTE)IsDlgButtonChecked(hwndDlg, IDC_RUN_APP_ON_HOTMAIL));
            proto->setByte("ManageServer", (BYTE)IsDlgButtonChecked(hwndDlg, IDC_MANAGEGROUPS));

            GetDlgItemText(hwndDlg, IDC_MAILER_APP, screenStr, _countof(screenStr));
            proto->setTString("MailerPath", screenStr);

            if (reconnectRequired && proto->msnLoggedIn)
                MessageBox(hwndDlg,
                           TranslateT("The changes you have made require you to reconnect to the MSN Messenger network before they take effect"),
                           TranslateT("MSN Options"), MB_OK);

            proto->LoadOptions();
            return TRUE;
        }
        break;
    }

    return FALSE;
}