// nc.cpp : Defines the class behaviors for the application.
//

#include "stdafx.h"
#include "nc.h"
#include "ncDlg.h"
//#include "USkin.h"
#include "NcFolder.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// CNcApp

BEGIN_MESSAGE_MAP(CNcApp, CWinApp)
	//{{AFX_MSG_MAP(CNcApp)
		// NOTE - the ClassWizard will add and remove mapping macros here.
		//    DO NOT EDIT what you see in these blocks of generated code!
	//}}AFX_MSG
	ON_COMMAND(ID_HELP, CWinApp::OnHelp)
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CNcApp construction

CNcApp::CNcApp()
{
	// TODO: add construction code here,
	// Place all significant initialization in InitInstance
}

/////////////////////////////////////////////////////////////////////////////
// The one and only CNcApp object

CNcApp theApp;

/////////////////////////////////////////////////////////////////////////////
// CNcApp initialization

//only run one instance
BOOL CNcApp::FirstInstance()
{
	CWnd *pWndPrev, *pWndChild;
	// Determine if another window with our class name and Window title exists...
	// The title "Instance " is set up latter, in the InitDialog function.
	if (pWndPrev = CWnd::FindWindow(NULL,"iQue聚乐部管理软件"))
	{
		pWndChild = pWndPrev->GetLastActivePopup();
		// if so, does it have any popups?
		if (pWndPrev->IsIconic()) 
			pWndPrev->ShowWindow(SW_RESTORE); 
		// If iconic, restore the main window
		pWndChild->SetForegroundWindow(); 
		// Bring the window to the foreground
		return FALSE; 
	}
	else
		return TRUE; // First instance. Proceed as normal.
}
BOOL CNcApp::InitInstance()
{
	AfxEnableControlContainer();
	if(!FirstInstance())
	{
		MessageBox(NULL,"iQue聚乐部管理软件已经在运行了","错误",MB_OK);
		return FALSE;
	}

	// Standard initialization
	// If you are not using these features and wish to reduce the size
	//  of your final executable, you should remove from the following
	//  the specific initialization routines you do not need.

#ifdef _AFXDLL
	Enable3dControls();			// Call this when using MFC in a shared DLL
#else
	Enable3dControlsStatic();	// Call this when linking to MFC statically
#endif
//	USkinInit(NULL,NULL,("media.u3"));
	CNcDlg dlg;
	m_pMainWnd = &dlg;
	SetDialogBkColor(RGB(239,235,239),RGB(255,0,0));
	
	int nResponse = dlg.DoModal();
	if (nResponse == IDOK)
	{
		// TODO: Place code here to handle when the dialog is
		//  dismissed with OK
	}
	else if (nResponse == IDCANCEL)
	{
		// TODO: Place code here to handle when the dialog is
		//  dismissed with Cancel
	}
	
//	USkinExit();
	// Since the dialog has been closed, return FALSE so that we exit the
	//  application, rather than start the application's message pump.
	return FALSE;
}
