Пример #1
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;
}
Пример #2
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;
	}
Пример #3
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);
    }
}