//this file is part of eMule
//Copyright (C)2002 Merkur ( merkur-@users.sourceforge.net / http://www.emule-project.net )
//
//This program is free software; you can redistribute it and/or
//modify it under the terms of the GNU General Public License
//as published by the Free Software Foundation; either
//version 2 of the License, or (at your option) any later version.
//
//This program is distributed in the hope that it will be useful,
//but WITHOUT ANY WARRANTY; without even the implied warranty of
//MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
//GNU General Public License for more details.
//
//You should have received a copy of the GNU General Public License
//along with this program; if not, write to the Free Software
//Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.


#pragma once
#include "searchlistctrl.h"
#include "afxcmn.h"
#include "packets.h"
#include "types.h"
#include "afxwin.h"
#include "iconstatic.h"
#include "closabletabctrl.h"

// CSearchDlg dialog
class CSearchDlg : public CResizableDialog
{
	DECLARE_DYNAMIC(CSearchDlg)

public:
	CSearchDlg(CWnd* pParent = NULL);   // standard constructor
	virtual ~CSearchDlg();
	
	afx_msg void OnBnClickedStarts();
	afx_msg void OnTimer(UINT nIDEvent);
	afx_msg void OnBnClickedCancels();
	afx_msg void OnBnClickedSdownload();
	afx_msg void OnBnClickedClearall();
	enum { IDD = IDD_SEARCH };

	void	Localize();
	void	DownloadSelected();
	void	LocalSearchEnd(uint16 count);
	void	AddUDPResult(uint16 count);
	void	DeleteSearch(uint32 nSearchID);
	void	DeleteAllSearchs();
	void	CreateNewTab(CString searchString,uint32 nSearchID);
	CSearchListCtrl searchlistctrl;
	CClosableTabCtrl searchselect;

protected:
	void StartNewSearch();
	LRESULT OnCloseTab(WPARAM wparam, LPARAM lparam);
	CString	CreateWebQuery();

	virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV support
	virtual BOOL OnInitDialog();
	virtual BOOL PreTranslateMessage(MSG* pMsg);
	afx_msg void OnNMDblclkSearchlist(NMHDR *pNMHDR, LRESULT *pResult);
	afx_msg void OnTcnSelchangeTab1(NMHDR *pNMHDR, LRESULT *pResult);
	afx_msg void OnEnChangeSearchname();

	DECLARE_MESSAGE_MAP()

private:

	Packet*		searchpacket;		
	UINT_PTR	global_search_timer;
	CProgressCtrl searchprogress;
	bool		canceld;
	uint16		servercount;
	bool		globsearch;
	uint32		m_nSearchID;
	CComboBox	typebox;
	CComboBox	Stypebox;
	CImageList	m_ImageList;

	CIconStatic m_ctrlSearchFrm;
	CIconStatic m_ctrlWebSearchFrm;
	CIconStatic m_ctrlDirectDlFrm;
public:
	afx_msg void OnBnClickedSearchReset();
	afx_msg void OnBnClickedFakecheck();
};
