#include "pch.h"
#include "framework.h"
#include "GenericBkMFC.h"
#include "GenericBkMFCDlg.h"
#include "afxdialogex.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#endif

#define IDS_MAILADDR	_T("mailto:info@softechsoftware.it")
#define IDS_WEBADDR		_T("http://www.softechsoftware.it")
#define	IDS_ICONSADDR	_T("http://www.softechsoftware.it/iconsdll.html")

#ifdef	_WIN64
#define	ICONS_FILENAME		_T("Icons64.dll")
#else
#define	ICONS_FILENAME		_T("Icons.dll")
#endif
#define	ICONS_REQVER_MAJOR	4
#define	ICONS_REQVER_MINOR	0
#define	ICONS_REQVER_BUILD	1
#define	ICONS_REQVER_QFE	0

CGenericBkMFCDlg::CGenericBkMFCDlg(CWnd* pParent /*=nullptr*/)
	: CBkResizableDialogST(IDD_GENERICBKMFC_DIALOG, pParent)
{
	m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
}

void CGenericBkMFCDlg::DoDataExchange(CDataExchange* pDX)
{
	CBkResizableDialogST::DoDataExchange(pDX);

	DDX_Control(pDX, IDOK, m_btnExit);
	DDX_Control(pDX, IDC_BTNFULLSCREEN, m_btnFullScreen);
	DDX_Control(pDX, IDC_STCTITLE, m_stcTitle);
	DDX_Control(pDX, IDC_LBXST, m_lbxListBox);

	DDX_Control(pDX, IDC_EMAILLINK, m_EMailLink);
	DDX_Control(pDX, IDC_HOMEPAGELINK, m_HomePageLink);
}

BEGIN_MESSAGE_MAP(CGenericBkMFCDlg, CBkResizableDialogST)
	ON_WM_PAINT()
	ON_WM_QUERYDRAGICON()
	ON_WM_SIZE()

	ON_MESSAGE(WM_USER + 150, On_PageActivationCallback)
	ON_LBN_SELCHANGE(IDC_LBXST, &CGenericBkMFCDlg::OnSelChangeLbxST)
	ON_BN_CLICKED(IDC_BTNFULLSCREEN, &CGenericBkMFCDlg::OnBnClickedBtnfullscreen)
END_MESSAGE_MAP()

BOOL CGenericBkMFCDlg::OnInitDialog()
{
	BOOL	bIconsFound = TRUE;
	DWORD	dwIconsDLLresult = 0;
	CString	sIconsReqVer;

	CBkResizableDialogST::OnInitDialog();

	// Set the icon for this dialog.  The framework does this automatically
	//  when the application's main window is not a dialog
	SetIcon(m_hIcon, TRUE);			// Set big icon
	SetIcon(m_hIcon, FALSE);		// Set small icon

	// Registry home
	m_Registry.SetKeys(HKEY_CURRENT_USER, _T("Software\\SoftechSoftware\\SoftechSoftware_Demo"));

	sIconsReqVer.Format(_T("%d.%d.%d.%d"), ICONS_REQVER_MAJOR, ICONS_REQVER_MINOR, ICONS_REQVER_BUILD, ICONS_REQVER_QFE);

	dwIconsDLLresult = LoadIconsDLL(&m_IconsDLL, sIconsReqVer);
	switch (dwIconsDLLresult)
	{
		case 0:
			break;
		case 1:
			if (NotifyIconsNotFound(sIconsReqVer) == TRUE)
			{
				PostQuitMessage(0);
				return TRUE;
			} // if
			break;
		case 2:
			if (NotifyIconsVersionMismatch(sIconsReqVer) == TRUE)
			{
				PostQuitMessage(0);
				return TRUE;
			} // if
			break;
	} // if

	//ShowSizeGrip(FALSE);
	//SetBitmap(m_IconsDLL.LoadBitmap(DLL_IDB_BACKGROUND01, LR_SHARED));
	//ActivateEasyMoveMode(TRUE);

	// Set HyperLink for E-Mail
	m_EMailLink.SetURL(IDS_MAILADDR);
	m_EMailLink.SetUnderline(CHyperLink::ulAlways);
	m_EMailLink.DrawTransparent(FALSE);

	// Set HyperLink for Home Page
	m_HomePageLink.SetURL(IDS_WEBADDR);
	m_HomePageLink.SetUnderline(CHyperLink::ulAlways);
	m_HomePageLink.DrawTransparent(FALSE);

	// Button exit
	m_btnExit.SetThemeHelper(&m_Theme);
	m_btnExit.SetIcon(m_IconsDLL.LoadIcon(DLL_IDI_SET03_CANCEL, 32, 32));
	m_btnExit.SetTooltipText(_T("Close the application"));

	// Button full screen
	m_btnFullScreen.SetThemeHelper(&m_Theme);
	m_btnFullScreen.SetIcon(m_IconsDLL.LoadIcon(DLL_IDI_GENERAL_FULLSCREEN03, 32, 32));
	m_btnFullScreen.SetTooltipText(_T("Switch to full screen"));
	//m_btnFullScreen.DrawAsToolbar(TRUE);

	if (m_Theme.IsAppThemed() == FALSE)
	{
		m_btnExit.DrawTransparent();
		m_btnFullScreen.DrawTransparent();
	} // if

	// Create font
	m_fntFont.CreateFont(-14, 0, 0, 0, FW_BOLD, FALSE, FALSE, 0, 0, 0, 0, ANTIALIASED_QUALITY, 0, _T("Verdana"));

	// Title
	m_stcTitle.SetFont(&m_fntFont, FALSE);
	m_stcTitle.SetColors(::GetSysColor(COLOR_HIGHLIGHTTEXT), ::GetSysColor(COLOR_HIGHLIGHT), FALSE);

	CreateImageList();
	BOOL bRetValue = CreatePages();
	if (bRetValue == FALSE) MessageBox(_T("Failed creating pages!"));

	// Preset layout
	AddAnchor(m_btnExit.m_hWnd, BOTTOM_RIGHT);
	AddAnchor(m_btnFullScreen.m_hWnd, TOP_RIGHT);
	AddAnchor(m_EMailLink.m_hWnd, BOTTOM_LEFT);
	AddAnchor(m_HomePageLink.m_hWnd, BOTTOM_LEFT);
	AddAnchor(m_lbxListBox.m_hWnd, TOP_LEFT, BOTTOM_LEFT);
	AddAnchor(m_stcTitle.m_hWnd, TOP_LEFT, TOP_RIGHT);
	AddAnchor(IDC_STCPLACEHOLDER, MIDDLE_CENTER);

	// Activate first page
	m_lbxListBox.SetCurSel(0);
	m_Pages.ActivatePage(0);

	return TRUE;
} // End of OnInitDialog

void CGenericBkMFCDlg::OnCancel()
{
	if (m_FullScreen.IsFullScreen())
	{
		OnBnClickedBtnfullscreen();
	} // if
	else
	{
		CBkResizableDialogST::OnCancel();
	} // else
} // End of OnCancel

void CGenericBkMFCDlg::OnSize(UINT nType, int cx, int cy)
{
	CResizableDialog::OnSize(nType, cx, cy);

	ResizeCurrentPage();
} // End of OnSize

void CGenericBkMFCDlg::OnPostEraseBkgnd(CDC* pDC)
{
	if (m_Theme.IsAppThemed() == FALSE)
	{
		m_btnExit.SetBk(pDC);
		m_btnFullScreen.SetBk(pDC);
	} // if

	m_EMailLink.SetBk(pDC);
	m_HomePageLink.SetBk(pDC);
} // End of OnPostEraseBkgnd

//	Return values:
//	0	= DLL loaded successfully
//	1	= DLL not found
//	2	= DLL version mismatch
//
DWORD CGenericBkMFCDlg::LoadIconsDLL(CResourceServerST* pIconsDLL, LPCTSTR lpszReqVersion)
{
	TCHAR	szFilename[_MAX_PATH];
	TCHAR	szDrive[_MAX_PATH];
	TCHAR	szDir[_MAX_PATH];
	TCHAR	szPathToDLL[_MAX_PATH];
	DWORD	dwRetValue = 0;
	DWORD	dwRetValueFunc = 0;

	::GetModuleFileName(NULL, szFilename, _MAX_PATH);

	// Split path into components
	_tsplitpath_s(szFilename, szDrive, _MAX_PATH, szDir, _MAX_PATH, NULL, 0, NULL, 0);

	// Full path to DLL
	_stprintf_s(szPathToDLL, _MAX_PATH, _T("%s%s%s"), szDrive, szDir, ICONS_FILENAME);

	CFileVersionInfo fvi;
	TCHAR szVer[256] = { 0 };

	if (fvi.Open(szPathToDLL))
	{
		if (fvi.GetFileVersionMajor() < ICONS_REQVER_MAJOR)	return 2;
		if (fvi.GetFileVersionMinor() < ICONS_REQVER_MINOR)	return 2;
		if (fvi.GetFileVersionBuild() < ICONS_REQVER_BUILD)	return 2;
		if (fvi.GetFileVersionQFE() < ICONS_REQVER_QFE)		return 2;
	} // if

	if (pIconsDLL)
	{
		//AfxMessageBox(szPathToDLL);

		dwRetValue = pIconsDLL->Load(szPathToDLL);
		if (dwRetValue != RESSRVST_OK)
		{
			dwRetValueFunc = 1;
		} // if
	} // if

	return dwRetValueFunc;
} // End of LoadIconsDLL

//	Return values:
//	TRUE	= Open download link
//	FALSE	= Continue without icons
//
BOOL CGenericBkMFCDlg::NotifyIconsNotFound(LPCTSTR lpszReqVersion)
{
	CHyperLink	hlWeb;
	CString		sMessage;
	BOOL		bRetValue = FALSE;
	int			nRetValue = 0;

	sMessage = ICONS_FILENAME;
	sMessage += _T(" not found.\r\n");
	sMessage +=	_T("The application requires this DLL version ");
	sMessage +=	lpszReqVersion;
	sMessage +=	_T("\r\n\r\n");
	sMessage +=	_T("This DLL is required by the application but is not ");
	sMessage +=	_T("essential to properly work.\r\n");
	sMessage +=	_T("Do you want to download the DLL ?\r\n\r\n");
	sMessage +=	_T("Press 'Yes' to go to download page on SoftechSoftware site.\r\n");
	sMessage +=	_T("Press 'No' to continue without icons and bitmaps.\r\n");

	nRetValue = MessageBox(	sMessage,
							_T("SoftechSoftware"),
							MB_ICONQUESTION | MB_YESNO);
	if (nRetValue == IDYES)
	{
		hlWeb.GotoURL(IDS_ICONSADDR, SW_SHOW);
		bRetValue = TRUE;
	} // if

	return bRetValue;
} // End of NotifyIconsNotFound

//	Return values:
//	TRUE	= Open download link
//	FALSE	= Continue with found DLL
//
BOOL CGenericBkMFCDlg::NotifyIconsVersionMismatch(LPCTSTR lpszReqVersion)
{
	CHyperLink	hlWeb;
	CString		sMessage;
	BOOL		bRetValue = FALSE;
	int			nRetValue = 0;

	sMessage = _T("This application requires ");
	sMessage += ICONS_FILENAME;
	sMessage += _T(" version ");
	sMessage +=	lpszReqVersion;
	sMessage +=	_T("\r\n\r\n");
	sMessage +=	_T("A different version has been found installed with this application.\r\n");
	sMessage +=	_T("Do you want to download the correct version ?\r\n\r\n");
	sMessage +=	_T("Press 'Yes' to go to download page on SoftechSoftware site.\r\n");
	sMessage +=	_T("Press 'No' to continue with the installed version.\r\n");

	nRetValue = MessageBox(	sMessage,
							_T("SoftechSoftware"),
							MB_ICONQUESTION | MB_YESNO);
	if (nRetValue == IDYES)
	{
		hlWeb.GotoURL(IDS_ICONSADDR, SW_SHOW);
		bRetValue = TRUE;
	} // if

	return bRetValue;
} // End of NotifyIconsVersionMismatch

// If you add a minimize button to your dialog, you will need the code below
//  to draw the icon.  For MFC applications using the document/view model,
//  this is automatically done for you by the framework.

void CGenericBkMFCDlg::OnPaint()
{
	if (IsIconic())
	{
		CPaintDC dc(this); // device context for painting

		SendMessage(WM_ICONERASEBKGND, reinterpret_cast<WPARAM>(dc.GetSafeHdc()), 0);

		// Center icon in client rectangle
		int cxIcon = GetSystemMetrics(SM_CXICON);
		int cyIcon = GetSystemMetrics(SM_CYICON);
		CRect rect;
		GetClientRect(&rect);
		int x = (rect.Width() - cxIcon + 1) / 2;
		int y = (rect.Height() - cyIcon + 1) / 2;

		// Draw the icon
		dc.DrawIcon(x, y, m_hIcon);
	}
	else
	{
		CBkResizableDialogST::OnPaint();
	}
}

// The system calls this function to obtain the cursor to display while the user drags
//  the minimized window.
HCURSOR CGenericBkMFCDlg::OnQueryDragIcon()
{
	return static_cast<HCURSOR>(m_hIcon);
}

LRESULT CGenericBkMFCDlg::On_PageActivationCallback(WPARAM wParam, LPARAM lParam)
{
	CString	sPageTitle;

	if (lParam)
	{
		m_Pages.GetPageTitle((DWORD)wParam, sPageTitle);
		m_stcTitle.SetWindowText(sPageTitle);
		//sPageTitle += _T(" - SoftechSoftware");
		SetWindowText(sPageTitle);

		m_stcTitle.Invalidate();
	} // if

	return 0;
} // End of On_PageActivationCallback

void CGenericBkMFCDlg::CreateImageList()
{
	BOOL	bRetValue = FALSE;
	HICON	hIcon = NULL;

	// Create image list
	bRetValue = m_ImageList.Create(16, 16, ILC_COLOR32 | ILC_MASK, 25, 1);
	ASSERT(bRetValue == TRUE);

	// Add some icons
	m_ImageList.Add(m_IconsDLL.LoadIcon(DLL_IDI_SET03_ABOUT, 16, 16));
	m_ImageList.Add(m_IconsDLL.LoadIcon(DLL_IDI_SET03_STAR, 16, 16));
	m_ImageList.Add(m_IconsDLL.LoadIcon(DLL_IDI_SET03_ADD, 16, 16));
	m_ImageList.Add(m_IconsDLL.LoadIcon(DLL_IDI_GENERAL_WINDOW02, 16, 16));
	m_ImageList.Add(m_IconsDLL.LoadIcon(DLL_IDI_GENERAL_USER01, 16, 16));
	m_ImageList.Add(m_IconsDLL.LoadIcon(DLL_IDI_GENERAL_KEYBOARD02, 16, 16));
	m_ImageList.Add(m_IconsDLL.LoadIcon(DLL_IDI_GENERAL_MISC02, 16, 16));
	m_ImageList.Add(m_IconsDLL.LoadIcon(DLL_IDI_GENERAL_MISC05, 16, 16));
	m_ImageList.Add(m_IconsDLL.LoadIcon(DLL_IDI_GENERAL_MISC04, 16, 16));
	m_ImageList.Add(m_IconsDLL.LoadIcon(DLL_IDI_GENERAL_MISC04, 16, 16));
	m_ImageList.Add(m_IconsDLL.LoadIcon(DLL_IDI_GENERAL_MISC04, 16, 16));
	m_ImageList.Add(m_IconsDLL.LoadIcon(DLL_IDI_GENERAL_MISC04, 16, 16));
	m_ImageList.Add(m_IconsDLL.LoadIcon(DLL_IDI_GENERAL_TIME04, 16, 16));
	m_ImageList.Add(m_IconsDLL.LoadIcon(DLL_IDI_GENERAL_FOLDER01, 16, 16));
	m_ImageList.Add(m_IconsDLL.LoadIcon(DLL_IDI_GENERAL_WAIT01, 16, 16));
	m_ImageList.Add(m_IconsDLL.LoadIcon(DLL_IDI_GENERAL_WINDOW03, 16, 16));
	m_ImageList.Add(m_IconsDLL.LoadIcon(DLL_IDI_GENERAL_WINDOW03, 16, 16));
	m_ImageList.Add(m_IconsDLL.LoadIcon(DLL_IDI_GENERAL_WINDOW03, 16, 16));
	m_ImageList.Add(m_IconsDLL.LoadIcon(DLL_IDI_GENERAL_SETTINGS11, 16, 16));
} // End of CreateImageList

BOOL CGenericBkMFCDlg::CreatePages()
{
	DWORD	dwRetValue = 0;

	// Associate image list to list box
	m_lbxListBox.SetImageList(&m_ImageList);

	m_lbxListBox.AddString(_T("About"), 0);
	m_lbxListBox.AddString(_T("Basic"), 1);
	m_lbxListBox.AddString(_T("Advanced"), 2);
	m_lbxListBox.AddString(_T("Transparent"), 3);
	m_lbxListBox.AddString(_T("CShadeButtonST"), 4);
	m_lbxListBox.AddString(_T("CKeyboardButtonST"), 5);
	m_lbxListBox.AddString(_T("CXPStyleButtonST"), 6);
	m_lbxListBox.AddString(_T("CLifeCakeButtonST"), 7);
	m_lbxListBox.AddString(_T("CWinXPButtonST"), 8);
	m_lbxListBox.AddString(_T("CBlendedButtonST"), 9);
	m_lbxListBox.AddString(_T("CStaticST"), 10);
	m_lbxListBox.AddString(_T("CBlendedStaticST"), 11);
	m_lbxListBox.AddString(_T("CCloskST"), 12);
	m_lbxListBox.AddString(_T("CFileDialogST"), 13);
	m_lbxListBox.AddString(_T("CProgressCtrlST"), 14);
	m_lbxListBox.AddString(_T("CListBoxST"), 15);
	m_lbxListBox.AddString(_T("CListBoxColorPickerST"), 16);
	m_lbxListBox.AddString(_T("CLayeredWindowHelperST"), 17);
	m_lbxListBox.AddString(_T("CDigitST"), 18);

	dwRetValue = m_Pages.CreateFromStatic(IDC_STCPLACEHOLDER, this);
	if (dwRetValue != PAGEMANAGERST_OK)	return FALSE;

	m_Pages.SetPageActivationCallback(m_hWnd, WM_USER + 150);

	dwRetValue = m_Pages.AddPage(new CDlgAbout(), CDlgAbout::IDD, _T("About SoftechSoftware"), 0);
	if (dwRetValue != PAGEMANAGERST_OK)	return FALSE;
	//
	dwRetValue = m_Pages.AddPage(new CDlgBasic(NULL, &m_IconsDLL), CDlgBasic::IDD, _T("CButtonST basic features"), 1);
	if (dwRetValue != PAGEMANAGERST_OK)	return FALSE;
	//
	dwRetValue = m_Pages.AddPage(new CDlgAdvanced(NULL, &m_IconsDLL), CDlgAdvanced::IDD, _T("CButtonST advanced features"), 2);
	if (dwRetValue != PAGEMANAGERST_OK)	return FALSE;
	//
	dwRetValue = m_Pages.AddPage(new CDlgTransparent(NULL, &m_IconsDLL), CDlgTransparent::IDD, _T("CButtonST transparent features"), 3);
	if (dwRetValue != PAGEMANAGERST_OK)	return FALSE;
	//
	dwRetValue = m_Pages.AddPage(new CDlgShadeButtonST(NULL, &m_IconsDLL), CDlgShadeButtonST::IDD, _T("CShadeButtonST"), 4);
	if (dwRetValue != PAGEMANAGERST_OK)	return FALSE;
	//
	dwRetValue = m_Pages.AddPage(new CDlgDerived(NULL, &m_IconsDLL), CDlgDerived::IDD, _T("CKeyboardButtonST"), 5);
	if (dwRetValue != PAGEMANAGERST_OK)	return FALSE;
	//
	dwRetValue = m_Pages.AddPage(new CDlgXPStyleButtonST(NULL, &m_IconsDLL), CDlgXPStyleButtonST::IDD, _T("CXPStyleButtonST"), 6);
	if (dwRetValue != PAGEMANAGERST_OK)	return FALSE;
	//
	dwRetValue = m_Pages.AddPage(new CDlgLifeCakeButtonST(NULL, &m_IconsDLL), CDlgLifeCakeButtonST::IDD, _T("CLifeCakeButtonST"), 7);
	if (dwRetValue != PAGEMANAGERST_OK)	return FALSE;
	//
	dwRetValue = m_Pages.AddPage(new CDlgWinXPButtonST(NULL, &m_IconsDLL), CDlgWinXPButtonST::IDD, _T("CWinXPButtonST"), 8);
	if (dwRetValue != PAGEMANAGERST_OK)	return FALSE;
	//
	dwRetValue = m_Pages.AddPage(new CDlgBlendedButtonST(NULL, &m_IconsDLL), CDlgBlendedButtonST::IDD, _T("CBlendedButtonST"), 9);
	if (dwRetValue != PAGEMANAGERST_OK)	return FALSE;
	//
	dwRetValue = m_Pages.AddPage(new CDlgStaticST(NULL, &m_IconsDLL), CDlgStaticST::IDD, _T("CStaticST"), 10);
	if (dwRetValue != PAGEMANAGERST_OK)	return FALSE;
	//
	dwRetValue = m_Pages.AddPage(new CDlgBlendedStaticST(NULL, &m_IconsDLL), CDlgBlendedStaticST::IDD, _T("CBlendedStaticST"), 11);
	if (dwRetValue != PAGEMANAGERST_OK)	return FALSE;
	//
	dwRetValue = m_Pages.AddPage(new CDlgClockST(NULL, &m_IconsDLL), CDlgClockST::IDD, _T("CClockST"), 12);
	if (dwRetValue != PAGEMANAGERST_OK)	return FALSE;
	//
	dwRetValue = m_Pages.AddPage(new CDlgFileDialogST(NULL, &m_IconsDLL), CDlgFileDialogST::IDD, _T("CFileDialogST"), 13);
	if (dwRetValue != PAGEMANAGERST_OK)	return FALSE;
	//
	dwRetValue = m_Pages.AddPage(new CDlgProgressCtrlST(NULL, &m_IconsDLL), CDlgProgressCtrlST::IDD, _T("CProgressCtrlST"), 14);
	if (dwRetValue != PAGEMANAGERST_OK)	return FALSE;
	//
	dwRetValue = m_Pages.AddPage(new CDlgListBoxST(NULL, &m_IconsDLL), CDlgListBoxST::IDD, _T("CListBoxST"), 15);
	if (dwRetValue != PAGEMANAGERST_OK)	return FALSE;
	//
	dwRetValue = m_Pages.AddPage(new CDlgListBoxColorPickerST(NULL, &m_IconsDLL), CDlgListBoxColorPickerST::IDD, _T("CListBoxColorPickerST"), 15);
	if (dwRetValue != PAGEMANAGERST_OK)	return FALSE;
	//
	dwRetValue = m_Pages.AddPage(new CDlgLayeredWindowHelperST(NULL, &m_IconsDLL, m_hWnd), CDlgLayeredWindowHelperST::IDD, _T("CLayeredWindowHelperST"), 15);
	if (dwRetValue != PAGEMANAGERST_OK)	return FALSE;
	//
	dwRetValue = m_Pages.AddPage(new CDlgDigitST(NULL, &m_IconsDLL), CDlgDigitST::IDD, _T("CDigitST"), 16);
	if (dwRetValue != PAGEMANAGERST_OK)	return FALSE;
	//

	return TRUE;
} // End of CreatePages

void CGenericBkMFCDlg::ResizeCurrentPage()
{
	DWORD	dwRetValue = 0;
	DWORD	dwPageNumber = 0;
	CWnd*	lpWnd = NULL;
	CRect	rRect;

	dwRetValue = m_Pages.GetCurrentPageNumber(&dwPageNumber);
	// Resize only if exists one page !
	if (dwRetValue == PAGEMANAGERST_OK)
	{
		m_Pages.GetPagePtr(dwPageNumber, &lpWnd);

		if (lpWnd != NULL)
		{
			GetDlgItem(IDC_STCPLACEHOLDER)->GetWindowRect(rRect);
			ScreenToClient(rRect);
			lpWnd->MoveWindow(rRect);
		} // if
	} // if
} // End of ResizeCurrentPage

void CGenericBkMFCDlg::OnSelChangeLbxST()
{
	int	nIndex = LB_ERR;

	nIndex = m_lbxListBox.GetCurSel();
	if (nIndex != LB_ERR)
	{
		m_Pages.ActivatePage((DWORD)nIndex);
	} // if
} // End of OnSelChangeLbxST

void CGenericBkMFCDlg::OnBnClickedBtnfullscreen()
{
	m_FullScreen.ToggleFullScreen(m_hWnd, FALSE);
} // End of OnBnClickedBtnfullscreen
