Click here to Skip to main content
15,881,691 members
Articles / Desktop Programming / MFC

dotNetInstaller - Setup Bootstrapper for .NET Application

Rate me:
Please Sign up or sign in to vote.
4.96/5 (87 votes)
4 Jan 2004MIT22 min read 1M   2.2K   310  
With this tool the developer can define the application prerequisites and install the correct version of these components in the correct order based on the user operating system type and language, allow the user to download these components from the web or install these components directly.
#pragma once
#include "afxwin.h"
#include "afxcmn.h"

#include "DownloadDialogSupport.h"


namespace DVLib
{
	// DownloadDialog dialog

	class DownloadDialog : public CDialog, public IDownloadCallback
	{
		DECLARE_DYNAMIC(DownloadDialog)

	public:
		DownloadDialog(const DownloadGroupConfiguration & p_Configuration,
							CWnd* pParent = NULL);   // standard constructor

		virtual ~DownloadDialog();

	// Dialog Data
		enum { IDD = IDD_DOWNLOAD_DIALOG };

	private:
		CString m_Caption;
		CString m_HelpMessage;
		CString m_HelpMessageDownloading;
		CString m_ButtonStartCaption;
		CString m_ButtonCancelCaption;
		DownloadComponentInfoVector m_Components;
		bool m_bAutoStartDownload;

		bool m_bCancelDownload;
		HANDLE m_hDownloadThread;
		bool m_bDownloadCompleted;

		HICON m_hIcon;

		//HWND m_HWNDProgressBar;
		//HWND m_HWNDLabelStatus;

	protected:
		virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV support
		virtual BOOL OnInitDialog();
		virtual afx_msg void OnClose();

		virtual void WaitDownloadThread();

		DECLARE_MESSAGE_MAP()
	public:
		CStatic m_LabelHelpDownload;
		CStatic m_LabelStatus;
		CButton m_btStart;
		CButton m_btCancel;
		CProgressCtrl m_ProgressControl;
		afx_msg void OnBnClickedCancel();
		afx_msg void OnBnClickedStart();
		afx_msg void OnCancel();
		afx_msg void OnOK();

		afx_msg LRESULT OnSetStatusDownload(WPARAM wParam, LPARAM lParam);

		inline bool IsDownloadCompleted(){return m_bDownloadCompleted;};

		// IDownloadCallback
		virtual void Status(ULONG p_CurrentProgress, ULONG p_MaxProgress, LPCTSTR p_Description);
		virtual void DownloadComplete();
		virtual void DownloadError(LPCTSTR);
		virtual bool WantToStop();
		virtual void CanceledByTheUser();
		virtual DownloadComponentInfoVector * GetComponents();
	};


	enum StatusType
	{
		StatusType_Error,
		StatusType_Downloading,
		StatusType_Completed,
		StatusType_Canceled
	};

	struct DownloadStatusParam
	{
		StatusType Type;
		ULONG CurrentProgress;
		ULONG ProgressMax;
		CString Status;
		CString Error;

		static DownloadStatusParam * CreateProgress(CString p_Status, ULONG p_CurrentProgress, ULONG p_ProgressMax)
		{
			DownloadStatusParam * param = new DownloadStatusParam();
			param->Type = StatusType_Downloading;
			param->CurrentProgress = p_CurrentProgress;
			param->ProgressMax = p_ProgressMax;
			param->Status = p_Status;
			return param;
		}
		static DownloadStatusParam * CreateComplete()
		{
			DownloadStatusParam * param = new DownloadStatusParam();
			param->Type = StatusType_Completed;
			return param;
		}
		static DownloadStatusParam * CreateError(CString p_Error)
		{
			DownloadStatusParam * param = new DownloadStatusParam();
			param->Type = StatusType_Error;
			param->Error = p_Error;
			return param;
		}
		static DownloadStatusParam * CreateCanceled()
		{
			DownloadStatusParam * param = new DownloadStatusParam();
			param->Type = StatusType_Canceled;
			return param;
		}

		static void Free(DownloadStatusParam * param)
		{
			delete param;
		}
	};

	inline bool RunDownloadDialog(const DVLib::DownloadGroupConfiguration & p_ConfigDownload)
	{
		DVLib::DownloadDialog l_dgDownload(p_ConfigDownload);
		l_dgDownload.DoModal();

		return l_dgDownload.IsDownloadCompleted();
	}
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The MIT License


Written By
Software Developer
Italy Italy
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions