Beispiel #1
0
LRESULT MainDlg::OnConnectStateChanged(WPARAM wParam, LPARAM lParam)
{
	ConnectState state = DeviceProxy::GetInstance()->GetConnectState();
	if (state == STATE_DEVICE_CLOSED)
	{
		// 按钮状态
		m_connectStateChkBtn.SetCheck(0);
		m_connectStateChkBtn.SetWindowText(_T("启动验钞机"));

		// 状态栏提示
		CString str;
		str.LoadStringW(IDS_DEVICE_CLOSED);
		m_statusBar.SetPanel(STATUSBAR_CONNECT_STATE, str, IDB_RED_CIRCLE);
	}
	else if (state == STATE_DEVICE_UNCONNECTED)
	{
		DeviceProxy::GetInstance()->Stop();
	}
	else if (state == STATE_DEVICE_CONNECTED)
	{
		// 状态栏提示
		CString str;
		str.LoadStringW(IDS_DEVICE_CONNECTED);
		m_statusBar.SetPanel(STATUSBAR_CONNECT_STATE, str, IDB_GREEN_CIRCLE);
	}
	else if (state == STATE_DEVICE_LISTENING)
	{
		// 状态栏提示
		CString str;
		str.LoadStringW(IDS_DEVICE_LISTENING);
		m_statusBar.SetPanel(STATUSBAR_CONNECT_STATE, str, IDB_GREEN_CIRCLE);
	}
	return TRUE;
}
//------------------------------------------------------------------
// convert CPU policy setting to string
//------------------------------------------------------------------
CString throttleString( UCHAR throttle )
{
  static CString s1, s2, s3, s4, s5;
  static boolean init = false;

  if( !init )
  {
    s1.LoadStringW( IDS_MAIN56 );
    s2.LoadStringW( IDS_MAIN57 );
    s3.LoadStringW( IDS_MAIN58 );
    s4.LoadStringW( IDS_MAIN59 );
    s5.LoadStringW( IDS_SW7 );
    init = true;
  }

  switch( throttle )
  {
    case PO_THROTTLE_NONE:      return s1;
    case PO_THROTTLE_CONSTANT:  return s2;
    case PO_THROTTLE_DEGRADE:   return s3;
    case PO_THROTTLE_ADAPTIVE:  return s4;
  }
  
  return s5;    
}
//------------------------------------------------------------------
// power action to string
//------------------------------------------------------------------
CString pwrAction( POWER_ACTION action )
{
  static CString s1, s2, s3, s4, s5, s6, s7, s8, s9;
  static boolean init = false;

  if( !init )
  {
    s1.LoadStringW( IDS_SW16 );
    s2.LoadStringW( IDS_SW17 );
    s3.LoadStringW( IDS_SW18 );
    s4.LoadStringW( IDS_SW19 );
    s5.LoadStringW( IDS_SW20 );
    s6.LoadStringW( IDS_SW21 );
    s7.LoadStringW( IDS_SW22 );
    s8.LoadStringW( IDS_SW23 );
    s9.LoadStringW( IDS_SW7 );
    init = true;
  }

  switch( action )
  {
    case PowerActionNone:          return s1; //_T("No action");
    case PowerActionReserved:      return s2; //_T("(reserved setting)");
    case PowerActionSleep:         return s3; //_T("Sleep");
    case PowerActionHibernate:     return s4; //_T("Hibernate");
    case PowerActionShutdown:      return s5; //_T("Shutdown");
    case PowerActionShutdownReset: return s6; //_T("Shutdown and reset");
    case PowerActionShutdownOff:   return s7; //_T("Shutdown and power off");
    case PowerActionWarmEject:     return s8; //_T("Warm eject");
  }
    
  return s9; //_T("(UNKNOWN)");
}
//------------------------------------------------------------------
// power state to string
//------------------------------------------------------------------
CString sysPwrState( SYSTEM_POWER_STATE state )
{
  static CString s1, s2, s3, s4, s5, s6, s7, s8, s9;
  static boolean init = false;

  if( !init )
  {
    s1.LoadStringW( IDS_SW8 );
    s2.LoadStringW( IDS_SW9 );
    s3.LoadStringW( IDS_SW10 );
    s4.LoadStringW( IDS_SW11 );
    s5.LoadStringW( IDS_SW12 );
    s6.LoadStringW( IDS_SW13 );
    s7.LoadStringW( IDS_SW14 );
    s8.LoadStringW( IDS_SW15 );
    s9.LoadStringW( IDS_SW7 );
    init = true;
  }

  switch( state )
  {
    case PowerSystemUnspecified: return s1; //_T("No wake up when lid opened");
    case PowerSystemWorking:     return s2; //_T("S0");
    case PowerSystemSleeping1:   return s3; //_T("S1");
    case PowerSystemSleeping2:   return s4; //_T("S2");
    case PowerSystemSleeping3:   return s5; //_T("S3");
    case PowerSystemHibernate:   return s6; //_T("S4 (Hibernate)");
    case PowerSystemShutdown:    return s7; //_T("S5 (Off)");
    case PowerSystemMaximum:     return s8; //_T("???");
  }
    
  return s9; //_T("(UNKNOWN)");
}
Beispiel #5
0
void CStartupView::DrawTitleText(Gdiplus::Graphics &graphics)
{
   Gdiplus::Rect gdipRcLeftButtons;
   CalculateLeftButtonsRegion(gdipRcLeftButtons);

   Gdiplus::SolidBrush blackBrush(Gdiplus::Color(255, 0, 0, 0));

   Gdiplus::Font titleFont(m_csFontFamily, m_iTitleFontSize, 
      Gdiplus::FontStyleBold, Gdiplus::UnitPixel);
   Gdiplus::Font subTitleFont(m_csFontFamily, m_iNormalFontSize, 
      Gdiplus::FontStyleBold, Gdiplus::UnitPixel);
   CString csRecord1;
   csRecord1.LoadString(IDS_RECORD);
   INT x = gdipRcLeftButtons.X;
   INT y = gdipRcLeftButtons.Y + 2*BUTTON_TITLE_HEIGHT;
   Gdiplus::PointF textOrigin(x/*gdipRcLeftButtons.X*/, y/*(gdipRcLeftButtons.Y + gdipRcLeftButtons.Height)*/ );
   graphics.SetTextRenderingHint(Gdiplus::TextRenderingHintAntiAliasGridFit);
   graphics.DrawString(csRecord1, csRecord1.GetLength(), &titleFont, textOrigin, &blackBrush);
   
   x = gdipRcLeftButtons.X;
   y = gdipRcLeftButtons.Y + BUTTON_TITLE_HEIGHT + 2*BUTTON_SUBTITLE_HEIGHT + 2*(BUTTON_HEIGHT1 + 10) + SEPARATOR_HEIGHT + 5;
   //Gdiplus::PointF textOrigin(x/*gdipRcLeftButtons.X*/, y/*(gdipRcLeftButtons.Y + gdipRcLeftButtons.Height)*/ );
   textOrigin.X = x;
   textOrigin.Y = y;

   CString csWelcome;
   //csWelcome.LoadStringW(IDS_WELCOME);
   csWelcome.LoadStringW(ID_MENU_NEW);
   graphics.DrawString(csWelcome, csWelcome.GetLength(), &titleFont, textOrigin, &blackBrush); 

   textOrigin.Y += BUTTON_TITLE_HEIGHT;
   

   Gdiplus::Rect gdipRcRightButtons;
   CalculateRightButtonsRegion(gdipRcRightButtons);

   textOrigin.X = gdipRcRightButtons.X ;
   textOrigin.Y = gdipRcRightButtons.Y + BUTTON_TITLE_HEIGHT + BUTTON_HEIGHT;;
   CString csRecord;
   //csRecord.LoadStringW(IDS_RECORD);
   csRecord.LoadStringW(ID_MENU_OPEN);
   graphics.DrawString(csRecord, csRecord.GetLength(), &titleFont, textOrigin, &blackBrush); 

   /*textOrigin.X = gdipRcRightButtons.X ;
   textOrigin.Y += 3*BUTTON_HEIGHT;

   CString csRecent;
   csRecent.LoadStringW(IDS_RECENTLY_OPENED_PROJECTS);
   graphics.DrawString(csRecent, csRecent.GetLength(), &titleFont, textOrigin, &blackBrush); */

}
Beispiel #6
0
BOOL CDlgFtch::OnInitDialog()
{
	CDialog::OnInitDialog();

	CString str;
	str.LoadStringW(IDS_STRING9030);
	GetDlgItem(IDC_STATIC_EDIT1)->SetWindowText(str);

	str.LoadStringW(IDS_STRING9031);
	this->SetWindowTextW(str);
	this->MoveWindow(0,0,625,90);

	return TRUE;  // return TRUE unless you set the focus to a control
	// EXCEPTION: OCX Property Pages should return FALSE
}
Beispiel #7
0
BOOL MainDlg::OnInitDialog()
{
	CDialog::OnInitDialog();

	// 设置此对话框的图标。  当应用程序主窗口不是对话框时,框架将自动
	//  执行此操作
	SetIcon(m_hIcon, TRUE);			// 设置大图标
	SetIcon(m_hIcon, FALSE);		// 设置小图标

	// TODO:  在此添加额外的初始化代码

	// 状态栏
	m_statusBar.Create(this, IDC_PLACE_STATUS);
	CString str;
	str.LoadStringW(IDS_DEVICE_CLOSED);//初始状态显示关闭
	m_statusBar.AddPanel(STATUSBAR_CONNECT_STATE, str, IDB_RED_CIRCLE, StatusBar::PANEL_ALIGN_RIGHT);
	str = "版本: ";
	str += ConfigBlock::GetInstance()->GetStringParameter(L"DeviceInfo", L"firmwareVersion", L"");
	m_statusBar.AddPanel(STATUSBAR_DEVICE_INFO, str, NULL, StatusBar::PANEL_ALIGN_RIGHT);

	// 点钞机状态按钮
	m_connectStateChkBtn.SetCheck(0);
	m_connectStateChkBtn.SetWindowText(_T("启动点钞机"));
	
	// 布局
	m_layout.Init(m_hWnd);
	m_layout.AddAnchor(m_statusBar.m_hWnd, AnchorLayout::BOTTOM_LEFT, AnchorLayout::BOTTOM_RIGHT);
	m_layout.AddDlgItem(IDC_EDIT_TIPS, AnchorLayout::BOTTOM_LEFT, AnchorLayout::BOTTOM_RIGHT);
	m_layout.AddDlgItem(IDC_STATIC_TIPS, AnchorLayout::BOTTOM_LEFT, AnchorLayout::BOTTOM_LEFT);

	// 显示
	ShowWindow(SW_SHOW);

	return TRUE;  // 除非将焦点设置到控件,否则返回 TRUE
}
void Contact::setContactType(int type)
{
	if(type < 0 || type > 2)
	{
		//throw new Error or smth...
		return;
	}
	tipContactKey = type;
	CString strTip;
	switch(type)
	{
	case Contact::FRIEND:
		strTip.LoadStringW(IDS_STRING132);
		break;
	case Contact::COLLEAGUE:
		strTip.LoadStringW(IDS_STRING133);
		break;
	case Contact::ACQUAINTANCE:
		strTip.LoadStringW(IDS_STRING134);
		break;
	}	
	setContactType(strTip);
}
Beispiel #9
0
/*++
* @name DynamicLoadIcon
*
* Returns the respective icon as per the current battery capacity.
* It also does the work of setting global parameters of battery capacity and tooltips.
*
* @param hinst
*        A handle to a instance of the module.
*
* @return The handle to respective battery icon.
*
*--*/
static HICON DynamicLoadIcon(HINSTANCE hinst)
{
    SYSTEM_POWER_STATUS PowerStatus;
    HICON hBatIcon;
    UINT index = -1;

    if (!GetSystemPowerStatus(&PowerStatus) ||
        PowerStatus.ACLineStatus == AC_LINE_UNKNOWN ||
        PowerStatus.BatteryFlag == BATTERY_FLAG_UNKNOWN)
    {
        hBatIcon = LoadIcon(hinst, MAKEINTRESOURCE(IDI_BATTCAP_ERR));
        g_strTooltip.LoadStringW(IDS_PWR_UNKNOWN_REMAINING);
        return hBatIcon;
    }

    if (((PowerStatus.BatteryFlag & BATTERY_FLAG_NO_BATTERY) == 0) &&
        ((PowerStatus.BatteryFlag & BATTERY_FLAG_CHARGING) == BATTERY_FLAG_CHARGING))
    {
        index = Quantize(PowerStatus.BatteryLifePercent);
        hBatIcon = LoadIcon(hinst, MAKEINTRESOURCE(bc_icons[index])); 
        g_strTooltip.Format(IDS_PWR_CHARGING, PowerStatus.BatteryLifePercent);
    }
    else if (((PowerStatus.BatteryFlag & BATTERY_FLAG_NO_BATTERY) == 0) &&
             ((PowerStatus.BatteryFlag & BATTERY_FLAG_CHARGING) == 0))
    {
        index = Quantize(PowerStatus.BatteryLifePercent);
        hBatIcon = LoadIcon(hinst, MAKEINTRESOURCE(br_icons[index]));
        g_strTooltip.Format(IDS_PWR_PERCENT_REMAINING, PowerStatus.BatteryLifePercent);
    }
    else
    {
        hBatIcon = LoadIcon(hinst, MAKEINTRESOURCE(IDI_POWER_AC));
        g_strTooltip.LoadStringW(IDS_PWR_AC);
    }

    return hBatIcon;
}
// The constructor
//
CArmyCardSgtDrakeAlexander::CArmyCardSgtDrakeAlexander()
:
// Call the base constructor
CArmyCard()
{
	// The name of the card
	m_Name.LoadString(IDS_SGTDRAKEALEXANDERNAME);
	// The basic rule text
	//m_BasicText.LoadStringW(IDS_);
	// The basic rule movement
	m_BasicMovementSpace = 5;
	// The basic range
	m_BasicRangeSpace = 1;
	// The basic rule attack
	m_BasicAttackDice = 3;
	// The basic rule defense
	m_BasicDefenseDice = 6;
	// The expert rule text
	//m_ExpertText.LoadStringW(IDS_);
	// The expert rule movement
	m_ExpertMovementSpace = 5;
	// The expert rule range
	m_ExpertRangeSpace = 1;
	// The expert rule attack
	m_ExpertAttackDice = 3;
	// The expert rule defense
	m_ExpertDefenseDice = 4;
	// The expert rule cost point
	m_ExpertCostPoint = 80;
	// The expert rule total life point
	m_ExpertTotalLifePoint = 4;
	// The current life point
	m_CurrentLifePoint = m_ExpertTotalLifePoint;
	// The ability to fly
	m_CanFly = false;
	// The bitmap file name
	m_BitmapFileName = _T("Sgt_Drake_Alexander");
	// The figures list
	CString Str;
	Str.LoadStringW( IDS_SGTDRAKEALEXANDER );
	CFigureObject* pFigureObject = new CFigureObject( false, Str, _T("SGT DRAKE ALEXANDER"), this );
	m_Figures.Add( pFigureObject );
}
Beispiel #11
0
// At the creation
//
int CInfoListBar::OnCreate(LPCREATESTRUCT lpCreateStruct) 
{
    if (CSizingControlBar::OnCreate(lpCreateStruct) == -1)
        return -1;

    if (!m_wndMyListCtrl.Create(LVS_REPORT|WS_CHILD|WS_VISIBLE|WS_BORDER|LVS_SINGLESEL|LVS_OWNERDRAWFIXED,CRect(0,0,0,0), this, 30003))
        return -1;

	if( !m_wndIcon.Create(NULL,SS_BITMAP|WS_CHILD|WS_VISIBLE,CRect(0,0,110,100), this, 2))
		return -1;
	m_bmp.LoadBitmap(IDB_INFOLIST);
	m_wndIcon.SetBitmap( (HBITMAP) m_bmp );

	CString StrResource;
	StrResource.LoadString( IDS_INFOBAR );
	if( !m_wndText.Create( StrResource ,WS_CHILD|WS_VISIBLE,CRect(0,0,0,0), this, 3))
		return -1;

    if (!m_font.CreateStockObject(DEFAULT_GUI_FONT))
		if (!m_font.CreatePointFont(80, _T("MS Sans Serif")))
            return -1;

    m_wndText.SetFont(&m_font);

	// Define the minimum size of this window
	m_szMin.cx = 110;
	m_szMin.cy = 100;

	m_ImageList.Create( IDB_IMAGELIST_INFO, 16, 3, RGB(255,0,255) );

	m_wndMyListCtrl.SetSpecialList( true );

	m_wndMyListCtrl.SetImageList( &m_ImageList, LVSIL_SMALL );
	CString Str;
	Str.LoadStringW( IDS_INFO_COLUMN );
	CGlobalIHM::CreateColumnListCtrl( &m_wndMyListCtrl, Str );
	LVCOLUMN Column;
	Column.mask = LVCF_FMT;
	Column.fmt = LVCFMT_CENTER;
	m_wndMyListCtrl.SetColumn( 1, &Column );

    return 0;
}
void ConnectionInfoUpdater(void * target)
{
	CEdit * connDisplay = (CEdit*)target;

	for (;;)
	{
		if (webserverSimName() != NULL)
		{
			connDisplay->SetWindowText(webserverSimName()->c_str());
		}
		else
		{
			CString simNameString;
			simNameString.LoadStringW(IDS_NOT_CONNECTED);
			connDisplay->SetWindowText(simNameString);
		}
		Sleep(1000);
	}
}
BOOL CServerBasicGUIDlg::OnInitDialog()
{
	CDialogEx::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

	// TODO: Add extra initialization here
	_beginthread(ConnectionInfoUpdater, 0, &simName);
	CString simNameString;
	simNameString.LoadStringW(IDS_NOT_CONNECTED);
	simName.SetWindowText(simNameString);

	CString portNumberString("8080");
	portNumber.SetWindowText(portNumberString);

	return TRUE;  // return TRUE  unless you set the focus to a control
}
void CServerBasicGUIDlg::OnBnClickedRunServer()
{
	if (runServer.GetCheck())
	{
		portNumber.SetReadOnly(true);
		launchServer(std::string(address), std::string(""));
	}
	else
	{
		stopServer();
		portNumber.SetReadOnly(false);
		CString simNameString;
		simNameString.LoadStringW(IDS_NOT_CONNECTED);
		simName.SetWindowText(simNameString);
	}

	if (webserverSimName() != NULL)
	{
		simName.SetWindowText(webserverSimName()->c_str());
	}

}
Beispiel #15
0
/**
\brief Executa os processos de leitura de arquivos e inserção no banco
\details	
	Funções executadas neste método:
	- Ler cada arquivo que necessita de atualização da lista;
	- Indicar o nome do arquivo de estrutura de dados;
	- Apagar os registros das tabelas a serem atualizadas;
	- Indicar quais dados de arquivo(tabela) deve ser baixada da internet;
	- Criar a barra de progresso para cada ítem da lista;
	- Inserir os valores no banco de dados;
	- Iniciar a atualização das séries

	Erros que causam a saída deste método:
	- Erro ao indicar o nome do arquivo de estrutura;
	- Erro ao indicar um arquivo a ser baixado da internet;
	- Erro ao apagar dados da tabela;
	- Erro ao inserir dados na tabela;
	- Erro ao enviar pedido de atualização de séries.

\param LPCTSTR szSystem: Nome do sistema que serão criadas as tabelas
\return void.
*/
void CUpdateDlg::_Process(LPCTSTR szSystem)
{
	SetStatus(L"Processando as atualizações...");

	CString strSys = szSystem;
	_FIELDS_ meu_registro;
	CString nomeTabela , insertCommand, sApagaTabela;
	TB_ATUALIZACAO *dadoArquivo = NULL;
	CGetFile *fileAtualiza;

	int errors = 0;

	HCURSOR hCurs = GetCursor();
	SetCursor(LoadCursor(NULL, IDC_WAIT));

	CString sContrato = m_params->GetValue(L"contrato");
	CString sVarPma = L"transmite_" + strSys;
	CString sURL = m_params->GetValue(sVarPma);
	if(sURL.IsEmpty())
	{
		STLOG_WRITE("CUpdateDlg::_Process(): url 'transmite' esta vazia.");
	}

	//::MessageBox( NULL, (CString) this->getNomeTabela(), L"TESTE", MB_OK );
	
	for( int i = 0; i < m_list.GetItemCount() ; i++)
	{
		nomeTabela = m_list.GetItemText(i,0);
		nomeTabela.Trim();

		fileAtualiza = new CGetFile();
		fileAtualiza->SetStructFile(m_sStructPath);
		if(!fileAtualiza->SetNomeTabela(nomeTabela))
		{
			errors++;
			m_list.SetProgress(i, 0);
			STLOG_WRITE(L"CUpdateDlg::_Process(): Error setando lista %s", nomeTabela);
			STLOG_WRITE("----------------------------------------------------------");
			continue;
		}		

		if(! fileAtualiza->GetFileFromServer(sURL, sContrato))
		{
			errors++;
			m_list.SetProgress(i, 0);
			STLOG_WRITE(L"CUpdateDlg::_Process(): Error Download %s", nomeTabela);
			STLOG_WRITE("----------------------------------------------------------");
			continue;
		}

		CTableBase::BeginTransaction(CppSQLite3DB::getInstance());

		//TODO: If migração não apaga
		//sApagaTabela.Format( L"DELETE FROM %s", nomeTabela );
		sApagaTabela.Format( L"DROP TABLE %s", nomeTabela );

		try
		{
			CppSQLite3DB::getInstance()->execQuery( CStr(sApagaTabela) );
		}
		catch(CppSQLite3Exception e)
		{
			errors++;
			STLOG_WRITE("CUpdateDlg::_Process(): %s", e.errorMessage());
			STLOG_WRITE(sApagaTabela);
			STLOG_WRITE("----------------------------------------------------------");
			continue;
		}

		m_manageDB->CreateOneTable(nomeTabela);

		BOOL failed = FALSE;
		int count;

		for(count=0; !fileAtualiza->IsEOF(); count++)
		{
			if ((count%2000) == 0)
			{
				Sleep(2000);
			}

			fileAtualiza->GetRecord(&meu_registro);
			insertCommand = fileAtualiza->sqlInsertCommand;

			try
			{
				CppSQLite3DB::getInstance()->execQuery( CStr(insertCommand) );
				m_list.SetProgress(i, (int)(100*(count+1)/fileAtualiza->GetTotalRegs()));
			}
			catch(CppSQLite3Exception e)
			{
				STLOG_WRITE(L"CUpdateDlg::_Process(1): %S", e.errorMessage());
				STLOG_WRITE(insertCommand);
				STLOG_WRITE("----------------------------------------------------------");

				errors++;
				failed = TRUE;
				CTableBase::RollbackTransaction(CppSQLite3DB::getInstance());
				m_list.SetProgress(i, 0);

				break;
			}

			fileAtualiza->MoveNext();
		}

		if(count == 0 || errors == 0)
			m_list.SetProgress(i, 100);

		m_listaArquivos.Lookup(nomeTabela, dadoArquivo);

		//TODO: If migracao não atualiza
		if(!failed)
		{
			CStr sQuery;
			sQuery.Format("INSERT INTO atualizacao VALUES ('%S', '%S', '%S')",
						  dadoArquivo->nome.Trim(), 
						  dadoArquivo->data,
						  dadoArquivo->hora );

			try
			{
				CppSQLite3DB::getInstance()->execQuery( sQuery );
				CTableBase::CommitTransaction(CppSQLite3DB::getInstance());
			}
			catch(CppSQLite3Exception e)
			{
				errors++;
				m_list.SetProgress(i, 0);
				CTableBase::RollbackTransaction(CppSQLite3DB::getInstance());
				STLOG_WRITE(L"CUpdateDlg::_Process(2): %S", e.errorMessage());
				STLOG_WRITE(insertCommand);
				STLOG_WRITE("----------------------------------------------------------");
			}
		}
		delete(fileAtualiza);
	}

	if(errors > 0)
	{
		errors = 0;
		SetCursor(hCurs);
		CString sErr;
		sErr.LoadStringW(IDS_ERRO_ATUALIZACAO);
		MessageBox(sErr, L"Mensagem", MB_ICONINFORMATION|MB_OK);

		// Aplicacao nao continua...
		return;
	}

	m_wnd->Show(L"Processando atualizações...");

	SetCursor(hCurs);

	m_wnd->Hide();

	SetStatus(L"Atualização encerrada com sucesso");
	Sleep(1000);

	return;
}
Beispiel #16
0
int COutputWnd::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
	if (CDockablePane::OnCreate(lpCreateStruct) == -1)
		return -1;

	CRect rectDummy;
	rectDummy.SetRectEmpty();

	// 建立索引標籤視窗:
	if (!m_wndTabs.Create(CMFCTabCtrl::STYLE_FLAT, rectDummy, this, 1))
	{
		TRACE0("無法建立輸出索引標籤視窗\n");
		return -1;      // 無法建立
	}

	// 建立輸出窗格:
	const DWORD dwStyle = LBS_NOINTEGRALHEIGHT | WS_CHILD | WS_VISIBLE | WS_HSCROLL | WS_VSCROLL;

	if (!m_wndOutputBuild.Create(dwStyle, rectDummy, &m_wndTabs, 2) ||
		!m_wndOutputDebug.Create(dwStyle, rectDummy, &m_wndTabs, 3) ||
		!m_wndOutputFind.Create(dwStyle, rectDummy, &m_wndTabs, 4))
	{
		TRACE0("無法建立輸出視窗\n");
		return -1;      // 無法建立
	}

	UpdateFonts();




	// 附加清單視窗到索引標籤:

	// phlin
	m_wndObjText.Create(WS_CHILD | WS_VISIBLE | WS_HSCROLL | WS_VSCROLL 
		|ES_AUTOHSCROLL | ES_AUTOVSCROLL | ES_MULTILINE | ES_LEFT | ES_WANTRETURN ,// | ES_READONLY, 
		rectDummy /*CRect(0,0,0,0)*/, &m_wndTabs, 5);
	m_wndTabs.AddTab(&m_wndObjText, _T(".obj"), (UINT)0);
	UpdateFonts();
	m_wndObjText.SetWindowTextW(_T("obj viewer\ntest"));
	
//	font.CreatePointFont(120, _T("新細明體"));
//	font.CreatePointFont(120, _T("標楷體"));
	font.CreatePointFont(110, _T("Courier New"));
	m_wndObjText.SetFont(&font);

//	CString str = _T("init");
//	str.AppendFormat(_T("%d\r\n%d"), 1, 2);
	CString str;
	str.LoadStringW(IDS_NO_MODEL);

	m_wndObjText.SetWindowTextW(str);


	CString strTabName;
	BOOL bNameValid;

	bNameValid = strTabName.LoadString(IDS_BUILD_TAB);
	ASSERT(bNameValid);
	m_wndTabs.AddTab(&m_wndOutputBuild, strTabName, (UINT)1);
	bNameValid = strTabName.LoadString(IDS_DEBUG_TAB);
	ASSERT(bNameValid);
	m_wndTabs.AddTab(&m_wndOutputDebug, strTabName, (UINT)2);
	bNameValid = strTabName.LoadString(IDS_FIND_TAB);
	ASSERT(bNameValid);
	m_wndTabs.AddTab(&m_wndOutputFind, strTabName, (UINT)3);

	


	// 在輸出索引標籤中填入一些假文字 (不需要什麼特別的內容)
	FillBuildWindow();
	FillDebugWindow();
	FillFindWindow();

	return 0;
}
//------------------------------------------------------------------
// check power scheme integrity
//
// check: 0=no consistency check
//        1=check power scheme only
//        2=check processor scheme only
//        3=check both power and processor scheme
//------------------------------------------------------------------
BOOL checkProfile( int check )
{
  log( _T("Checking power scheme integrity ...") );
  
  CString err;
  err.LoadStringW( IDS_MAINERR2 );

  POWER_POLICY policyTemp;
  MACHINE_PROCESSOR_POWER_POLICY machTemp;
  static TCHAR msg[1024];   // für diverse Fehlertexte
  BOOL forceActivate = FALSE;

  if( !ReadPwrScheme(internalProfile,&policyTemp) )
  {
    log( _T("Recreating power scheme ...") );
    UINT x = internalProfile;

    if( !WritePwrScheme(&x,L"Speedswitch Control",L"\0\0",&internalPolicy) )
    {
      CString s1;
      s1.LoadStringW( IDS_SW1 );
      wsprintf( msg, s1, GetLastError() );
      MessageBox( NULL, msg, err, MB_ICONEXCLAMATION|MB_OK );
      return FALSE;
    }

    forceActivate = TRUE;
  }
  else if( check&1 )
  {
    if( !comparePowerProfile(policyTemp,internalPolicy) )
    {
      log( _T("Restoring power scheme data ...") );
      UINT x = internalProfile;

      if( !WritePwrScheme(&x,L"Speedswitch Control",L"\0\0",&internalPolicy) )
      {
        CString s1;
        s1.LoadStringW( IDS_SW2 );
        wsprintf( msg, s1, GetLastError() );
        MessageBox( NULL, msg, err, MB_ICONEXCLAMATION|MB_OK );
        return FALSE;
      }

      forceActivate = TRUE;
    }
  }

  if( !ReadProcessorPwrScheme(internalProfile,&machTemp) )
  {
    log( _T("Recreating processor scheme ...") );
    if( !WriteProcessorPwrScheme(internalProfile,&mach) )
    {
      CString s1;
      s1.LoadStringW( IDS_SW3 );
      wsprintf( msg, s1, GetLastError() );
      MessageBox( NULL, msg, err, MB_ICONEXCLAMATION|MB_OK );
      return FALSE;
    }   

    forceActivate = TRUE;
  }
  else if( check&2 )
  {
    if( !compareCPUScheme(machTemp,mach) )
    {
      log( _T("Restoring processor scheme data ...") );
      if( !WriteProcessorPwrScheme(internalProfile,&mach) )
      {
        CString s1;
        s1.LoadStringW( IDS_SW4 );
        wsprintf( msg, s1, GetLastError() );
        MessageBox( NULL, msg, err, MB_ICONEXCLAMATION|MB_OK );
        return FALSE;
      }  

      forceActivate = TRUE;
    }
  }

  UINT profile;

  if( !GetActivePwrScheme(&profile) )
  {
    CString s1;
    s1.LoadStringW( IDS_SW5 );
    wsprintf( msg, s1, GetLastError() );
    MessageBox( NULL, msg, err, MB_OK|MB_ICONEXCLAMATION );
    return FALSE;
  }

  if( forceActivate || profile!=internalProfile )
  {
    log( _T("Reactivating power scheme (%d, %d) ..."), profile, internalProfile );
    if( !SetActivePwrScheme(internalProfile,NULL,NULL) )
    {
      CString s1;
      s1.LoadStringW( IDS_SW6 );
      wsprintf( msg, s1, GetLastError() );
      MessageBox( NULL, msg, err, MB_ICONEXCLAMATION|MB_OK );
      return FALSE;
    }
  }

  return TRUE;
}