示例#1
0
BOOL CLogin::OnInitDialog()
{
	CDialog::OnInitDialog();
	
	CWinApp* pApp = AfxGetApp();

	//determine range of accounts in history.
	//range begins at 1 and ends at and includes latest.  Bing: "latest" is actually the count for previous logins.
	//
	//in this case, if 0 is the latest, then there is no history
	//and thus, don't do anything.

	UINT latest = pApp->GetProfileInt("History", "Latest", 0);

	m_ListBox.SetExtendedStyle( m_ListBox.GetExtendedStyle() | LVS_EX_FULLROWSELECT );
	m_ListBox.InsertColumn(0, "Name", LVCFMT_LEFT, 75);
	m_ListBox.InsertColumn(1, "Zone", LVCFMT_LEFT, 75);
	m_ListBox.InsertColumn(2, "Server Host", LVCFMT_LEFT, 110);
	m_ListBox.InsertColumn(3, "Port", LVCFMT_LEFT, 75);

	for(UINT i = 1; i <= latest; i++)
	{
		FillBoxes(i, true);
	}

	int count = m_ListBox.GetItemCount();

	if(count > 0)
	{
		VERIFY(m_ListBox.SetItemState(count-1, 0xFFFFFFFF, LVIS_SELECTED));
	}

	// set the last login
	int last_login = pApp->GetProfileInt("History", "LastLogin", 0);
	if(last_login == 0) /* no last login */
	{
		if(latest > 0)
		{
			last_login = latest;
		}
	}
	if(last_login > 0)
	{
		FillBoxes(last_login, false);
	}

	CButton *cbox = (CButton *)GetDlgItem(IDC_CHECK_PRELOGINS);
	if(pApp->GetProfileInt("ShowPreviousLogins", "YesNo", 1) == 0)
	{
		cbox->SetCheck(BST_UNCHECKED);
	}
	else
	{
		cbox->SetCheck(BST_CHECKED);
	}
	OnBnClickedCheckPrelogins();

	return TRUE;  // return TRUE unless you set the focus to a control
	              // EXCEPTION: OCX Property Pages should return FALSE
}
示例#2
0
void CLogin::OnClickList(NMHDR* pNMHDR, LRESULT* pResult) 
{
	*pResult = 0;

	if(1 != m_ListBox.GetSelectedCount())
		return;

	POSITION POS = m_ListBox.GetFirstSelectedItemPosition();
	int i = m_ListBox.GetNextSelectedItem(POS);

	FillBoxes(i+1, false);
}
示例#3
0
BOOL CConfigDlg::OnInitDialog()
{
    if( !CDialog::OnInitDialog() )
        return FALSE;

	CString tip;
	tip.LoadString( IDS_INCREASE_TIP );
	m_increase.SetToolTipText( &tip );

    tip.LoadString( IDS_MINIMIZE_TIP );
    m_minimize.SetToolTipText( &tip );

	tip.LoadString( IDS_PAUSE_TIP );
	m_muteCheck.SetToolTipText( &tip );

	tip.LoadString( IDS_ADD_TIP );
	m_addButton.SetToolTipText( &tip );

	tip.LoadString( IDS_DELETE_TIP );
	m_deleteButton.SetToolTipText( &tip );

	m_daysBox.SetUseTabOrder(TRUE);

    GetPlaylists();
    FillBoxes();

    m_snoozeTime.SetWindowText( _T("1") );
    m_snoozeSpin.SetRange( 1, 60 );

	CSliderCtrl *secs = (CSliderCtrl*)GetDlgItem( IDC_SECONDS_SLIDER );

	secs->SetPageSize( 10 );
	secs->SetRangeMin( 10 );
	secs->SetRangeMax( 120 );
	secs->EnableWindow( false );

    SetFocus();
    SetForegroundWindow();
    GetDlgItem(IDC_PLAYLISTS)->SetFocus();

	((CButton*)GetDlgItem( IDC_SUNDAY_CHECK ))->SetWindowText( DayInfo::LongDayNames()[0].c_str() );
	((CButton*)GetDlgItem( IDC_MONDAY_CHECK ))->SetWindowText( DayInfo::LongDayNames()[1].c_str() );
	((CButton*)GetDlgItem( IDC_TUESDAY_CHECK ))->SetWindowText( DayInfo::LongDayNames()[2].c_str() );
	((CButton*)GetDlgItem( IDC_WEDNESDAY_CHECK ))->SetWindowText( DayInfo::LongDayNames()[3].c_str() );
	((CButton*)GetDlgItem( IDC_THURSDAY_CHECK ))->SetWindowText( DayInfo::LongDayNames()[4].c_str() );
	((CButton*)GetDlgItem( IDC_FRIDAY_CHECK ))->SetWindowText( DayInfo::LongDayNames()[5].c_str() );
	((CButton*)GetDlgItem( IDC_SATURDAY_CHECK ))->SetWindowText( DayInfo::LongDayNames()[6].c_str() );

    return TRUE;
}
示例#4
0
void CConfigDlg::OnBnClickedButton1()
{
    CComboBox *playlists = (CComboBox*)GetDlgItem( IDC_PLAYLISTS );
    int selected = playlists->GetCurSel();
    playlists->ResetContent();
    m_playlists.clear();
    m_plids.clear();
    GetPlaylists();
    FillBoxes();
    if( selected < playlists->GetCount() )
        playlists->SetCurSel( selected );
    else
        SelectPlaylist();
}
示例#5
0
void CLogin::OnLoginRemove() 
{
	int count = m_ListBox.GetSelectedCount();

	//someone hit remove without selecting something to remove.
	if(0 == count)
		return;

	ASSERT(1 == count);


	if(AfxMessageBox("Do you want to delete the selected login data?", MB_YESNO) != IDYES)
		return;

	POSITION POS = m_ListBox.GetFirstSelectedItemPosition();
	int i = m_ListBox.GetNextSelectedItem(POS);

	CWinApp* pApp = AfxGetApp();

	UINT latest = pApp->GetProfileInt("History", "Latest", 0);

	//latest should never be 0 if there was something to remove.
	//nevertheless, if it is 0 we should return and do nothing.
	if(0 == latest)
	{
		ASSERT(1);	
		return;
	}

	CString name, host, zone, port;

	char buf[256];
	char buf2[256];

	//i is the listbox id for the profile to be removed.
	//the registry id for the profile is always i+1.
	//latest is always a valid entry, but latest+1 is not - hence no reason to move
	for(UINT j = i + 1; j < latest; j++)
	{
		sprintf(buf, "History\\%d", j);
		sprintf(buf2, "History\\%d", j+1);

		name = pApp->GetProfileString(buf2, "Name");
		host = pApp->GetProfileString(buf2, "Host");
		zone = pApp->GetProfileString(buf2, "Zone");
		port = pApp->GetProfileString(buf2, "Port");
		pApp->WriteProfileString(buf, "Name", name);
		pApp->WriteProfileString(buf, "Host", host);
		pApp->WriteProfileString(buf, "Zone", zone);
		pApp->WriteProfileString(buf, "Port", port);
	}

	//reflect that we're now one-less a profile and remove the last one.
	sprintf(buf, "History\\%d", latest);
	//erase all the child values
	pApp->WriteProfileString(buf, "Name", NULL);
	pApp->WriteProfileString(buf, "Host", NULL);
	pApp->WriteProfileString(buf, "Zone", NULL);
	pApp->WriteProfileString(buf, "Port", NULL);

	//erase the history key itself
	HKEY hKey;
	sprintf(buf, "%d", latest);
	::RegOpenKey(HKEY_CURRENT_USER, "Software\\San Diego Supercomputer Center\\WINI\\History", &hKey);
	::RegDeleteKey(hKey, buf);

	if(--latest < 0)
		latest = 0;

	pApp->WriteProfileInt("History", "Latest", latest);

	//finally, update the GUI
	m_ListBox.DeleteItem(i);

	//fills the left-hand boxes with the profile following the removed one.
	//don't fill up the right-hand listbox. it should handle case where i
	//is an illegal value safely.
	//remember, the parameter is i+1 not to find the subsequent value.
	//the subsequent value is now i, we are feeding fillboxes i+1 because
	//it works in registry range, not listbox range!
	FillBoxes(i+1, false);
}