示例#1
0
unsigned int RecipePanel::getCharId() const
{

    unsigned int toonid = 0;

    WTL::CComboBox tooncb = GetDlgItem(IDC_CHARACTERCOMBO);
    if (tooncb.GetCurSel() > 0)
    {
        toonid = (unsigned int)tooncb.GetItemData(tooncb.GetCurSel());
    }

    return toonid;
}
示例#2
0
void CMainDlg::ThreadConnectFn( ) 
{
	WTL::CComboBox port ;
	port.Attach( GetDlgItem( IDC_COMBO_RS232 ) ) ;
	int sel = port.GetCurSel( ) ;
	if ( sel == -1 ){
		MessageBox( "Выберите ком-порт" , "Внимание" , MB_OK | MB_ICONWARNING ) ;
		port.Detach() ;
		_endthread( ) ;
	}
	char szPortName[ 1024 ] ;
	*szPortName = NULL ;
	if ( port.GetLBTextLen( sel ) < 1 ) {
		MessageBox( "Выбрано пустое имя, выберите имя порта, начинающееся с COM.." , 
			"Внимание" , MB_OK | MB_ICONWARNING ) ;
		port.Detach( ) ;
		_endthread( ) ;
	}
	port.GetLBText( sel , szPortName ) ;
	port.Detach( ) ;

	char status[ 1024 ] ;
	*status = NULL ;
	sprintf( status , "Попытка подключиться к %s ..." , szPortName ) ;
	Status( status ) ;

	BOOL ok = FALSE ;
	ok = Connect( szPortName ) ;

	if ( !ok ){
		Disconnect() ;
		sprintf( status , "FAILED!Не могу подкл-ся к %s !!!" , szPortName ) ;
		StatusAppendLine( status ) ;
		_endthread( ) ;
	}else{
		sprintf( status , "OK! Подключиться к %s удалось успешно!" , szPortName ) ;
		StatusAppendLine( status ) ;
	}
	
	/*
	вставить обработку отсутствия АЦП
	if ( AdcGetCount( ) < 1 ){
		sprintf( status , "WARN! Не найдено ни одного модуля АЦП" ) ;
		StatusAppendLine( status ) ;
		Disconnect( ) ;
		sprintf( status , "OK! Произведено отключение от %s" , szPortName ) ;
		StatusAppendLine( status ) ;
		_endthread( ) ;
	}*/

	m_status = CONNECTED ;
	UpdateControls( ) ;

	HANDLE h = TableGetHandle( 0 ) ;
	if ( h ) TableCallback( h , UpdatePos ) ;

	_endthread( ) ;

}
示例#3
0
std::set<Item> RecipePanel::getItemList(const std::list<Item>& itemsInDatabase) const {
    WTL::CComboBox templatecb = GetDlgItem(IDC_RECIPECOMBO);
    if (templatecb.GetCurSel() > 0) {
        TCHAR buf[256] = {0};
        templatecb.GetLBText(templatecb.GetCurSel(), buf);
        std::tstring recipe(buf);

        const RecipeList* const r = m_recipeLoader.getRecipe(recipe);
        if (r == NULL)
            return std::set<Item>();
        else
            return r->getItemList(itemsInDatabase);
    }
    else
        return std::set<Item>();
}
示例#4
0
std::list<unsigned int> RecipePanel::getDesiredItemRefs() const {
    WTL::CComboBox templatecb = GetDlgItem(IDC_RECIPECOMBO);
    if (templatecb.GetCurSel() > 0) {
        TCHAR buf[256] = {0};
        templatecb.GetLBText(templatecb.GetCurSel(), buf);
        std::tstring recipe(buf);

        const RecipeList* const r = m_recipeLoader.getRecipe(recipe);
        if (r == NULL)
            return std::list<unsigned int>();
        else
            return r->getDesiredItemRefs();
    }
    else
        return std::list<unsigned int>();
}
示例#5
0
std::tstring RecipePanel::getRecipeName() const {

    WTL::CComboBox templatecb = GetDlgItem(IDC_RECIPECOMBO);
    if (templatecb.GetCurSel() > 0) {
        TCHAR buf[256] = {0};
        templatecb.GetLBText(templatecb.GetCurSel(), buf);
        std::tstring recipe(buf);

        const RecipeList* const r = m_recipeLoader.getRecipe(recipe);
        if (r == NULL)
            return _T("Unknown recipe??");
        else
            return r->getName();
    }
    else
        return _T("Unknown recipe??");
}
示例#6
0
LRESULT FindView::onDimensionFocus(WORD/*wNotifyCode*/, WORD/*wID*/, HWND/*hWndCtl*/, BOOL&/*bHandled*/)
{
    KillTimer(1);

    WTL::CComboBox cb = GetDlgItem(IDC_DIMENSION_COMBO);
    int oldselection = cb.GetCurSel();

    updateDimensionList();

    if (oldselection >= 0)
    {
        cb.SetCurSel(oldselection);
    }
    else if (oldselection == -1)
    {
        cb.SetCurSel(0);
    }

    return 0;
}
示例#7
0
	LRESULT onInitDialog(HWND, LPARAM)
	{
		WTL::CComboBox peerTypes;

		peerTypes.Attach(GetDlgItem(HAL_NEWT_ADD_PEERS_TYP_CBOX));
		
		peerTypes.AddString(hal::app().res_wstr(HAL_NEWT_ADD_PEERS_WEB).c_str());
		peerTypes.AddString(hal::app().res_wstr(HAL_NEWT_ADD_PEERS_DHT).c_str());

		if (hal::app().res_wstr(HAL_NEWT_ADD_PEERS_WEB) == peer_.type)
			peerTypes.SetCurSel(1);
		else
		{
			peerTypes.SetCurSel(0);
			::EnableWindow(GetDlgItem(HAL_NEWT_ADD_DHT_PORT_TEXT), true);
			::EnableWindow(GetDlgItem(HAL_NEWT_ADD_DHT_PORT), true);
		}

		resize_class_t::DlgResize_Init(false, true, WS_CLIPCHILDREN);

		SetMsgHandled(false);
		return 0;
	}
示例#8
0
LRESULT CMainDlg::OnInitDialog(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
{
	SetDlgItemInt( IDC_EDIT_COUNT , 41700 , FALSE ) ;
	// Определяем свободные порты

	HANDLE hPort = INVALID_HANDLE_VALUE ;
	char szPortName[ 1024 ] ;

	WTL::CComboBox	combo ;
	combo.Attach( GetDlgItem( IDC_COMBO_RS232 ) ) ;
	int count = combo.GetCount( ) ;
	if ( count > 0 ){
		for ( int i = 0 ; i < count ; i++ )
			combo.DeleteString( 0 ) ;
	}

	for ( UINT8 i = 1 ; i < 255 ; i++ ){
		*szPortName = NULL ;
		sprintf( szPortName , "COM%d" , i ) ;
		hPort = CreateFile( szPortName , GENERIC_READ | GENERIC_WRITE ,	NULL , NULL ,
			OPEN_EXISTING,	FILE_FLAG_OVERLAPPED, NULL ) ;
		DWORD dwError = GetLastError( ) ;
		if ( hPort == INVALID_HANDLE_VALUE ) continue ;
		combo.AddString( szPortName ) ;
		CloseHandle( hPort ) ;
		hPort = INVALID_HANDLE_VALUE ;
	}
	count = combo.GetCount( ) ;
	if ( count > 0 ) combo.SetCurSel( 0 ) ;

	combo.Detach( ) ;

	UpdateControls( ) ;

	Status( "Программа запущена..." ) ;

	return TRUE;
}
示例#9
0
void RecipePanel::updateCharList() {



    CComboBox cb = GetDlgItem(IDC_CHARACTERCOMBO);
    if (cb.GetCount() < 1)
    {
        WTL::CComboBox cb = GetDlgItem(IDC_CHARACTERCOMBO);
        cb.ResetContent();
        int item = cb.AddString(_T("-"));
        cb.SetItemData(item, 0);
        cb.SetCurSel(0);
        return;
    }

    unsigned int prev_selected_toon = cb.GetItemData(cb.GetCurSel());

    cb.ResetContent();
    int item = cb.AddString(_T("-"));
    cb.SetItemData(item, 0);
    cb.SetCurSel(0);

    g_DBManager.Lock();
    sqlite::ITablePtr pT = m_db->ExecTable("SELECT DISTINCT charid FROM tToons ORDER BY charname");

    if (pT != NULL)
    {
        for (unsigned int i = 0; i < pT->Rows(); i++)
        {
            unsigned int id = boost::lexical_cast<unsigned int>(pT->Data(i, 0));

            std::tstring name = g_DBManager.GetToonName(id);
            if (name.empty())
            {
                name = from_ascii_copy(pT->Data(i, 0));
            }

            if ((item = cb.AddString(name.c_str())) != CB_ERR)
            {
                cb.SetItemData(item, id);
            }
        }
    }
    g_DBManager.UnLock();

    bool found = false;
    for (int i = 0; i < cb.GetCount(); ++i)
    {
        unsigned int data = cb.GetItemData(i);
        if (data == prev_selected_toon)
        {
            cb.SetCurSel(i);
            found = true;
            break;
        }
    }

    if (!found)
    {
        cb.SetCurSel(0);
    }
}