// TestDlg.cpp : ����Ӧ�ó��������Ϊ��
//

#include "stdafx.h"
#include "TestDlg.h"
#include "TestDlgDlg.h"

#include "SDKInterface.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#endif


// CTestDlgApp

BEGIN_MESSAGE_MAP(CTestDlgApp, CWinApp)
	ON_COMMAND(ID_HELP, &CWinApp::OnHelp)
END_MESSAGE_MAP()


// CTestDlgApp ����

CTestDlgApp::CTestDlgApp()
{
	// ֧����������������
	m_dwRestartManagerSupportFlags = AFX_RESTART_MANAGER_SUPPORT_RESTART;

	// TODO:  �ڴ˴����ӹ�����룬
	// ��������Ҫ�ij�ʼ�������� InitInstance ��
}


// Ψһ��һ�� CTestDlgApp ����

CTestDlgApp theApp;


// CTestDlgApp ��ʼ��

BOOL CTestDlgApp::InitInstance()
{
	// ���һ�������� Windows XP �ϵ�Ӧ�ó����嵥ָ��Ҫ
	// ʹ�� ComCtl32.dll �汾 6 ����߰汾�����ÿ��ӻ���ʽ��
	//����Ҫ InitCommonControlsEx()��  ���򣬽��޷��������ڡ�
	INITCOMMONCONTROLSEX InitCtrls;
	InitCtrls.dwSize = sizeof(InitCtrls);
	// ��������Ϊ��������Ҫ��Ӧ�ó�����ʹ�õ�
	// �����ؼ��ࡣ
	InitCtrls.dwICC = ICC_WIN95_CLASSES;
	InitCommonControlsEx(&InitCtrls);

	CWinApp::InitInstance();

#if 1
	AllocConsole();                             // ���ٿ���̨;
	SetConsoleTitle(_T("�������"));				// ���ÿ���̨���ڱ���;
	freopen("CONOUT$", "w+t", stdout);			// �ض������;
	freopen("CONIN$", "r+t", stdin);			// �ض�������;

	HWND hWnd = NULL;
	hWnd = ::FindWindow(NULL, _T("�������"));
	if (hWnd)
	{
		if (!::SetWindowPos(hWnd, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE))
		{
			_tprintf(_T("ǰ������ʧ��\n"));
		}
		else
		{
			_tprintf(_T("ǰ�����óɹ�\n"));
		}
	}
#endif

#if 1
	//////////////////////////////////////////////////////////////////////////
	SDKInterface tagSDK;
	if (!tagSDK.Init())
	{
		AfxMessageBox(_T("��ر�������׿��ص�adb����"));
		return FALSE;
	}

	while (!tagSDK.IsConnect() )
	{
		Sleep(500);
	}
	tagSDK.BrightScreen(true);
	tagSDK.HomeBtnPress();
	// ��΢���л���ǰ̨;
	tagSDK.SwitchForground();
	// ��ʼ��������;
	tagSDK.StartDianZan();
	Sleep(20000);
	// ֹͣ��������;
	tagSDK.StopDianZan();
	// ��ȡ΢�ź����б�;
	//tagSDK.GetContactList();
	// ��ȡ΢��Ⱥ�б�;
	tagSDK.GetChatroomList();
	//////////////////////////////////////////////////////////////////////////
#endif

	AfxEnableControlContainer();

	// ���� shell ���������Է��Ի������
	// �κ� shell ����ͼ�ؼ��� shell �б���ͼ�ؼ���
	CShellManager *pShellManager = new CShellManager;

	// ���Windows Native���Ӿ����������Ա��� MFC �ؼ�����������
	CMFCVisualManager::SetDefaultManager(RUNTIME_CLASS(CMFCVisualManagerWindows));

	// ��׼��ʼ��
	// ���δʹ����Щ���ܲ�ϣ����С
	// ���տ�ִ���ļ��Ĵ�С����Ӧ�Ƴ�����
	// ����Ҫ���ض���ʼ������
	// �������ڴ洢���õ�ע�����
	// TODO:  Ӧ�ʵ��޸ĸ��ַ�����
	// �����޸�Ϊ��˾����֯��
	SetRegistryKey(_T("Ӧ�ó��������ɵı���Ӧ�ó���"));

	CTestDlgDlg dlg;
	m_pMainWnd = &dlg;
	INT_PTR nResponse = dlg.DoModal();
	if (nResponse == IDOK)
	{
		// TODO:  �ڴ˷��ô�����ʱ��
		//  ��ȷ�������رնԻ���Ĵ���
	}
	else if (nResponse == IDCANCEL)
	{
		// TODO:  �ڴ˷��ô�����ʱ��
		//  ��ȡ�������رնԻ���Ĵ���
	}
	else if (nResponse == -1)
	{
		TRACE(traceAppMsg, 0, "����: �Ի��򴴽�ʧ�ܣ�Ӧ�ó���������ֹ��\n");
		TRACE(traceAppMsg, 0, "����: ������ڶԻ�����ʹ�� MFC �ؼ������޷� #define _AFX_NO_MFC_CONTROLS_IN_DIALOGS��\n");
	}

	// ɾ�����洴���� shell ��������
	if (pShellManager != NULL)
	{
		delete pShellManager;
	}

	// ���ڶԻ����ѹرգ����Խ����� FALSE �Ա��˳�Ӧ�ó���
	//  ����������Ӧ�ó������Ϣ�á�
	return FALSE;
}