コード例 #1
0
LRESULT PublicHubsFrame::onCopyHub(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/)
{
	if (m_ctrlHubs.GetSelectedCount() == 1)
	{
		LocalArray<TCHAR, 256> buf;
		int i = m_ctrlHubs.GetNextItem(-1, LVNI_SELECTED);
		m_ctrlHubs.GetItemText(i, COLUMN_SERVER, buf.data(), 256);
		WinUtil::setClipboard(buf.data());
	}
	return 0;
}
コード例 #2
0
LRESULT FlyUpdateDlg::OnLink(int /*idCtrl*/, LPNMHDR pnmh, BOOL& bHandled)
{
	const ENLINK* pL = (const ENLINK*)pnmh;
	if (WM_LBUTTONDOWN == pL->msg)
	{
		LocalArray<TCHAR, MAX_PATH> buf;
		CRichEditCtrl(pL->nmhdr.hwndFrom).GetTextRange(pL->chrg.cpMin, pL->chrg.cpMax, buf.data());
		WinUtil::openFile(buf.data());
	}
	else
		bHandled = FALSE;
	return 0;
}
コード例 #3
0
UINT_PTR CALLBACK MenuBarCommDlgProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{

	if (uMsg == WM_COMMAND)
	{
		if (HIWORD(wParam) == EN_CHANGE &&
		        (LOWORD(wParam) == CTLID_VALUE_RED || LOWORD(wParam) == CTLID_VALUE_GREEN || LOWORD(wParam) == CTLID_VALUE_BLUE))
		{
			LocalArray<TCHAR, 16> buf;
			buf[0] = 0;
			::GetDlgItemText(hWnd, CTLID_VALUE_RED, buf.data(), 15);
			int color_r = Util::toInt(buf.data());
			buf[0] = 0;
			::GetDlgItemText(hWnd, CTLID_VALUE_BLUE, buf.data(), 15);
			int color_g = Util::toInt(buf.data());
			buf[0] = 0;
			::GetDlgItemText(hWnd, CTLID_VALUE_GREEN, buf.data(), 15);
			int color_b = Util::toInt(buf.data());
			
			color_r = (color_r < 0) ? 0 : ((color_r > 255) ? 255 : color_r);
			color_g = (color_g < 0) ? 0 : ((color_g > 255) ? 255 : color_g);
			color_b = (color_b < 0) ? 0 : ((color_b > 255) ? 255 : color_b);
			
			if (current_page->bDoProgress)
			{
				if (current_page->bDoLeft)
				{
					current_page->crProgressDown = RGB(color_r, color_g, color_b);
					current_page->ctrlProgressDownDrawer.Invalidate();
				}
				else if (current_page->bDoSegment)
				{
					current_page->crProgressSegment = RGB(color_r, color_g, color_b);
				}
				else
				{
					current_page->crProgressUp = RGB(color_r, color_g, color_b);
					current_page->ctrlProgressUpDrawer.Invalidate();
				}
			}
			else
			{
				if (current_page->bDoLeft)
					current_page->crMenubarLeft = RGB(color_r, color_g, color_b);
				else
					current_page->crMenubarRight = RGB(color_r, color_g, color_b);
				current_page->ctrlMenubarDrawer.Invalidate();
			}
		}
	}
	
	return (*color_proc)(hWnd, uMsg, wParam, lParam);
	
}
コード例 #4
0
LRESULT WaitingUsersFrame::onCustomDraw(int /*idCtrl*/, LPNMHDR pnmh, BOOL& bHandled)
{
	/*  [-] IRainman
	if (!BOOLSETTING(SHOW_PROGRESS_BARS))
	{
	    bHandled = FALSE;
	    return 0;
	}
	*/
	CRect rc;
	LPNMLVCUSTOMDRAW cd = reinterpret_cast<LPNMLVCUSTOMDRAW>(pnmh);
	UploadQueueItem *ii = (UploadQueueItem*)cd->nmcd.lItemlParam; // ??
	
	switch (cd->nmcd.dwDrawStage)
	{
		case CDDS_PREPAINT:
			return CDRF_NOTIFYITEMDRAW;
		case CDDS_ITEMPREPAINT:
#ifdef FLYLINKDC_USE_LIST_VIEW_MATTRESS
			Colors::alternationBkColor(cd); // [+] IRainman
#endif
			return CDRF_NOTIFYSUBITEMDRAW;
			
		case CDDS_SUBITEM | CDDS_ITEMPREPAINT:
		{
			// Let's draw a box if needed...
			if (BOOLSETTING(SHOW_PROGRESS_BARS) && m_ctrlList.findColumn(cd->iSubItem) == UploadQueueItem::COLUMN_TRANSFERRED) // [+] IRainman
			{
				// draw something nice...
				LocalArray<TCHAR, 256> buf;
				m_ctrlList.GetItemText((int)cd->nmcd.dwItemSpec, cd->iSubItem, buf.data(), 255);
				m_ctrlList.GetSubItemRect((int)cd->nmcd.dwItemSpec, cd->iSubItem, LVIR_BOUNDS, rc);
				// Real rc, the original one.
				CRect real_rc = rc;
				// We need to offset the current rc to (0, 0) to paint on the New dc
				rc.MoveToXY(0, 0);
				
				// Text rect
				CRect rc2 = rc;
				rc2.left += 6; // indented with 6 pixels
				rc2.right -= 2; // and without messing with the border of the cell
				
				// Set references
				CDC cdc;
				cdc.CreateCompatibleDC(cd->nmcd.hdc);
				HBITMAP hBmp = CreateCompatibleBitmap(cd->nmcd.hdc,  real_rc.Width(),  real_rc.Height());
				HBITMAP pOldBmp = cdc.SelectBitmap(hBmp);
				HDC& dc = cdc.m_hDC;
				
				HFONT oldFont = (HFONT)SelectObject(dc, Fonts::g_font);
				SetBkMode(dc, TRANSPARENT);
				
				CBarShader statusBar(rc.bottom - rc.top, rc.right - rc.left, RGB(150, 0, 0), ii->getSize());
				statusBar.FillRange(0, ii->getPos(), RGB(222, 160, 0));
				statusBar.Draw(cdc, rc.top, rc.left, SETTING(PROGRESS_3DDEPTH));
				
				SetTextColor(dc, SETTING(PROGRESS_TEXT_COLOR_UP));
				::ExtTextOut(dc, rc2.left, rc2.top + (rc2.Height() - WinUtil::getTextHeight(dc) - 1) / 2, ETO_CLIPPED, rc2, buf.data(), _tcslen(buf.data()), NULL);
				
				SelectObject(dc, oldFont);
				
				BitBlt(cd->nmcd.hdc, real_rc.left, real_rc.top, real_rc.Width(), real_rc.Height(), dc, 0, 0, SRCCOPY);
				
				DeleteObject(cdc.SelectBitmap(pOldBmp));
				return CDRF_SKIPDEFAULT;
			}
			
			// [!] Colors::getUserColor(ii->getUser(), cd->clrText, cd->clrTextBk); // [!] IRainman fix todo [1] https://www.box.net/shared/f7c509838c3a1125842b , https://crash-server.com/DumpGroup.aspx?ClientID=guest&DumpGroupID=59082
			// !SMT!-IP
			if (m_ctrlList.findColumn(cd->iSubItem) == UploadQueueItem::COLUMN_LOCATION)
			{
				const tstring l_text = ii->getText(UploadQueueItem::COLUMN_LOCATION);
				if (l_text.length() != 0)
				{
					m_ctrlList.GetSubItemRect((int)cd->nmcd.dwItemSpec, cd->iSubItem, LVIR_BOUNDS, rc);
					CRect rc2 = rc;
					m_ctrlList.SetItemFilled(cd, rc2, cd->clrText);
					LONG top = rc2.top + (rc2.Height() - 15) / 2;
					if ((top - rc2.top) < 2)
						top = rc2.top + 1;
						
					const POINT p = { rc2.left, top };
					if (ii->m_location.isKnown())
					{
						g_flagImage.DrawLocation(cd->nmcd.hdc, ii->m_location, p);
					}
					top = rc2.top + (rc2.Height() - 15 /*WinUtil::getTextHeight(cd->nmcd.hdc)*/ - 1) / 2;
					if (!l_text.empty())
					{
						::ExtTextOut(cd->nmcd.hdc, rc2.left + 30, top + 1, ETO_CLIPPED, rc2, l_text.c_str(), l_text.length(), NULL);
					}
					return CDRF_SKIPDEFAULT;
				}
			}
		} //[+]PPA
		// Fall through
		default:
			return CDRF_DODEFAULT;
	}
}
コード例 #5
0
ファイル: SpyFrame.cpp プロジェクト: craxycat/flylinkdc-r5xx
LRESULT SpyFrame::onSpeaker(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/)
{
	TaskQueue::List t;
	m_tasks.get(t);
	
	if (t.empty())
		return 0;
		
	CFlyBusyBool l_busy(m_spoken);
	CLockRedraw<> lockCtrlList(ctrlSearches);
	for (auto i = t.cbegin(); i != t.cend(); ++i)
	{
		switch (i->first)
		{
			case SEARCH:
			{
				SMTSearchInfo* si = (SMTSearchInfo*)i->second;
				//[+]IRainman refactoring SpyFrame
				if (m_needsUpdateTime)
				{
					m_CurrentTime = Text::toT(Util::formatDigitalClock(GET_TIME()));
					m_needsUpdateTime = false;
				}
				//[~]IRainman refactoring SpyFrame
				tstring l_SeekersNames;
				{
					auto& l_searh_item = m_spy_searches[si->s];
					if (m_showNick)// [+] IRainman
					{
						if (::strncmp(si->seeker.c_str(), "Hub:", 4))
						{
							const string::size_type l_twopt = si->seeker.find(':');
							if (l_twopt != string::npos)
							{
								const string l_ip = si->seeker.substr(0, l_twopt);
								const StringList l_users = ClientManager::getUserByIp(l_ip);
								if (!l_users.empty())
								{
									si->seeker = "[IP:" + l_ip + "] Users:" + Util::toString(l_users);
								}
							}
						}
					}
					if (m_log && m_LogFile)
					{
						m_log_txt += Text::fromT(m_CurrentTime) + "\t" +
						             si->seeker + "\t" +
						             si->s + "\r\n";
					}
					if (m_showNick)// [+] IRainman
					{
						size_t k;
						for (k = 0; k < NUM_SEEKERS; ++k)
							if (si->seeker == l_searh_item.m_seekers[k])
								break;          //that user's searching for file already noted
								
						if (k == NUM_SEEKERS)           //loop terminated normally
							l_searh_item.AddSeeker(si->seeker);
							
						for (k = 0; k < NUM_SEEKERS; ++k)
							l_SeekersNames += Text::toT(l_searh_item.m_seekers[k]) + _T("  ");
					}
					
					++m_total;
					++m_perSecond[m_current];
				}
				// !SMT!-S
				tstring hit;
				if (si->re == ClientManagerListener::SEARCH_PARTIAL_HIT)
					hit = _T('*');
				else if (si->re == ClientManagerListener::SEARCH_HIT)
					hit = _T('+');
					
				tstring l_search;
				l_search = Text::toT(si->s, l_search);
				const int j = ctrlSearches.find(l_search);
				if (j == -1)
				{
					TStringList a;
					a.reserve(5);
					a.push_back(l_search);
					a.push_back(_T("1"));
					a.push_back(l_SeekersNames);
					a.push_back(m_CurrentTime);
					a.push_back(hit);
					ctrlSearches.insert(a, 0, si->re);// !SMT!-S
					int l_Count = ctrlSearches.GetItemCount();
					if (l_Count > 500)
					{
						ctrlSearches.DeleteItem(--l_Count);
					}
				}
				else
				{
					TCHAR tmp[32];
					tmp[0] = 0;
					ctrlSearches.GetItemText(j, COLUMN_COUNT, tmp, 32);
					ctrlSearches.SetItemText(j, COLUMN_COUNT, Util::toStringW(Util::toInt(tmp) + 1).c_str());
					ctrlSearches.SetItemText(j, COLUMN_USERS, l_SeekersNames.c_str());
					ctrlSearches.SetItemText(j, COLUMN_TIME, m_CurrentTime.c_str());
					ctrlSearches.SetItemText(j, COLUMN_SHARE_HIT, hit.c_str()); // !SMT!-S
					ctrlSearches.SetItem(j, COLUMN_SHARE_HIT, LVIF_PARAM, NULL, 0, 0, 0, si->re); // !SMT!-S
					if (ctrlSearches.getSortColumn() == COLUMN_COUNT ||
					        ctrlSearches.getSortColumn() == COLUMN_TIME
					   )
						m_needsResort = true;
				}
				if (BOOLSETTING(BOLD_SEARCH))
				{
					setDirty(0);
				}
#ifdef FLYLINKDC_USE_SOUND_AND_POPUP_IN_SEARCH_SPY
				SHOW_POPUP(POPUP_SEARCH_SPY, m_CurrentTime + _T(" : ") + l_SeekersNames + _T("\r\n") + l_search, TSTRING(SEARCH_SPY)); // [+] SCALOlaz: Spy Popup. Thanks to tret2003 (NightOrion) with tstring
				PLAY_SOUND(SOUND_SEARCHSPY);
#endif
			}
			break;
			case TICK_AVG:
			{
				auto s = (Stats*)i->second;
				LocalArray<TCHAR, 50> buf;
				_snwprintf(buf.data(), buf.size(), CTSTRING(SEARCHES_PER), s->m_perS, s->m_perM);
				ctrlStatus.SetText(2, (TSTRING(TOTAL) + _T(' ') + Util::toStringW(m_total)).c_str());
				ctrlStatus.SetText(3, buf.data());
				ctrlStatus.SetText(4, (TSTRING(HITS) + _T(' ') + Util::toStringW((size_t)(ShareManager::getHits()))).c_str());
				const double ratio = m_total > 0 ? static_cast<double>(ShareManager::getHits()) / static_cast<double>(m_total) : 0.0;
				ctrlStatus.SetText(5, (TSTRING(HIT_RATIO) + _T(' ') + Util::toStringW(ratio)).c_str());
				if (m_needsResort)
				{
					m_needsResort = false;
					ctrlSearches.resort();
				}
			}
			break;
			case SAVE_LOG:
				if (m_log)
				{
					try
					{
						m_log->setEndPos(0);
						m_log->write(m_log_txt);
					}
					catch (const FileException& e)
					{
						LogManager::message("Error write file spylog.log error = " + e.getError());
					}
					m_log_txt.clear();
				}
				break;
		}
		delete i->second;
	}
	return 0;
}