⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 serviceprofiles.cpp

📁 j2me is based on j2mepolish, client & server for mobile application.
💻 CPP
字号:

//         Copyright E骾n O'Callaghan 2008 - 2008.
// Distributed under the Boost Software License, Version 1.0.
//    (See accompanying file LICENSE_1_0.txt or copy at
//          http://www.boost.org/LICENSE_1_0.txt)

#include "StdAfx.hpp"
#include "Resource.h"

#include "auxiliary/logger.hpp"

#include "event_logger.hpp"
#include "SvcProWindow.hpp"

static class txt_log_file : public boost::signals::trackable
{
public:
	txt_log_file();
	
	void operator()(std::wstring s)
	{
		boost::shared_ptr<event_type> e(new event_type(event_logger::dev, s));
		logger.post(e);
	}
	
	void disconnect() { conn_.disconnect(); }
	
private:
	std::wofstream wofs;
	boost::signals::scoped_connection conn_;
	
} txt_log_file_;

txt_log_file::txt_log_file() :
	conn_(aux::wlog().attach(bind(&txt_log_file::operator(), &txt_log_file_, _1)))
{}

static class event_log_file : public boost::signals::trackable
{
public:
	event_log_file();
	
	void operator()(boost::shared_ptr<event_type> e)
	{
		if (!wofs.is_open()) wofs.open("Events.txt");
			
		wofs << (boost::wformat(L"%2%, %1%") % e->msg() % event_logger::event_level_to_str(e->level())) << std::endl;	
		wofs.flush();
	}
	
	void disconnect() { conn_.disconnect(); }
	
private:
	std::wofstream wofs;
	boost::signals::scoped_connection conn_;
	
} event_log_file_;

event_log_file::event_log_file() :
	conn_(logger.attach(bind(&event_log_file::operator(), &event_log_file_, _1)))
{}


int Run(int nCmdShow = SW_SHOWDEFAULT)
{
	try 
	{

	WTL::CMessageLoop theLoop;
	_Module.AddMessageLoop(&theLoop);

	aux::txml_ini ini(aux::app.non_roaming_directory()/L"ini.xml");
	ini.load_data();

	SvcProWindow wndMain(ini);

	if (NULL == wndMain.CreateEx())
	{
		ATLTRACE(_T("Main window creation failed!\n"));
		return 1;
	}

	wndMain.ShowWindow(nCmdShow);

	int result = theLoop.Run();
	
	ini.save_data();

	_Module.RemoveMessageLoop();
	return result;

	}
	catch (const std::exception& e)
	{	
		aux::wlog() << boost::wformat(L"Root std::exception: %1%") % aux::from_utf8_safe(e.what());

	_Module.Term();
	return 1;
	}	
}

int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE, LPSTR lpCmdLine, int nCmdShow)
{
	HRESULT hRes = ::CoInitialize(NULL);
	ATLASSERT(SUCCEEDED(hRes));

	HINSTANCE hInstRich = ::LoadLibrary(WTL::CRichEditCtrl::GetLibraryName());
	ATLASSERT(hInstRich != NULL);
	WTL::AtlInitCommonControls(ICC_COOL_CLASSES | ICC_BAR_CLASSES);

	hRes = _Module.Init(NULL, hInstance);
	ATLASSERT(SUCCEEDED(hRes));

	aux::wlog() << boost::wformat(L"Inital Dir: %1%, Working Dir: %2%") 
		% aux::app.initial_path() % aux::app.working_directory();

	aux::app.set_app_dir(L"ServiceProfiles");

	int result = Run(nCmdShow);

	_Module.Term();
	::CoUninitialize();

	return result;
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -