Beispiel #1
0
void CJabberDlgBookmarks::OpenBookmark()
{
	int iItem = m_lvBookmarks.GetNextItem(-1, LVNI_SELECTED);
	if (iItem < 0) return;

	TCHAR *address = (TCHAR *)m_lvBookmarks.GetItemData(iItem);
	if (address == NULL) return;

	JABBER_LIST_ITEM *item = m_proto->ListGetItemPtr(LIST_BOOKMARK, address);
	if (item == NULL) return;

	if (!mir_tstrcmpi(item->type, _T("conference"))) {
		m_lvBookmarks.SetItemState(iItem, 0, LVIS_SELECTED); // Unselect the item

		/* some hack for using bookmark to transport not under XEP-0048 */
		if (!_tcschr(item->jid, _T('@')))
			//the room name is not provided let consider that it is transport and send request to registration
			m_proto->RegisterAgent(NULL, item->jid);
		else {
			TCHAR *room = NEWTSTR_ALLOCA(item->jid);
			TCHAR *server = _tcschr(room, _T('@'));
			*(server++) = 0;

			if (item->nick && *item->nick)
				m_proto->GroupchatJoinRoom(server, room, item->nick, item->password);
			else
				m_proto->GroupchatJoinRoom(server, room, ptrT(JabberNickFromJID(m_proto->m_szJabberJID)), item->password);
		}
	}
	else Utils_OpenUrlT(item->jid);
}
Beispiel #2
0
static LRESULT CALLBACK PluginListWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
	if (msg == WM_LBUTTONDOWN) {
		LVHITTESTINFO hi;
		hi.pt.x = LOWORD(lParam); hi.pt.y = HIWORD(lParam);
		ListView_SubItemHitTest(hwnd, &hi);
		if ((hi.iSubItem == 0) && (hi.flags & LVHT_ONITEMICON)) {
			LVITEM lvi = {0};
			lvi.mask = LVIF_IMAGE | LVIF_PARAM | LVIF_GROUPID;
			lvi.stateMask = -1;
			lvi.iItem = hi.iItem;
			if (ListView_GetItem(hwnd, &lvi) && lvi.iGroupId == 1) {
				FILEINFO *info = (FILEINFO *)lvi.lParam;

				TCHAR tszFileName[MAX_PATH];
				_tcscpy(tszFileName, _tcsrchr(info->tszNewName, L'\\') + 1);
				TCHAR *p = _tcschr(tszFileName, L'.'); *p = 0;

				TCHAR link[MAX_PATH];
				mir_sntprintf(link, _countof(link), PLUGIN_INFO_URL, tszFileName);
				Utils_OpenUrlT(link);
			}
		}
	}

	return CallWindowProc(oldWndProc, hwnd, msg, wParam, lParam);
}
Beispiel #3
0
INT_PTR __cdecl CVkProto::SvcOpenBroadcast(WPARAM hContact, LPARAM)
{
	debugLogA("CVkProto::SvcOpenBroadcast");

	CMString tszAudio(ptrT(db_get_tsa(hContact, m_szModuleName, "AudioUrl")));
	if (!tszAudio.IsEmpty())
		Utils_OpenUrlT(tszAudio);

	return 0;
}
Beispiel #4
0
void IEViewSink::BeforeNavigate2(IDispatch*, VARIANT* url, VARIANT*, VARIANT*, VARIANT*, VARIANT*, VARIANT_BOOL* cancel)
{
#ifndef GECKO
	if (mir_tstrcmp(url->bstrVal, _T("about:blank")))
	{
		Utils_OpenUrlT(url->bstrVal);
		*cancel = VARIANT_TRUE;
	}
#endif
}
Beispiel #5
0
INT_PTR __cdecl CVkProto::SvcVisitProfile(WPARAM hContact, LPARAM)
{
	debugLogA("CVkProto::SvcVisitProfile");
	if (isChatRoom(hContact)) {
		ptrT tszHomepage(db_get_tsa(hContact, m_szModuleName, "Homepage"));
		if(!IsEmpty(tszHomepage))
			Utils_OpenUrlT(tszHomepage);
		return 0;
	}

	LONG userID = getDword(hContact, "ID", -1);
	ptrT tszDomain(db_get_tsa(hContact, m_szModuleName, "domain"));

	CMString tszUrl("https://vk.com/");
	if (tszDomain)
		tszUrl.Append(tszDomain);
	else
		tszUrl.AppendFormat(_T("id%i"), userID);
	
	Utils_OpenUrlT(tszUrl);
	return 0;
}
Beispiel #6
0
void FacebookProto::OpenUrl(std::string url)
{
	url = PrepareUrl(url);
	ptrT data(mir_utf8decodeT(url.c_str()));

	// Check if there is user defined browser for opening links
	ptrT browser(getTStringA(FACEBOOK_KEY_OPEN_URL_BROWSER));
	if (browser != NULL)
		// If so, use it to open this link
		ForkThread(&FacebookProto::OpenUrlThread, new open_url(browser, data));
	else
		// Or use Miranda's service
		Utils_OpenUrlT(data);
}
Beispiel #7
0
bool IEView::mouseClick(POINT pt)
{
	if (GetFocus() != hwnd)
		getFocus = true;

	CComPtr<IHTMLDocument2> document = getDocument();
	if (document == NULL)
		return false;

	CComPtr<IHTMLElement> element;
	if (SUCCEEDED(document->elementFromPoint(pt.x, pt.y, &element)) && element != NULL) {
		ptrW url(getHrefFromAnchor(element));
		if (url != NULL) {
			if ((GetKeyState(VK_SHIFT) & 0x8000) && !(GetKeyState(VK_CONTROL) & 0x8000) && !(GetKeyState(VK_MENU) & 0x8000))
				SendMessage(GetParent(hwnd), WM_COMMAND, IDCANCEL, 0);

			Utils_OpenUrlT(url);
			return true;
		}
	}

	return false;
}
Beispiel #8
0
/*
MainDlgProc handles messages to the main dialog box
*/
INT_PTR CALLBACK MainDlgProc(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam)
{
	DIALOGPARAM *DlgParam = (DIALOGPARAM*)GetWindowLongPtr(hDlg, GWLP_USERDATA);
	HMENU listMenu;

	switch (msg) {
	case WM_INITDIALOG: {
		MCONTACT hContact;
		TCHAR title[256];
		TCHAR filter[FILTERTEXT];
		RECT rc;
		POINT pt;
			
		SetWindowLongPtr(hDlg, GWLP_USERDATA, lParam);
		DlgParam = (DIALOGPARAM*)lParam;
		listMenu = GetMenu(hDlg);
		TranslateDialogDefault(hDlg);
		TranslateMenu(listMenu);

		hContact = ((db_get_b(NULL, LINKLIST_MODULE, LINKLIST_SAVESPECIAL, 0) == 0) ? NULL: DlgParam->hContact);
		if (db_get_b(hContact, LINKLIST_MODULE, LINKLIST_FIRST, 0) == 0) {
			// First use of this plugin! Set default size!
			db_set_dw(hContact, LINKLIST_MODULE, "LinklistWidth", 400);
			db_set_dw(hContact, LINKLIST_MODULE, "LinklistHeight", 450);
			db_set_dw(hContact, LINKLIST_MODULE, "LinklistX", 0);
			db_set_dw(hContact, LINKLIST_MODULE, "LinklistY", 0);
				
			db_set_b(hContact, LINKLIST_MODULE, LINKLIST_FIRST, 1);
		}

		DlgParam->splitterPosNew = (int)db_get_dw(hContact, LINKLIST_MODULE, LINKLIST_SPLITPOS, -1);

		GetWindowRect(GetDlgItem(hDlg, IDC_MAIN), &rc);
		DlgParam->minSize.cx = rc.right - rc.left;
		DlgParam->minSize.cy = rc.bottom - rc.top;

		GetWindowRect(GetDlgItem(hDlg, IDC_SPLITTER), &rc);
		pt.y = (rc.top + rc.bottom) / 2;
		pt.x = 0;
		ScreenToClient(hDlg, &pt);
			
		DlgParam->splitterPosOld = rc.bottom - 20 - pt.y;
		if(DlgParam->splitterPosNew == -1)
			DlgParam->splitterPosNew = DlgParam->splitterPosOld;
			
		Utils_RestoreWindowPosition(hDlg, hContact, LINKLIST_MODULE, "Linklist");

		SetClassLongPtr(hDlg, GCLP_HICON, (LONG_PTR)LoadIcon(hInst, MAKEINTRESOURCE(IDI_LINKLISTICON))); 
		WindowList_Add(hWindowList, hDlg, DlgParam->hContact);
		mir_sntprintf(title, _T("%s [%s]"), TranslateT("Linklist plugin"), pcli->pfnGetContactDisplayName(DlgParam->hContact, 0));
		SetWindowText(hDlg, title);
		GetFilterText(listMenu, filter, _countof(filter));
		SetDlgItemText(hDlg, IDC_STATUS, filter);
			
		mir_subclassWindow(GetDlgItem(hDlg, IDC_SPLITTER), SplitterProc);
			
		SendDlgItemMessage( hDlg, IDC_MAIN, EM_SETEVENTMASK, 0, (LPARAM)ENM_LINK);
		SendDlgItemMessage( hDlg, IDC_MAIN, EM_AUTOURLDETECT, TRUE, 0 );
		// This is used in srmm... and I think he knew what he did... :)
		SendDlgItemMessage(hDlg, IDC_MAIN, EM_LIMITTEXT, (WPARAM)-1, 0);

		WriteLinkList(hDlg, WLL_ALL, (LISTELEMENT*)DlgParam->listStart, NULL, 0);

		return TRUE;
		} break;
	// open browser an load url if link is pressed
	// found at
	// http://www.tech-archive.net/Archive/Development/microsoft.public.win32.programmer.ui/2004-03/0133.html
	//
	// Popup menu on right mouse button is mainly taken from the miranda 
	// send/receive messaging plugin.
	case WM_NOTIFY: {  
		if (lParam == NULL)
			break;
		if (((LPNMHDR)lParam)->code != EN_LINK)
			break;
		LPTSTR link;
		BYTE mouseEvent;
		ENLINK *pENLink = (ENLINK*)lParam;

		mouseEvent = db_get_b(NULL, LINKLIST_MODULE, LINKLIST_MOUSE_EVENT, 0xFF);

		switch (pENLink->msg) {
		case WM_MOUSEMOVE:
			if (mouseEvent != 0x01)
				break;
			memcpy(&DlgParam->chrg, &pENLink->chrg, sizeof(CHARRANGE));
			SendDlgItemMessage(hDlg, IDC_MAIN, EM_EXSETSEL, 0, (LPARAM)&pENLink->chrg);
			WriteMessage(hDlg, DlgParam->listStart, SendDlgItemMessage(hDlg, IDC_MAIN, EM_LINEFROMCHAR, -1, 0));
			break;
		case WM_LBUTTONUP:
			link = (LPTSTR)mir_alloc((pENLink->chrg.cpMax - pENLink->chrg.cpMin + 2) * sizeof(TCHAR));
			if (link == NULL)
				break;
			SendDlgItemMessage(hDlg, IDC_MAIN, EM_EXSETSEL, 0, (LPARAM)&pENLink->chrg); 
			SendDlgItemMessage(hDlg, IDC_MAIN, EM_GETSELTEXT, 0, (LPARAM)link);
			if (_tcsstr(link, _T("mailto:")) != NULL)
				ShellExecute(HWND_TOP, NULL, link, NULL, NULL, SW_SHOWNORMAL); 
			else {
				bool openNewWindow = db_get_b(NULL, LINKLIST_MODULE, LINKLIST_OPEN_WINDOW, 0xFF) != 0xFF;
				Utils_OpenUrlT(link,openNewWindow);
			}
			mir_free(link);
			break;
		case WM_RBUTTONDOWN: { 
			HMENU hPopup, hSubMenu;
			POINT pt;
			hPopup = LoadMenu(hInst, MAKEINTRESOURCE(IDR_MENU2));
			hSubMenu = GetSubMenu(hPopup, 0);

			// Disable Menuoption if "mouse over" events are active
			mouseEvent = db_get_b(NULL, LINKLIST_MODULE, LINKLIST_MOUSE_EVENT, 0xFF);
			if (mouseEvent == 0x01)
				EnableMenuItem(hSubMenu, IDM_SHOWMESSAGE, MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);	
			TranslateMenu(hSubMenu);
			link = (LPTSTR)mir_alloc((pENLink->chrg.cpMax - pENLink->chrg.cpMin + 4) * sizeof(TCHAR));
			if (link == NULL)
				break;
			SendDlgItemMessage(hDlg, IDC_MAIN, EM_EXSETSEL, 0, (LPARAM)&pENLink->chrg); 
			SendDlgItemMessage(hDlg, IDC_MAIN, EM_GETSELTEXT, 0, (LPARAM)link);

			pt.x = (short)LOWORD(pENLink->lParam);
			pt.y = (short)HIWORD(pENLink->lParam);
			ClientToScreen(((NMHDR*)lParam)->hwndFrom, &pt);

			switch (TrackPopupMenu(hSubMenu, TPM_RETURNCMD, pt.x, pt.y, 0, hDlg, NULL)) {
			case IDM_LINK_OPEN:
				if (_tcsstr(link, _T("mailto:")) != NULL)
					ShellExecute(HWND_TOP, NULL, link, NULL, NULL, SW_SHOWNORMAL); 
				else
					Utils_OpenUrlT(link,false);
				break;
			case IDM_LINK_OPENNEW:
				if (_tcsstr(link, _T("mailto:")) != NULL)
					ShellExecute(HWND_TOP, NULL, link, NULL, NULL, SW_SHOWNORMAL); 
				else
					Utils_OpenUrlT(link);
				break;
			case IDM_LINK_COPY: {
				if (!OpenClipboard(hDlg))
					break;
				EmptyClipboard();

				size_t dataLen = ((mir_tstrlen(link) + 1) * sizeof(TCHAR));
				HGLOBAL hData = GlobalAlloc(GMEM_MOVEABLE, dataLen);
				memcpy((LPTSTR)GlobalLock(hData), link, dataLen);
				GlobalUnlock(hData);
				SetClipboardData(CF_UNICODETEXT, hData);
				CloseClipboard();
				} break;
			case IDM_SHOWMESSAGE:
				WriteMessage(hDlg, DlgParam->listStart, SendDlgItemMessage(hDlg, IDC_MAIN, EM_LINEFROMCHAR, -1, 0));
				break;
			}
			mir_free(link);
			DestroyMenu(hPopup);
			} break;
		}
		} break;
	case WM_COMMAND: {
		TCHAR filter[40];

		listMenu = GetMenu(hDlg);
		switch (wParam) {
		case IDM_SEARCH: // open Search Box
			if (DlgParam != 0) {	
				HWND hWndSearchDlg = CreateDialogParam(hInst, MAKEINTRESOURCE(IDD_SEARCH_DLG), hDlg, SearchDlgProc, (LPARAM)DlgParam);
				EnableMenuItem(listMenu, IDM_SEARCH, (MF_BYCOMMAND | MF_DISABLED | MF_GRAYED));
				ShowWindow(hWndSearchDlg, SW_SHOW);
				SetFocus(GetDlgItem(hWndSearchDlg, IDC_SEARCHSTRING));
			}
			break;
		case IDM_CLEARSEARCH: // clear search results
			GetFilterText(listMenu, filter, _countof(filter));
			SetDlgItemText(hDlg, IDC_STATUS, filter);
			SetDlgItemText(hDlg, IDC_MAIN, _T(""));
			WriteLinkList(hDlg, GetFlags(listMenu), DlgParam->listStart, NULL, 0);
			break;
		case IDM_SAVE: // save button
			SaveEditAsStream(hDlg);
			SetFocus(GetDlgItem(hDlg, IDC_MAIN));
			break;
		case IDCANCEL: // Esc or Close pressed
		case IDM_CLOSE:
			SendMessage(hDlg, WM_CLOSE, 0, 0);
			break;
		case IDM_DIR_IN: // view only incoming messages
			GetFilterText(listMenu, filter, _countof(filter));
			SetDlgItemText(hDlg, IDC_STATUS, filter);
			if ((GetMenuState(listMenu, IDM_SEARCH, MF_BYCOMMAND) & MF_DISABLED))
				break; // not possible if search dialog is open
			SetDlgItemText(hDlg, IDC_MAIN, _T(""));
			if (GetMenuState(listMenu, IDM_DIR_IN, MF_BYCOMMAND) == MF_CHECKED) {
				CheckMenuItem(listMenu, IDM_DIR_IN, MF_UNCHECKED);
				WriteLinkList(hDlg, GetFlags(listMenu), DlgParam->listStart, NULL, 0);
			} else {
				CheckMenuItem(listMenu, IDM_DIR_IN, MF_CHECKED);
				CheckMenuItem(listMenu, IDM_DIR_OUT, MF_UNCHECKED);
				WriteLinkList(hDlg, GetFlags(listMenu), DlgParam->listStart, NULL, 0);
			}		
			GetFilterText(GetMenu(hDlg), filter, _countof(filter));
			SetDlgItemText(hDlg, IDC_STATUS, filter);
			break;
		case IDM_DIR_OUT: // view only outgoing messages
			GetFilterText(listMenu, filter, _countof(filter));
			SetDlgItemText(hDlg, IDC_STATUS, filter);
			if ((GetMenuState(listMenu, IDM_SEARCH, MF_BYCOMMAND) & MF_DISABLED))
				break; // not possible if search dialog is open
			SetDlgItemText(hDlg, IDC_MAIN, _T(""));
			if (GetMenuState(listMenu, IDM_DIR_OUT, MF_BYCOMMAND) == MF_CHECKED) {
				CheckMenuItem(listMenu, IDM_DIR_OUT, MF_UNCHECKED);		
				WriteLinkList(hDlg, GetFlags(listMenu), DlgParam->listStart, NULL, 0);
			} else {
				CheckMenuItem(listMenu, IDM_DIR_OUT, MF_CHECKED);
				CheckMenuItem(listMenu, IDM_DIR_IN, MF_UNCHECKED);
				WriteLinkList(hDlg, GetFlags(listMenu), DlgParam->listStart, NULL, 0);
			}
			GetFilterText(listMenu, filter, _countof(filter));
			SetDlgItemText(hDlg, IDC_STATUS, filter);
			break;
		case IDM_TYPE_WEB: // view only e-mail addresses
			GetFilterText(listMenu, filter, _countof(filter));
			SetDlgItemText(hDlg, IDC_STATUS, filter);
			// not possible if search dialog is open
			if ((GetMenuState(listMenu, IDM_SEARCH, MF_BYCOMMAND) & MF_DISABLED))
				break;
			SetDlgItemText(hDlg, IDC_MAIN, _T(""));
			if (GetMenuState(listMenu, IDM_TYPE_WEB, MF_BYCOMMAND) == MF_CHECKED) {
				CheckMenuItem(listMenu, IDM_TYPE_WEB, MF_UNCHECKED);		
				WriteLinkList(hDlg, GetFlags(listMenu), DlgParam->listStart, NULL, 0);
			} else {
				CheckMenuItem(listMenu, IDM_TYPE_WEB, MF_CHECKED);
				CheckMenuItem(listMenu, IDM_TYPE_MAIL, MF_UNCHECKED);
				WriteLinkList(hDlg, GetFlags(listMenu), DlgParam->listStart, NULL, 0);
			}
			GetFilterText(listMenu, filter, _countof(filter));
			SetDlgItemText(hDlg, IDC_STATUS, filter);
			break;
		case IDM_TYPE_MAIL: // view only URLs
			if ((GetMenuState(listMenu, IDM_SEARCH, MF_BYCOMMAND) & MF_DISABLED))
				break; // not possible if search dialog is open
			SetDlgItemText(hDlg, IDC_MAIN, _T(""));
			if (GetMenuState(listMenu, IDM_TYPE_MAIL, MF_BYCOMMAND) == MF_CHECKED) {
				CheckMenuItem(listMenu, IDM_TYPE_MAIL, MF_UNCHECKED);		
				WriteLinkList(hDlg, GetFlags(listMenu), DlgParam->listStart, NULL, 0);				
			} else {
				CheckMenuItem(listMenu, IDM_TYPE_MAIL, MF_CHECKED);
				CheckMenuItem(listMenu, IDM_TYPE_WEB, MF_UNCHECKED);
				WriteLinkList(hDlg, GetFlags(listMenu), DlgParam->listStart, NULL, 0);
			}
			GetFilterText(listMenu, filter, _countof(filter));
			SetDlgItemText(hDlg, IDC_STATUS, filter);
			break;
		}
		} break;
	// Taken from srmm.
	// Btw: The longer I searched the source of this plugin
	// to learn how things work, the more I became a fan of
	// the programmer! 
	case WM_GETMINMAXINFO: {
		MINMAXINFO *mmi = (MINMAXINFO *)lParam;
		RECT rcWindow, rcMain;

		GetWindowRect(hDlg, &rcWindow);
		GetWindowRect(GetDlgItem(hDlg, IDC_MAIN), &rcMain);
		mmi->ptMinTrackSize.x = rcWindow.right - rcWindow.left - ((rcMain.right - rcMain.left) - DlgParam->minSize.cx);
		mmi->ptMinTrackSize.y = rcWindow.bottom - rcWindow.top - ((rcMain.bottom - rcMain.top) - DlgParam->minSize.cy);
		} break;
	case WM_SIZE:
		Utils_ResizeDialog(hDlg, hInst, MAKEINTRESOURCEA(IDD_MAIN_DLG), LinklistResizer, (LPARAM)DlgParam);
		// To get some scrollbars if needed...
		RedrawWindow(GetDlgItem(hDlg, IDC_MAIN), NULL, NULL, RDW_INVALIDATE);
		RedrawWindow(GetDlgItem(hDlg, IDC_MESSAGE), NULL, NULL, RDW_INVALIDATE);
		break;
	
	case DM_LINKSPLITTER: {
		POINT pt;
		RECT rc;
		int splitPosOld;

		GetClientRect(hDlg, &rc);
		pt.x = 0;
		pt.y = wParam;
		ScreenToClient(hDlg, &pt);

		splitPosOld = DlgParam->splitterPosNew;
		DlgParam->splitterPosNew = rc.bottom - pt.y;
			
		GetWindowRect(GetDlgItem(hDlg, IDC_MESSAGE), &rc);
		if (rc.bottom - rc.top + (DlgParam->splitterPosNew - splitPosOld) < 0)
			DlgParam->splitterPosNew = splitPosOld + 0 - (rc.bottom - rc.top);

		GetWindowRect(GetDlgItem(hDlg, IDC_MAIN), &rc);
		if (rc.bottom - rc.top - (DlgParam->splitterPosNew - splitPosOld) < DlgParam->minSize.cy)
			DlgParam->splitterPosNew = splitPosOld - DlgParam->minSize.cy + (rc.bottom - rc.top);
		SendMessage(hDlg, WM_SIZE, 0, 0);
		} break;
	case WM_CLOSE:
		DestroyWindow(hDlg);
		break;
	case WM_DESTROY:
		if (DlgParam != NULL) {
			MCONTACT hContact = ((db_get_b(NULL, LINKLIST_MODULE, LINKLIST_SAVESPECIAL, 0) == 0) ? NULL: DlgParam->hContact);
			Utils_SaveWindowPosition(hDlg, hContact, LINKLIST_MODULE, "Linklist");
			db_set_dw(NULL, LINKLIST_MODULE, LINKLIST_SPLITPOS, DlgParam->splitterPosNew);
			RemoveList(DlgParam->listStart);
			mir_free(DlgParam);
		}
		// Remove entry from Window list
		WindowList_Remove(hWindowList, hDlg);
		break;
	}
	return FALSE;
}
Beispiel #9
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;
}
Beispiel #10
0
void OpenUrl(LPCSTR acc, LPCTSTR mailbox, LPCTSTR url)
{
	extern DWORD itlsSettings;
	if (!ReadCheckbox(0, IDC_AUTHONMAILBOX, (UINT_PTR)TlsGetValue(itlsSettings)) || !OpenUrlWithAuth(acc, mailbox, url))
		Utils_OpenUrlT(url);
}
Beispiel #11
0
static INT_PTR CALLBACK sttEnterStringDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
{
	EnterStringFormParam *params = (EnterStringFormParam *)GetWindowLongPtr(hwndDlg, GWLP_USERDATA);

	switch (msg) {
	case WM_INITDIALOG:
		TranslateDialogDefault(hwndDlg);
		SendMessage(hwndDlg, WM_SETICON, ICON_BIG, (LPARAM)Skin_LoadIcon(SKINICON_OTHER_RENAME, true));
		SendMessage(hwndDlg, WM_SETICON, ICON_SMALL, (LPARAM)Skin_LoadIcon(SKINICON_OTHER_RENAME, false));
		params = (EnterStringFormParam *)lParam;
		SetWindowLongPtr(hwndDlg, GWLP_USERDATA, (LONG_PTR)params);
		SetWindowText(hwndDlg, params->caption);
		{
			RECT rc; GetWindowRect(hwndDlg, &rc);
			switch (params->type) {
			case ESF_PASSWORD:
				params->idcControl = IDC_TXT_PASSWORD;
				params->height = rc.bottom - rc.top;
				break;

			case ESF_MULTILINE:
				params->idcControl = IDC_TXT_MULTILINE;
				params->height = 0;
				rc.bottom += (rc.bottom - rc.top) * 2;
				SetWindowPos(hwndDlg, NULL, 0, 0, rc.right - rc.left, rc.bottom - rc.top, SWP_NOMOVE | SWP_NOREPOSITION);
				break;

			case ESF_COMBO:
				params->idcControl = IDC_TXT_COMBO;
				params->height = rc.bottom - rc.top;
				if (params->szDataPrefix && params->recentCount)
					ComboLoadRecentStrings(hwndDlg, params);
				break;

			case ESF_RICHEDIT:
				params->idcControl = IDC_TXT_RICHEDIT;
				SendDlgItemMessage(hwndDlg, IDC_TXT_RICHEDIT, EM_AUTOURLDETECT, TRUE, 0);
				SendDlgItemMessage(hwndDlg, IDC_TXT_RICHEDIT, EM_SETEVENTMASK, 0, ENM_LINK);
				params->height = 0;
				rc.bottom += (rc.bottom - rc.top) * 2;
				SetWindowPos(hwndDlg, NULL, 0, 0, rc.right - rc.left, rc.bottom - rc.top, SWP_NOMOVE | SWP_NOREPOSITION);
				break;
			}
		}
		ShowWindow(GetDlgItem(hwndDlg, params->idcControl), SW_SHOW);
		if (params->ptszInitVal)
			SetDlgItemText(hwndDlg, params->idcControl, params->ptszInitVal);

		if (params->szDataPrefix)
			Utils_RestoreWindowPosition(hwndDlg, NULL, params->szModuleName, params->szDataPrefix);

		SetTimer(hwndDlg, 1000, 50, NULL);

		if (params->timeout > 0) {
			SetTimer(hwndDlg, 1001, 1000, NULL);
			TCHAR buf[128];
			mir_sntprintf(buf, TranslateT("OK (%d)"), params->timeout);
			SetDlgItemText(hwndDlg, IDOK, buf);
		}

		return TRUE;

	case WM_DESTROY:
		Window_FreeIcon_IcoLib(hwndDlg);
		break;

	case WM_TIMER:
		switch (wParam) {
		case 1000:
			KillTimer(hwndDlg, 1000);
			EnableWindow(GetParent(hwndDlg), TRUE);
			break;

		case 1001:
			TCHAR buf[128];
			mir_sntprintf(buf, TranslateT("OK (%d)"), --params->timeout);
			SetDlgItemText(hwndDlg, IDOK, buf);

			if (params->timeout < 0) {
				KillTimer(hwndDlg, 1001);
				UIEmulateBtnClick(hwndDlg, IDOK);
			}
		}
		return TRUE;

	case WM_SIZE:
		Utils_ResizeDialog(hwndDlg, g_hInst, MAKEINTRESOURCEA(IDD_ENTER_STRING), sttEnterStringResizer);
		break;

	case WM_GETMINMAXINFO:
		{
			LPMINMAXINFO lpmmi = (LPMINMAXINFO)lParam;
			if (params && params->height)
				lpmmi->ptMaxSize.y = lpmmi->ptMaxTrackSize.y = params->height;
		}
		break;

	case WM_NOTIFY:
		{
			ENLINK *param = (ENLINK *)lParam;
			if (param->nmhdr.idFrom != IDC_TXT_RICHEDIT) break;
			if (param->nmhdr.code != EN_LINK) break;
			if (param->msg != WM_LBUTTONUP) break;

			CHARRANGE sel;
			SendMessage(param->nmhdr.hwndFrom, EM_EXGETSEL, 0, (LPARAM)& sel);
			if (sel.cpMin != sel.cpMax) break; // allow link selection

			TEXTRANGE tr;
			tr.chrg = param->chrg;
			tr.lpstrText = (TCHAR *)mir_alloc(sizeof(TCHAR)*(tr.chrg.cpMax - tr.chrg.cpMin + 2));
			SendMessage(param->nmhdr.hwndFrom, EM_GETTEXTRANGE, 0, (LPARAM)&tr);

			Utils_OpenUrlT(tr.lpstrText);
			mir_free(tr.lpstrText);
		}
		return TRUE;

	case WM_COMMAND:
		switch (LOWORD(wParam)) {
		case IDC_TXT_MULTILINE:
		case IDC_TXT_RICHEDIT:
			if ((HIWORD(wParam) != EN_SETFOCUS) && (HIWORD(wParam) != EN_KILLFOCUS)) {
				SetDlgItemText(hwndDlg, IDOK, TranslateT("OK"));
				KillTimer(hwndDlg, 1001);
			}
			break;

		case IDC_TXT_COMBO:
			if ((HIWORD(wParam) != CBN_SETFOCUS) && (HIWORD(wParam) != CBN_KILLFOCUS)) {
				SetDlgItemText(hwndDlg, IDOK, TranslateT("OK"));
				KillTimer(hwndDlg, 1001);
			}
			break;

		case IDCANCEL:
			if (params->szDataPrefix)
				Utils_SaveWindowPosition(hwndDlg, NULL, params->szModuleName, params->szDataPrefix);

			EndDialog(hwndDlg, 0);
			break;

		case IDOK:
			HWND hWnd = GetDlgItem(hwndDlg, params->idcControl);
			int len = GetWindowTextLength(hWnd)+1;
			params->ptszResult = (LPTSTR)mir_alloc(sizeof(TCHAR)*len);
			GetWindowText(hWnd, params->ptszResult, len);

			if ((params->type == ESF_COMBO) && params->szDataPrefix && params->recentCount)
				ComboAddRecentString(hwndDlg, params);
			if (params->szDataPrefix)
				Utils_SaveWindowPosition(hwndDlg, NULL, params->szModuleName, params->szDataPrefix);

			EndDialog(hwndDlg, 1);
			break;
		}
	}

	return FALSE;
}
Beispiel #12
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;
}