示例#1
0
void CXUIDatePicker::setDate( LPSYSTEMTIME pTm, BOOL isNone )
{
	if(!isNone)
	{
		DateTime_SetSystemtime(m_hWnd, GDT_VALID, pTm);
	} else
	{
		DateTime_SetSystemtime(m_hWnd, GDT_NONE, pTm);
	}
}
示例#2
0
void DateTimeFrame::setDate(uint64 date)
{
  date = (date + 11644473600ULL) * 10000000ULL;
  FILETIME ft;
  ft.dwLowDateTime = uint32(date);
  ft.dwHighDateTime = uint32(date >> 32);
  SYSTEMTIME st;
  FileTimeToSystemTime(&ft, &st);
  DateTime_SetSystemtime(hWnd, GDT_VALID, &st);
}
示例#3
0
void wxDatePickerCtrl::SetValue(const wxDateTime& dt)
{
    wxCHECK_RET( dt.IsValid() || HasFlag(wxDP_ALLOWNONE),
                    wxT("this control requires a valid date") );

    SYSTEMTIME st;
    if ( dt.IsValid() )
    {
        // Don't try setting the date if it's out of range: calendar control
        // under XP (and presumably all the other pre-Vista Windows versions)
        // doesn't return false from DateTime_SetSystemtime() in this case but
        // doesn't actually change the date, so we can't update our m_date
        // unconditionally and would need to check whether it was changed
        // before doing it. It looks simpler to just check whether it's in
        // range here instead.
        //
        // If we ever drop support for XP we could rely on the return value of
        // DateTime_SetSystemtime() but this probably won't happen in near
        // future.
        wxDateTime dtStart, dtEnd;
        GetRange(&dtStart, &dtEnd);
        if ( (dtStart.IsValid() && dt < dtStart) ||
                (dtEnd.IsValid() && dt > dtEnd) )
        {
            // Fail silently, some existing code relies on SetValue() with an
            // out of range value simply doing nothing -- so don't.
            return;
        }

        dt.GetAsMSWSysTime(&st);
    }

    if ( !DateTime_SetSystemtime(GetHwnd(),
                                 dt.IsValid() ? GDT_VALID : GDT_NONE,
                                 &st) )
    {
        // The only expected failure is when the date is out of range but we
        // already checked for this above.
        wxFAIL_MSG( wxT("Setting the calendar date unexpectedly failed.") );

        // In any case, skip updating m_date below.
        return;
    }

    // we need to keep only the date part, times don't make sense for this
    // control (in particular, comparisons with other dates would fail)
    m_date = dt;
    if ( m_date.IsValid() )
        m_date.ResetTime();
}
示例#4
0
	void SetOriginalTime ()
	{
		DateTime_SetSystemtime ( m_hTimeCreate, GDT_VALID, &m_tTimeCreate );
		DateTime_SetSystemtime ( m_hDateCreate, GDT_VALID, &m_tTimeCreate );
		DateTime_SetSystemtime ( m_hTimeAccess, GDT_VALID, &m_tTimeAccess );
		DateTime_SetSystemtime ( m_hDateAccess, GDT_VALID, &m_tTimeAccess );
		DateTime_SetSystemtime ( m_hTimeWrite, GDT_VALID, &m_tTimeWrite );
		DateTime_SetSystemtime ( m_hDateWrite, GDT_VALID, &m_tTimeWrite );
	}
示例#5
0
/**
 * name:	SetCurSel
 * class:	CAnnivEditCtrl
 * desc:	shows the item, identified by wIndex
 * param:	pDateCtrl	- pointer to the date control's data structure
 *			wIndex		- index of the item to delete
 * return:	0 on success 1 otherwise
 **/
INT_PTR CAnnivEditCtrl::SetCurSel(WORD wIndex)
{
	BYTE bEnabled = ItemValid(wIndex);

	EnableWindow(_hwndDate, bEnabled);
	EnableWindow(_hBtnEdit, bEnabled);
	EnableWindow(_hBtnDel, bEnabled && _pDates[wIndex]->IsValid());
	if (!bEnabled) {
		EnableReminderCtrl(FALSE);
		return 1;
	}
	_curDate = wIndex;

	// set date of date control
	if (_pDates[wIndex]->IsValid()) {
		SYSTEMTIME st = _pDates[wIndex]->SystemTime();
		DateTime_SetSystemtime(_hwndDate, GDT_VALID, &st);
		DateTime_SetFormat(_hwndDate, NULL);
	}
	else {
		TCHAR szText[MAX_DESC];
		mir_sntprintf(szText, _T("'%s'"), TranslateT("Unspecified"));
		DateTime_SetSystemtime(_hwndDate, GDT_NONE, NULL);
		DateTime_SetFormat(_hwndDate, szText);
	}
	// set edit button's caption
	SetWindowText(_hBtnEdit, _pDates[wIndex]->Description());

	// set reminder options
	CheckDlgButton(_hwndDlg, RADIO_REMIND1, _pDates[wIndex]->RemindOption() == BST_INDETERMINATE ? BST_CHECKED : BST_UNCHECKED);
	CheckDlgButton(_hwndDlg, RADIO_REMIND2, _pDates[wIndex]->RemindOption() == BST_CHECKED ? BST_CHECKED : BST_UNCHECKED);
	CheckDlgButton(_hwndDlg, RADIO_REMIND3, _pDates[wIndex]->RemindOption() == BST_UNCHECKED ? BST_CHECKED : BST_UNCHECKED);

	OnReminderChecked();
	EnableCurrentItem();
	return 0;
}
示例#6
0
void plAgeDescInterface::ISetControlDefaults()
{
    HWND hDate = GetDlgItem(fhDlg, IDC_DATE);
    HWND hTime = GetDlgItem(fhDlg, IDC_TIME);

    SYSTEMTIME st = {0};
    st.wDay = 1;
    st.wMonth = 1;
    st.wYear = 2000;
    DateTime_SetSystemtime(hDate, GDT_VALID, &st);
    DateTime_SetSystemtime(hTime, GDT_VALID, &st);

    fSpin->SetValue(24.f, FALSE);
    fCapSpin->SetValue(kDefaultCapacity, FALSE);

    CheckDlgButton( fhDlg, IDC_ADM_DONTLOAD, FALSE );

    int i;
    HWND ctrl = GetDlgItem( fhDlg, IDC_PAGE_LIST );
    for( i = SendMessage( ctrl, LB_GETCOUNT, 0, 0 ) - 1; i >= 0; i-- )
        RemovePageItem( ctrl, i );

    SetDlgItemText( fhDlg, IDC_AGEDESC, "Age Description" );
}
示例#7
0
void wxDatePickerCtrl::SetValue(const wxDateTime& dt)
{
    wxCHECK_RET( dt.IsValid() || HasFlag(wxDP_ALLOWNONE),
                    _T("this control requires a valid date") );

    SYSTEMTIME st;
    if ( dt.IsValid() )
        wxToSystemTime(&st, dt);
    if ( !DateTime_SetSystemtime(GetHwnd(),
                                 dt.IsValid() ? GDT_VALID : GDT_NONE,
                                 &st) )
    {
        wxLogDebug(_T("DateTime_SetSystemtime() failed"));
    }
}
示例#8
0
	void SetCurrentTime ()
	{
		SYSTEMTIME tTime;
		GetLocalTime ( &tTime );

		DateTime_SetSystemtime ( m_hTimeCreate, GDT_VALID, &tTime );
		DateTime_SetSystemtime ( m_hDateCreate, GDT_VALID, &tTime );
		DateTime_SetSystemtime ( m_hTimeAccess, GDT_VALID, &tTime );
		DateTime_SetSystemtime ( m_hDateAccess, GDT_VALID, &tTime );
		DateTime_SetSystemtime ( m_hTimeWrite, GDT_VALID, &tTime );
		DateTime_SetSystemtime ( m_hDateWrite, GDT_VALID, &tTime );
	}
示例#9
0
LRESULT CTimePickerDialog::OnInitDialog(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/)
{
	if ((m_title != NULL) && (strlen(m_title) > 0)) {
		String title = m_title;
		StringW title_w = convertToStringW(title);
		//SetWindowText(title_w.c_str());
		//GetDlgItem(IDC_TIME_CTRL).SetWindowText(title_w.c_str());
		SetDlgItemText(ID_TIME_CAPTION, title_w.c_str());
	}
	else {
		SetWindowText(_T("Date"));
	}

#if defined(_WIN32_WCE)

    SHINITDLGINFO shidi = { SHIDIM_FLAGS, m_hWnd, SHIDIF_SIZEDLGFULLSCREEN };
    RHO_ASSERT(SHInitDialog(&shidi));

    SHMENUBARINFO mbi = { sizeof(mbi), 0 };
    mbi.hwndParent = m_hWnd;
    mbi.nToolBarId = IDR_GETURL_MENUBAR;
    mbi.hInstRes = _AtlBaseModule.GetResourceInstance();
    RHO_ASSERT(SHCreateMenuBar(&mbi));
	GotoDlgCtrl(GetDlgItem(IDC_TIME_CTRL));

	SYSTEMTIME start_time;
	if (m_initialTime != 0) {
		UnixTimeToSystemTime(m_initialTime, &start_time);
		DateTime_SetSystemtime( GetDlgItem(IDC_TIME_CTRL), GDT_VALID, &start_time);
	}

#else

	CreateButtons();
	GotoDlgCtrl(m_btnOk);

#endif

	DLG_ITEM_SET_FONT_BOLD (IDC_TIME_STATIC);
	DLG_ITEM_SET_FONT_BOLD (ID_TIME_CAPTION);

    return FALSE;
}
示例#10
0
void wxDatePickerCtrl::SetValue(const wxDateTime& dt)
{
    wxCHECK_RET( dt.IsValid() || HasFlag(wxDP_ALLOWNONE),
                    wxT("this control requires a valid date") );

    SYSTEMTIME st;
    if ( dt.IsValid() )
        dt.GetAsMSWSysTime(&st);
    if ( !DateTime_SetSystemtime(GetHwnd(),
                                 dt.IsValid() ? GDT_VALID : GDT_NONE,
                                 &st) )
    {
        wxLogDebug(wxT("DateTime_SetSystemtime() failed"));
    }

    // we need to keep only the date part, times don't make sense for this
    // control (in particular, comparisons with other dates would fail)
    m_date = dt;
    if ( m_date.IsValid() )
        m_date.ResetTime();
}
示例#11
0
void wxDateTimePickerCtrl::SetValue(const wxDateTime& dt)
{
    wxCHECK_RET( dt.IsValid() || MSWAllowsNone(),
                    wxT("this control requires a valid date") );

    SYSTEMTIME st;
    if ( dt.IsValid() )
        dt.GetAsMSWSysTime(&st);

    if ( !DateTime_SetSystemtime(GetHwnd(),
                                 dt.IsValid() ? GDT_VALID : GDT_NONE,
                                 &st) )
    {
        // The only expected failure is when the date is out of range but we
        // already checked for this above.
        wxFAIL_MSG( wxT("Setting the calendar date unexpectedly failed.") );

        // In any case, skip updating m_date below.
        return;
    }

    m_date = dt;
}
示例#12
0
BOOL DateAdjustDlg::InitDlg()
{
	if (photos_.empty())
	{
		EndDialog(IDCANCEL);
		return true;
	}

	adj_mode_ = profile_adj_mode_;
	days_ = profile_days_;
	hours_ = profile_hours_;
	minutes_ = profile_minutes_;
	seconds_ = profile_seconds_;

	DialogChild::OnInitDialog();

	SetDlgItemInt(IDC_DAYS, days_);
	SetDlgItemInt(IDC_HOURS, hours_);
	SetDlgItemInt(IDC_MINUTES, minutes_);
	SetDlgItemInt(IDC_SECONDS, seconds_);

	BuildResizingMap();
	SetWndResizing(IDC_LIST, DlgAutoResize::RESIZE);
	SetWndResizing(IDC_HELP_BTN, DlgAutoResize::MOVE_V);
	SetWndResizing(IDCANCEL, DlgAutoResize::MOVE);
	SetWndResizing(IDOK, DlgAutoResize::MOVE);

	results_.SetExtendedStyle(LVS_EX_FULLROWSELECT | LVS_EX_DOUBLEBUFFER | LVS_EX_LABELTIP);
	//results_.InsertColumn(0, _T("File Name"), LVCFMT_LEFT, 100);
	results_.InsertColumn(0, _T("Existing Date/Time"), LVCFMT_LEFT, Pixels(150));
	results_.InsertColumn(1, _T("New Date/Time"), LVCFMT_LEFT, Pixels(150));
	results_.SetItemCount(static_cast<int>(photos_.size()));

	time_edit_.ModifyStyle(0, DTS_TIMEFORMAT);

	SubclassHelpBtn(_T("ToolDateTime.htm"));

	spin_days_.SetRange32(-100000, 100000);
	spin_hours_.SetRange32(-1000000, 1000000);
	spin_minutes_.SetRange32(-10000000, 10000000);
	spin_seconds_.SetRange32(-2000000000, 2000000000);

	// some reasonable text length limits (include sign, digits, and thousand separators)
	edit_days_.SetLimitText(8);
	edit_hours_.SetLimitText(16);
	edit_minutes_.SetLimitText(16);
	edit_seconds_.SetLimitText(16);

	// set min/max date
	WPARAM flags= GDTR_MIN | GDTR_MAX;
	SYSTEMTIME sys[2];
	memset(sys, 0, sizeof(sys));
	sys[0].wYear = 1601;
	sys[0].wMonth = 1;
	sys[0].wDay = 2;
	sys[1].wYear = 9999;
	sys[1].wMonth = 12;
	sys[1].wDay = 31;
	date_edit_.SendMessage(DTM_SETRANGE, flags, reinterpret_cast<LPARAM>(sys));
	time_edit_.SendMessage(DTM_SETRANGE, flags, reinterpret_cast<LPARAM>(sys));

	auto dt= DateTimeToSytemTime(FromISOString(profile_date_time_));
	DateTime_SetSystemtime(date_edit_, GDT_VALID, &dt);
	DateTime_SetSystemtime(time_edit_, GDT_VALID, &dt);

	example_time_ = photos_.front()->GetDateTime();

	ready_ = true;

	EnableGroup(adj_mode_ == 0);

	UpdateExampleAndOkBtn();

	return TRUE;  // return TRUE unless you set the focus to a control
	              // EXCEPTION: OCX Property Pages should return FALSE
}
示例#13
0
	void InitAttributesPage ( HWND hDlg )
	{
		DlgTxt ( hDlg, IDC_FIND_ARCHIVE, T_DLG_ATTR_ARCHIVE );
		DlgTxt ( hDlg, IDC_FIND_READONLY, T_DLG_ATTR_READONLY );
		DlgTxt ( hDlg, IDC_FIND_SYSTEM, T_DLG_ATTR_SYSTEM );
		DlgTxt ( hDlg, IDC_FIND_HIDDEN, T_DLG_ATTR_HIDDEN );
		DlgTxt ( hDlg, IDC_FIND_ROM, T_DLG_ATTR_ROM );
		DlgTxt ( hDlg, IDC_ORIGINAL, T_DLG_PROPS_ORIGINAL );
		DlgTxt ( hDlg, IDC_CURRENT, T_DLG_PROPS_CURRENT );
		DlgTxt ( hDlg, IDC_FIND_ATTRIBUTES_CHECK, T_DLG_PROPS_APPLYTOSUB );

		DlgTxt ( hDlg, IDC_CREATE_STATIC, T_DLG_PROPS_CREATED );
		DlgTxt ( hDlg, IDC_ACCESS_STATIC, T_DLG_PROPS_ACCESSED );
		DlgTxt ( hDlg, IDC_MODIFY_STATIC, T_DLG_PROPS_WRITTEN  );

		// time/date
		m_hTimeAccess	= GetDlgItem ( hDlg, IDC_TIME_ACCESS );
		m_hDateAccess	= GetDlgItem ( hDlg, IDC_DATE_ACCESS );
		m_hTimeCreate	= GetDlgItem ( hDlg, IDC_TIME_CREATE );
		m_hDateCreate	= GetDlgItem ( hDlg, IDC_DATE_CREATE );
		m_hTimeWrite	= GetDlgItem ( hDlg, IDC_TIME_WRITE );
		m_hDateWrite	= GetDlgItem ( hDlg, IDC_DATE_WRITE );

		BOOL bEnableTimeDate = m_tList.m_dFiles.Length () <= 1;

		EnableWindow ( m_hTimeAccess, bEnableTimeDate );
		EnableWindow ( m_hDateAccess, bEnableTimeDate );
		EnableWindow ( m_hTimeCreate, bEnableTimeDate );
		EnableWindow ( m_hDateCreate, bEnableTimeDate );
		EnableWindow ( m_hTimeWrite, bEnableTimeDate );
		EnableWindow ( m_hDateWrite, bEnableTimeDate );

		EnableWindow ( GetDlgItem ( hDlg, IDC_ORIGINAL ), bEnableTimeDate );
		EnableWindow ( GetDlgItem ( hDlg, IDC_CURRENT ), bEnableTimeDate );

		if ( ! bEnableTimeDate )
		{
			GetLocalTime ( &m_tTimeAccess );
			m_tTimeCreate = m_tTimeWrite = m_tTimeAccess;

			DateTime_SetSystemtime ( m_hDateAccess, GDT_VALID, &m_tTimeAccess );
			DateTime_SetSystemtime ( m_hTimeAccess, GDT_VALID, &m_tTimeAccess );
			DateTime_SetSystemtime ( m_hDateCreate, GDT_VALID, &m_tTimeAccess );
			DateTime_SetSystemtime ( m_hTimeCreate, GDT_VALID, &m_tTimeAccess );
			DateTime_SetSystemtime ( m_hDateWrite, GDT_VALID,  &m_tTimeAccess );
			DateTime_SetSystemtime ( m_hTimeWrite, GDT_VALID,  &m_tTimeAccess );
		}
		else
		{
			const WIN32_FIND_DATA & tData = m_tList.m_dFiles [0]->m_tData;
			FILETIME tLocalTime;

			FileTimeToLocalFileTime ( &tData.ftCreationTime, &tLocalTime );
			FileTimeToSystemTime ( &tLocalTime, &m_tTimeCreate );

			FileTimeToLocalFileTime ( &tData.ftLastAccessTime, &tLocalTime );
			FileTimeToSystemTime ( &tLocalTime, &m_tTimeAccess );
			
			FileTimeToLocalFileTime ( &tData.ftLastWriteTime, &tLocalTime );
			FileTimeToSystemTime ( &tLocalTime, &m_tTimeWrite );

			DateTime_SetSystemtime ( m_hTimeAccess, GDT_VALID, &m_tTimeAccess );
			DateTime_SetSystemtime ( m_hDateAccess, GDT_VALID, &m_tTimeAccess );

			DateTime_SetSystemtime ( m_hTimeCreate, GDT_VALID, &m_tTimeCreate );
			DateTime_SetSystemtime ( m_hDateCreate, GDT_VALID, &m_tTimeCreate );

			DateTime_SetSystemtime ( m_hTimeWrite, GDT_VALID, &m_tTimeWrite );
			DateTime_SetSystemtime ( m_hDateWrite, GDT_VALID, &m_tTimeWrite );
		}

		// attributes
		bool bEnable3State = m_nFiles > 1;

		EnableWindow ( GetDlgItem ( hDlg, IDC_FIND_ATTRIBUTES_CHECK ), ( m_nFiles + m_nFolders > 1 ) ? TRUE : FALSE );
		for ( int i = 0; i <= IDC_FIND_ROM - IDC_FIND_ARCHIVE; ++i )
		{
			HWND hItem = GetDlgItem ( hDlg, i + IDC_FIND_ARCHIVE );
			
			int iStyle = bEnable3State ? BS_AUTO3STATE : BS_AUTOCHECKBOX;
			SendMessage ( hItem, BM_SETSTYLE, iStyle, FALSE );

			int iCheck = BST_INDETERMINATE;

			if ( m_dwIncAttrib & g_dAttributes [i] )
			{
				if ( ! ( m_dwExAttrib & g_dAttributes [i] ) )
					iCheck = BST_CHECKED;
			}
			else
				if (  m_dwExAttrib & g_dAttributes [i] )
					iCheck = BST_UNCHECKED;

			CheckDlgButton ( hDlg, i + IDC_FIND_ARCHIVE, iCheck );
		}
	}
示例#14
0
void plAgeDescInterface::ILoadAge( const plFileName &path, bool checkSeqNum )
{
    ISetControlDefaults();
    
    fDirty = false;

    // create and read the age desc
    plAgeDescription aged( path );

    // Get the name of the age
    ST::string ageName = path.GetFileNameNoExt();

    // Check the sequence prefix #
    if( checkSeqNum )
        ICheckSequenceNumber( aged );

    char str[ _MAX_FNAME + 30 ];
    sprintf( str, "Description for %s", ageName.c_str() );
    SetDlgItemText( fhDlg, IDC_AGEDESC, str );

    // Set up the Dlgs
    SYSTEMTIME st;

    HWND hTime = GetDlgItem(fhDlg, IDC_TIME);
    memset(&st,0, sizeof(st));
    st.wYear = 2000;
    st.wMonth = 1;
    st.wDay = 1;
    st.wHour = aged.GetStartHour();
    st.wMinute = aged.GetStartMinute();
    st.wSecond = aged.GetStartSecond();
    DateTime_SetSystemtime(hTime, GDT_VALID, &st);

    
    HWND hDate = GetDlgItem(fhDlg, IDC_DATE);
    memset(&st,0, sizeof(st));
    st.wMonth = aged.GetStartMonth();
    st.wDay = aged.GetStartDay();
    st.wYear = aged.GetStartYear();
    DateTime_SetSystemtime(hDate, GDT_VALID, &st);

    
    fSpin->SetValue(aged.GetDayLength(), FALSE);

    int maxCap = aged.GetMaxCapacity();
    if (maxCap == -1)
    {
        maxCap = kDefaultCapacity;
        fDirty = true;
    }
    fCapSpin->SetValue(maxCap, FALSE);

    int32_t seqPrefix = aged.GetSequencePrefix();
    if( seqPrefix < 0 )
    {
        // Reserved prefix
        fSeqPrefixSpin->SetValue( (int)( -seqPrefix ), FALSE );
        CheckDlgButton( fhDlg, IDC_RSVDCHECK, BST_CHECKED );
    }
    else
    {
        fSeqPrefixSpin->SetValue( (int)seqPrefix, FALSE );
        CheckDlgButton( fhDlg, IDC_RSVDCHECK, BST_UNCHECKED );
    }

    // Disable the registry controls for now
    EnableWindow( GetDlgItem( fhDlg, IDC_RSVDCHECK ), false );
    EnableWindow( GetDlgItem( fhDlg, IDC_SEQPREFIX_EDIT ), false );
    EnableWindow( GetDlgItem( fhDlg, IDC_SEQPREFIX_SPIN ), false );

    aged.SeekFirstPage();
    plAgePage *page;

    HWND hPage = GetDlgItem(fhDlg, IDC_PAGE_LIST);
    while( ( page = aged.GetNextPage() ) != nil )
    {
        int idx = ListBox_AddString( hPage, page->GetName().c_str() );
        ListBox_SetItemData( hPage, idx, (LPARAM)new plAgePage( *page ) );
    }
}
示例#15
0
static INT_PTR CALLBACK SettingsDlgProc(HWND hwndDlg,UINT msg,WPARAM wParam,LPARAM lParam)
{
	switch(msg) {
	case WM_INITDIALOG:
		{
			LCID locale;
			hwndSettingsDlg=hwndDlg;
			TranslateDialogDefault(hwndDlg);
			locale=CallService(MS_LANGPACK_GETLOCALE,0,0);
			SendDlgItemMessage(hwndDlg,IDC_ICON_HEADER,STM_SETIMAGE,IMAGE_ICON,(LPARAM)Skin_GetIcon("AutoShutdown_Header"));
			{
				HFONT hBoldFont;
				LOGFONT lf;
				if (GetObject((HFONT)SendDlgItemMessage(hwndDlg,IDC_TEXT_HEADER,WM_GETFONT,0,0),sizeof(lf),&lf)) {
					lf.lfWeight=FW_BOLD;
					hBoldFont=CreateFontIndirect(&lf);
				} else hBoldFont=NULL;
				SendDlgItemMessage(hwndDlg,IDC_TEXT_HEADER,WM_SETFONT,(WPARAM)hBoldFont,FALSE);
			}
			/* read-in watcher flags */
			{
				WORD watcherType=db_get_w(NULL,"AutoShutdown","WatcherFlags",SETTING_WATCHERFLAGS_DEFAULT);
				CheckRadioButton(hwndDlg,IDC_RADIO_STTIME,IDC_RADIO_STCOUNTDOWN,(watcherType&SDWTF_ST_TIME)?IDC_RADIO_STTIME:IDC_RADIO_STCOUNTDOWN);
				CheckDlgButton(hwndDlg,IDC_CHECK_SPECIFICTIME,(watcherType&SDWTF_SPECIFICTIME) != 0 ? BST_CHECKED : BST_UNCHECKED);
				CheckDlgButton(hwndDlg,IDC_CHECK_MESSAGE,(watcherType&SDWTF_MESSAGE) != 0 ? BST_CHECKED : BST_UNCHECKED);
				CheckDlgButton(hwndDlg,IDC_CHECK_FILETRANSFER,(watcherType&SDWTF_FILETRANSFER) != 0 ? BST_CHECKED : BST_UNCHECKED);
				CheckDlgButton(hwndDlg,IDC_CHECK_IDLE,(watcherType&SDWTF_IDLE) != 0 ? BST_CHECKED : BST_UNCHECKED);
				CheckDlgButton(hwndDlg,IDC_CHECK_STATUS,(watcherType&SDWTF_STATUS) != 0 ? BST_CHECKED : BST_UNCHECKED);
				CheckDlgButton(hwndDlg,IDC_CHECK_CPUUSAGE,(watcherType&SDWTF_CPUUSAGE) != 0 ? BST_CHECKED : BST_UNCHECKED);
			}
			/* read-in countdown val */
			{
				SYSTEMTIME st;
				if (!TimeStampToSystemTime((time_t)db_get_dw(NULL,"AutoShutdown","TimeStamp",SETTING_TIMESTAMP_DEFAULT),&st))
					GetLocalTime(&st);
				DateTime_SetSystemtime(GetDlgItem(hwndDlg,IDC_TIME_TIMESTAMP),GDT_VALID,&st);
				DateTime_SetSystemtime(GetDlgItem(hwndDlg,IDC_DATE_TIMESTAMP),GDT_VALID,&st);
				SendMessage(hwndDlg,M_CHECK_DATETIME,0,0);
			}
			{
				DWORD setting=db_get_dw(NULL,"AutoShutdown","Countdown",SETTING_COUNTDOWN_DEFAULT);
				if (setting<1) setting=SETTING_COUNTDOWN_DEFAULT;
				SendDlgItemMessage(hwndDlg,IDC_SPIN_COUNTDOWN,UDM_SETRANGE,0,MAKELPARAM(UD_MAXVAL,1));
				SendDlgItemMessage(hwndDlg,IDC_EDIT_COUNTDOWN,EM_SETLIMITTEXT,(WPARAM)10,0);
				SendDlgItemMessage(hwndDlg,IDC_SPIN_COUNTDOWN,UDM_SETPOS,0,MAKELPARAM(setting,0));
				SetDlgItemInt(hwndDlg,IDC_EDIT_COUNTDOWN,setting,FALSE);
			}
			{
				HWND hwndCombo=GetDlgItem(hwndDlg,IDC_COMBO_COUNTDOWNUNIT);
				DWORD lastUnit=db_get_dw(NULL,"AutoShutdown","CountdownUnit",SETTING_COUNTDOWNUNIT_DEFAULT);
				SendMessage(hwndCombo,CB_SETLOCALE,(WPARAM)locale,0); /* sort order */
				SendMessage(hwndCombo,CB_INITSTORAGE,SIZEOF(unitNames),SIZEOF(unitNames)*16); /* approx. */
				for(int i=0;i<SIZEOF(unitNames);++i) {
					int index=SendMessage(hwndCombo,CB_ADDSTRING,0,(LPARAM)TranslateTS(unitNames[i]));
					if (index != LB_ERR) {
						SendMessage(hwndCombo,CB_SETITEMDATA,index,(LPARAM)unitValues[i]);
						if (i==0 || unitValues[i]==lastUnit) SendMessage(hwndCombo,CB_SETCURSEL,index,0);
					}
				}
			}
			{
				DBVARIANT dbv;
				if (!db_get_ts(NULL,"AutoShutdown","Message",&dbv)) {
					SetDlgItemText(hwndDlg,IDC_EDIT_MESSAGE,dbv.ptszVal);
					mir_free(dbv.ptszVal);
				}
			}
			/* cpuusage threshold */
			{
				BYTE setting=DBGetContactSettingRangedByte(NULL,"AutoShutdown","CpuUsageThreshold",SETTING_CPUUSAGETHRESHOLD_DEFAULT,1,100);
				SendDlgItemMessage(hwndDlg,IDC_SPIN_CPUUSAGE,UDM_SETRANGE,0,MAKELPARAM(100,1));
				SendDlgItemMessage(hwndDlg,IDC_EDIT_CPUUSAGE,EM_SETLIMITTEXT,(WPARAM)3,0);
				SendDlgItemMessage(hwndDlg,IDC_SPIN_CPUUSAGE,UDM_SETPOS,0,MAKELPARAM(setting,0));
				SetDlgItemInt(hwndDlg,IDC_EDIT_CPUUSAGE,setting,FALSE);
			}
			/* shutdown types */
			{
				HWND hwndCombo=GetDlgItem(hwndDlg,IDC_COMBO_SHUTDOWNTYPE);
				BYTE lastShutdownType=db_get_b(NULL,"AutoShutdown","ShutdownType",SETTING_SHUTDOWNTYPE_DEFAULT);
				SendMessage(hwndCombo,CB_SETLOCALE,(WPARAM)locale,0); /* sort order */
				SendMessage(hwndCombo,CB_SETEXTENDEDUI,TRUE,0);
				SendMessage(hwndCombo,CB_INITSTORAGE,SDSDT_MAX,SDSDT_MAX*32);
				for(BYTE shutdownType=1;shutdownType<=SDSDT_MAX;++shutdownType)
					if (ServiceIsTypeEnabled(shutdownType,0)) {
						TCHAR *pszText=(TCHAR*)ServiceGetTypeDescription(shutdownType,GSTDF_TCHAR); /* never fails */
						int index=SendMessage(hwndCombo,CB_ADDSTRING,0,(LPARAM)pszText);
						if (index != LB_ERR) {
							SendMessage(hwndCombo,CB_SETITEMDATA,index,(LPARAM)shutdownType);
							if (shutdownType==1 || shutdownType==lastShutdownType) SendMessage(hwndCombo,CB_SETCURSEL,(WPARAM)index,0);
						}
					}
				SendMessage(hwndDlg,M_UPDATE_SHUTDOWNDESC,0,(LPARAM)hwndCombo);
			}
			/* check if proto is installed that supports instant messages and check if a message dialog plugin is installed */
			if (!AnyProtoHasCaps(PF1_IMRECV) || !ServiceExists(MS_MSG_SENDMESSAGE)) { /* no srmessage present? */
				CheckDlgButton(hwndDlg, IDC_CHECK_MESSAGE, BST_UNCHECKED);
				EnableWindow(GetDlgItem(hwndDlg,IDC_CHECK_MESSAGE),FALSE);
				EnableWindow(GetDlgItem(hwndDlg,IDC_EDIT_MESSAGE),FALSE);
			}
			/* check if proto is installed that supports file transfers and check if a file transfer dialog is available */
			if (!AnyProtoHasCaps(PF1_FILESEND) && !AnyProtoHasCaps(PF1_FILERECV)) {  /* no srfile present? */
				CheckDlgButton(hwndDlg, IDC_CHECK_FILETRANSFER, BST_UNCHECKED);
				EnableWindow(GetDlgItem(hwndDlg,IDC_CHECK_FILETRANSFER),FALSE);
			}
			/* check if cpu usage can be detected */
			if (!PollCpuUsage(DisplayCpuUsageProc,(LPARAM)GetDlgItem(hwndDlg,IDC_TEXT_CURRENTCPU),1800)) {
				CheckDlgButton(hwndDlg, IDC_CHECK_CPUUSAGE, BST_UNCHECKED);
				EnableWindow(GetDlgItem(hwndDlg,IDC_CHECK_CPUUSAGE),FALSE);
			}
			SendMessage(hwndDlg,M_ENABLE_SUBCTLS,0,0);
			Utils_RestoreWindowPositionNoSize(hwndDlg,NULL,"AutoShutdown","SettingsDlg_");
			return TRUE; /* default focus */
		}
	case WM_DESTROY:
		{
			Utils_SaveWindowPosition(hwndDlg,NULL,"AutoShutdown","SettingsDlg_");
			HICON hIcon=(HICON)SendDlgItemMessage(hwndDlg,IDC_ICON_HEADER,STM_SETIMAGE,IMAGE_ICON,0);
			HFONT hFont=(HFONT)SendDlgItemMessage(hwndDlg,IDC_TEXT_HEADER,WM_GETFONT,0,0);
			SendDlgItemMessage(hwndDlg,IDC_TEXT_HEADER,WM_SETFONT,0,FALSE); /* no return value */
			if (hFont != NULL) DeleteObject(hFont);
			hwndSettingsDlg=NULL;
		}
		return TRUE;

	case WM_CTLCOLORSTATIC:
		switch(GetDlgCtrlID((HWND)lParam)) {
		case IDC_ICON_HEADER:
			SetBkMode((HDC)wParam,TRANSPARENT);
		case IDC_RECT_HEADER:
			/* need to set COLOR_WINDOW manually for Win9x */
			SetBkColor((HDC)wParam,GetSysColor(COLOR_WINDOW));
			return (BOOL)GetSysColorBrush(COLOR_WINDOW);
		case IDC_TEXT_HEADER:
		case IDC_TEXT_HEADERDESC:
			SetBkMode((HDC)wParam,TRANSPARENT);
			return (BOOL)GetStockObject(NULL_BRUSH);
		}
		break;

	case M_ENABLE_SUBCTLS:
		{
			BOOL checked=IsDlgButtonChecked(hwndDlg,IDC_CHECK_MESSAGE) != 0;
			EnableDlgItem(hwndDlg,IDC_EDIT_MESSAGE,checked);
			checked=IsDlgButtonChecked(hwndDlg,IDC_CHECK_SPECIFICTIME) != 0;
			EnableDlgItem(hwndDlg,IDC_RADIO_STTIME,checked);
			EnableDlgItem(hwndDlg,IDC_RADIO_STCOUNTDOWN,checked);
			checked=(IsDlgButtonChecked(hwndDlg,IDC_CHECK_SPECIFICTIME) && IsDlgButtonChecked(hwndDlg,IDC_RADIO_STTIME));
			EnableDlgItem(hwndDlg,IDC_TIME_TIMESTAMP,checked);
			EnableDlgItem(hwndDlg,IDC_DATE_TIMESTAMP,checked);
			checked=(IsDlgButtonChecked(hwndDlg,IDC_CHECK_SPECIFICTIME) && IsDlgButtonChecked(hwndDlg,IDC_RADIO_STCOUNTDOWN));
			EnableDlgItem(hwndDlg,IDC_EDIT_COUNTDOWN,checked);
			EnableDlgItem(hwndDlg,IDC_SPIN_COUNTDOWN,checked);
			EnableDlgItem(hwndDlg,IDC_COMBO_COUNTDOWNUNIT,checked);
			checked=IsDlgButtonChecked(hwndDlg,IDC_CHECK_IDLE) != 0;
			EnableDlgItem(hwndDlg,IDC_URL_IDLE,checked);
			checked=IsDlgButtonChecked(hwndDlg,IDC_CHECK_CPUUSAGE) != 0;
			EnableDlgItem(hwndDlg,IDC_EDIT_CPUUSAGE,checked);
			EnableDlgItem(hwndDlg,IDC_SPIN_CPUUSAGE,checked);
			EnableDlgItem(hwndDlg,IDC_TEXT_PERCENT,checked);
			EnableDlgItem(hwndDlg,IDC_TEXT_CURRENTCPU,checked);
			checked=(IsDlgButtonChecked(hwndDlg,IDC_CHECK_SPECIFICTIME) || IsDlgButtonChecked(hwndDlg,IDC_CHECK_MESSAGE) ||
				IsDlgButtonChecked(hwndDlg,IDC_CHECK_IDLE) || IsDlgButtonChecked(hwndDlg,IDC_CHECK_STATUS) ||
				IsDlgButtonChecked(hwndDlg,IDC_CHECK_FILETRANSFER) || IsDlgButtonChecked(hwndDlg,IDC_CHECK_CPUUSAGE));
			EnableDlgItem(hwndDlg,IDOK,checked);
		}
		return TRUE;
	case M_UPDATE_SHUTDOWNDESC: /* lParam=(LPARAM)(HWND)hwndCombo */
		{
			BYTE shutdownType = (BYTE)SendMessage((HWND)lParam,CB_GETITEMDATA,SendMessage((HWND)lParam,CB_GETCURSEL,0,0),0);
			SetDlgItemText(hwndDlg,IDC_TEXT_SHUTDOWNTYPE,(TCHAR*)ServiceGetTypeDescription(shutdownType,GSTDF_LONGDESC|GSTDF_TCHAR));
		}
		return TRUE;

	case WM_TIMECHANGE: /* system time changed */
		SendMessage(hwndDlg,M_CHECK_DATETIME,0,0);
		return TRUE;

	case M_CHECK_DATETIME:
		{
			SYSTEMTIME st,stBuf;
			time_t timestamp;
			DateTime_GetSystemtime(GetDlgItem(hwndDlg,IDC_DATE_TIMESTAMP),&stBuf);
			DateTime_GetSystemtime(GetDlgItem(hwndDlg,IDC_TIME_TIMESTAMP),&st);
			st.wDay=stBuf.wDay;
			st.wDayOfWeek=stBuf.wDayOfWeek;
			st.wMonth=stBuf.wMonth;
			st.wYear=stBuf.wYear;
			GetLocalTime(&stBuf);
			if (SystemTimeToTimeStamp(&st,&timestamp)) {
				/* set to current date if earlier */
				if (timestamp<time(NULL)) {
					st.wDay=stBuf.wDay;
					st.wDayOfWeek=stBuf.wDayOfWeek;
					st.wMonth=stBuf.wMonth;
					st.wYear=stBuf.wYear;
					if (SystemTimeToTimeStamp(&st,&timestamp)) {
						/* step one day up if still earlier */
						if (timestamp<time(NULL)) {
							timestamp+=24*60*60;
							TimeStampToSystemTime(timestamp,&st);
						}
					}
				}
			}
			DateTime_SetRange(GetDlgItem(hwndDlg,IDC_DATE_TIMESTAMP),GDTR_MIN,&stBuf);
			DateTime_SetRange(GetDlgItem(hwndDlg,IDC_TIME_TIMESTAMP),GDTR_MIN,&stBuf);
			DateTime_SetSystemtime(GetDlgItem(hwndDlg,IDC_DATE_TIMESTAMP),GDT_VALID,&st);
			DateTime_SetSystemtime(GetDlgItem(hwndDlg,IDC_TIME_TIMESTAMP),GDT_VALID,&st);
			return TRUE;
		}
	case WM_NOTIFY:
		switch(((NMHDR*)lParam)->idFrom) {
		case IDC_TIME_TIMESTAMP:
		case IDC_DATE_TIMESTAMP:
			switch(((NMHDR*)lParam)->code) {
			case DTN_CLOSEUP:
			case NM_KILLFOCUS:
				PostMessage(hwndDlg,M_CHECK_DATETIME,0,0);
				return TRUE;
			}
		}
		break;

	case WM_COMMAND:
		switch(LOWORD(wParam)) {
		case IDC_CHECK_MESSAGE:
		case IDC_CHECK_FILETRANSFER:
		case IDC_CHECK_IDLE:
		case IDC_CHECK_CPUUSAGE:
		case IDC_CHECK_STATUS:
		case IDC_CHECK_SPECIFICTIME:
		case IDC_RADIO_STTIME:
		case IDC_RADIO_STCOUNTDOWN:
			SendMessage(hwndDlg,M_ENABLE_SUBCTLS,0,0);
			return TRUE;

		case IDC_EDIT_COUNTDOWN:
			if (HIWORD(wParam)==EN_KILLFOCUS) {
				if ((int)GetDlgItemInt(hwndDlg,IDC_EDIT_COUNTDOWN,NULL,TRUE)<1) {
					SendDlgItemMessage(hwndDlg,IDC_SPIN_COUNTDOWN,UDM_SETPOS,0,MAKELPARAM(1,0));
					SetDlgItemInt(hwndDlg,IDC_EDIT_COUNTDOWN,1,FALSE);
				}
				return TRUE;
			}
			break;

		case IDC_EDIT_CPUUSAGE:
			if (HIWORD(wParam)==EN_KILLFOCUS) {
				WORD val=(WORD)GetDlgItemInt(hwndDlg,IDC_EDIT_CPUUSAGE,NULL,FALSE);
				if (val<1) val=1;
				else if (val>100) val=100;
				SendDlgItemMessage(hwndDlg,IDC_SPIN_CPUUSAGE,UDM_SETPOS,0,MAKELPARAM(val,0));
				SetDlgItemInt(hwndDlg,IDC_EDIT_CPUUSAGE,val,FALSE);
				return TRUE;
			}
			break;

		case IDC_URL_IDLE:
			{	
				OPENOPTIONSDIALOG ood;
				ood.cbSize = sizeof(ood);
				ood.pszGroup = "Status"; /* autotranslated */
				ood.pszPage = "Idle"; /* autotranslated */
				ood.pszTab = NULL;
				Options_Open(&ood);
				return TRUE;
			}

		case IDC_COMBO_SHUTDOWNTYPE:
			if (HIWORD(wParam)==CBN_SELCHANGE)
				SendMessage(hwndDlg,M_UPDATE_SHUTDOWNDESC,0,lParam);
			return TRUE;

		case IDOK: /* save settings and start watcher */
			ShowWindow(hwndDlg,SW_HIDE);
			/* message text */
			{
				HWND hwndEdit=GetDlgItem(hwndDlg,IDC_EDIT_MESSAGE);
				int len=GetWindowTextLength(hwndEdit)+1;
				TCHAR *pszText=(TCHAR*)mir_alloc(len*sizeof(TCHAR));
				if (pszText != NULL && GetWindowText(hwndEdit,pszText,len+1)) {
					TrimString(pszText);
					db_set_ts(NULL,"AutoShutdown","Message",pszText);
				}
				mir_free(pszText); /* does NULL check */
			}
			/* timestamp */
			{
				SYSTEMTIME st;
				time_t timestamp;
				DateTime_GetSystemtime(GetDlgItem(hwndDlg,IDC_TIME_TIMESTAMP),&st); /* time gets synchronized */
				if (!SystemTimeToTimeStamp(&st,&timestamp))
					timestamp=time(NULL);
				db_set_dw(NULL,"AutoShutdown","TimeStamp",(DWORD)timestamp);
			}
			/* shutdown type */
			{
				int index = SendDlgItemMessage(hwndDlg,IDC_COMBO_SHUTDOWNTYPE,CB_GETCURSEL,0,0);
				if (index != LB_ERR) db_set_b(NULL,"AutoShutdown","ShutdownType",(BYTE)SendDlgItemMessage(hwndDlg,IDC_COMBO_SHUTDOWNTYPE,CB_GETITEMDATA,(WPARAM)index,0));
				index=SendDlgItemMessage(hwndDlg,IDC_COMBO_COUNTDOWNUNIT,CB_GETCURSEL,0,0);
				if (index != LB_ERR) db_set_dw(NULL,"AutoShutdown","CountdownUnit",(DWORD)SendDlgItemMessage(hwndDlg,IDC_COMBO_COUNTDOWNUNIT,CB_GETITEMDATA,(WPARAM)index,0));
				db_set_dw(NULL,"AutoShutdown","Countdown",(DWORD)GetDlgItemInt(hwndDlg,IDC_EDIT_COUNTDOWN,NULL,FALSE));
				db_set_b(NULL,"AutoShutdown","CpuUsageThreshold",(BYTE)GetDlgItemInt(hwndDlg,IDC_EDIT_CPUUSAGE,NULL,FALSE));
			}
			/* watcher type */
			{
				WORD watcherType = (WORD)(IsDlgButtonChecked(hwndDlg,IDC_RADIO_STTIME)?SDWTF_ST_TIME:SDWTF_ST_COUNTDOWN);
				if (IsDlgButtonChecked(hwndDlg,IDC_CHECK_SPECIFICTIME)) watcherType|=SDWTF_SPECIFICTIME;
				if (IsDlgButtonChecked(hwndDlg,IDC_CHECK_MESSAGE)) watcherType|=SDWTF_MESSAGE;
				if (IsDlgButtonChecked(hwndDlg,IDC_CHECK_FILETRANSFER)) watcherType|=SDWTF_FILETRANSFER;
				if (IsDlgButtonChecked(hwndDlg,IDC_CHECK_IDLE)) watcherType|=SDWTF_IDLE;
				if (IsDlgButtonChecked(hwndDlg,IDC_CHECK_STATUS)) watcherType|=SDWTF_STATUS;
				if (IsDlgButtonChecked(hwndDlg,IDC_CHECK_CPUUSAGE)) watcherType|=SDWTF_CPUUSAGE;
				db_set_w(NULL,"AutoShutdown","WatcherFlags",watcherType);
				ServiceStartWatcher(0,watcherType);
			}
			DestroyWindow(hwndDlg);
			return TRUE;
			/* fall through */
		case IDCANCEL: /* WM_CLOSE */
			DestroyWindow(hwndDlg);
			SetShutdownToolbarButton(false);
			SetShutdownMenuItem(false);
			return TRUE;
		}
		break;
	}
	return FALSE;
}
示例#16
0
void
CalendarCtrl::InitCalendarValues()
{
	wyString temp,temp2;
	m_row = CustomGrid_GetCurSelRow(m_hwndparent);
	m_col = CustomGrid_GetCurSelCol(m_hwndparent);
	wyChar tempchar[5]= "";
	
	
	if(m_orgdata.Substr(0,4)==NULL)
		strcpy(tempchar,"0");
	else
		strcpy(tempchar,m_orgdata.Substr(0,4));
	temp.Add(tempchar);
	m_datetime.wYear=temp.GetAsUInt32();
	temp.Clear();
	
	
	if(m_orgdata.Substr(5,2)==NULL)
		strcpy(tempchar,"0");
	else
		strcpy(tempchar,m_orgdata.Substr(5,2));
	temp.Add(tempchar);
	m_datetime.wMonth=temp.GetAsUInt32();
	temp.Clear();
	
	if(m_orgdata.Substr(8,2)==NULL)
		strcpy(tempchar,"0");
	else
		strcpy(tempchar,m_orgdata.Substr(8,2));
	temp.Add(tempchar);
	m_datetime.wDay=temp.GetAsUInt32();
	temp.Clear();
		
	
	if(m_orgdata.Substr(11,2)==NULL)
		strcpy(tempchar,"0");
	else
		strcpy(tempchar,m_orgdata.Substr(11,2));
	temp.Add(tempchar);
	m_datetime.wHour=temp.GetAsUInt32();
	temp.Clear();
	
	
	if(m_orgdata.Substr(14,2)==NULL)
		strcpy(tempchar,"0");
	else
		strcpy(tempchar,m_orgdata.Substr(14,2));
	temp.Add(tempchar);

			m_datetime.wMinute=temp.GetAsUInt32();
			temp.Clear();

			
	if(m_orgdata.Substr(17,2)==NULL)
		strcpy(tempchar,"0");
	else
		strcpy(tempchar,m_orgdata.Substr(17,2));
	temp.Add(tempchar);
	m_datetime.wSecond=temp.GetAsUInt32();
	m_datetime.wMilliseconds=0;
	
	
	MonthCal_SetCurSel(GetDlgItem(m_hwnd,IDC_MONTHCALENDAR1), &m_datetime);
	if(!m_isDate)
	{
		DateTime_SetFormat(GetDlgItem(m_hwnd,IDC_DATETIMEPICKER1), L"HH:mm:ss");
		DateTime_SetSystemtime(GetDlgItem(m_hwnd,IDC_DATETIMEPICKER1),GDT_VALID, &m_datetime);
	}
}
示例#17
0
void DateTimeFrame::setNoDate()
{
  DateTime_SetSystemtime(hWnd, GDT_NONE, NULL);
}
示例#18
0
INT_PTR CALLBACK MirandaAdvOptionsPageProc(HWND hdlg,UINT message,WPARAM wParam,LPARAM lParam)
{
	switch(message) {
	case WM_INITDIALOG:
		TranslateDialogDefault(hdlg);
		{
			struct tm *TM = NULL;
			struct _SYSTEMTIME ST = {0};

			dwSinceDate = db_get_dw(NULL,IMPORT_MODULE,"ImportSinceTS",time(NULL));

			TM = localtime(&dwSinceDate);

			ST.wYear = TM->tm_year + 1900;
			ST.wMonth = TM->tm_mon + 1;
			ST.wDay = TM->tm_mday;

    		DateTime_SetSystemtime(GetDlgItem(hdlg,IDC_DATETIMEPICKER),GDT_VALID,&ST);
		}
		return TRUE;

	case WM_COMMAND:
		switch(LOWORD(wParam)) {
		case IDC_BACK:
			PostMessage(GetParent(hdlg),WIZM_GOTOPAGE,IDD_OPTIONS,(LPARAM)MirandaOptionsPageProc);
			break;

		case IDOK:
			DoImport = MirandaImport;
			nImportOption = IMPORT_CUSTOM;
			nCustomOptions = 0;

			if (IsDlgButtonChecked(hdlg,IDC_CONTACTS))
				nCustomOptions |= IOPT_CONTACTS | IOPT_GROUPS;
			if (IsDlgButtonChecked(hdlg,IDC_SYSTEM))
				nCustomOptions |= IOPT_SYSTEM;

			// incoming
			if (IsDlgButtonChecked(hdlg,IDC_IN_MSG))
				nCustomOptions |= IOPT_MSGRECV;
			if (IsDlgButtonChecked(hdlg,IDC_IN_URL))
				nCustomOptions |= IOPT_URLRECV;
			if (IsDlgButtonChecked(hdlg,IDC_IN_FT))
				nCustomOptions |= IOPT_FILERECV;
			if (IsDlgButtonChecked(hdlg,IDC_IN_OTHER))
				nCustomOptions |= IOPT_OTHERRECV;

			// outgoing
			if (IsDlgButtonChecked(hdlg,IDC_OUT_MSG))
				nCustomOptions |= IOPT_MSGSENT;
			if (IsDlgButtonChecked(hdlg,IDC_OUT_URL))
				nCustomOptions |= IOPT_URLSENT;
			if (IsDlgButtonChecked(hdlg,IDC_OUT_FT))
				nCustomOptions |= IOPT_FILESENT;
			if (IsDlgButtonChecked(hdlg,IDC_OUT_OTHER))
				nCustomOptions |= IOPT_OTHERSENT;

			// since date
			dwSinceDate = 0;

			if ( IsDlgButtonChecked( hdlg, IDC_SINCE )) {
				struct _SYSTEMTIME ST = {0};

				if (DateTime_GetSystemtime(GetDlgItem(hdlg,IDC_DATETIMEPICKER), &ST) == GDT_VALID) {
					struct tm TM = {0};

					TM.tm_mday = ST.wDay;
					TM.tm_mon = ST.wMonth - 1;
					TM.tm_year = ST.wYear - 1900;

					dwSinceDate = mktime(&TM);

					db_set_dw(NULL,IMPORT_MODULE,"ImportSinceTS",dwSinceDate);
  			}	}

			if (nCustomOptions)
				PostMessage(GetParent(hdlg),WIZM_GOTOPAGE,IDD_PROGRESS,(LPARAM)ProgressPageProc);
			break;

		case IDCANCEL:
			PostMessage(GetParent(hdlg), WM_CLOSE, 0, 0);
			break;

		case IDC_SINCE:
			EnableWindow(GetDlgItem(hdlg, IDC_DATETIMEPICKER), IsDlgButtonChecked(hdlg, IDC_SINCE));
			break;

		if (HIWORD(wParam) != STN_CLICKED)
			break;

		case IDC_ALL:
		case IDC_INCOMING:
		case IDC_OUTGOING:
			if (LOWORD(wParam) == IDC_ALL)
				for (int i = 0; i < sizeof(SysControls)/sizeof(SysControls[0]); i++)
					CheckDlgButton(hdlg,SysControls[i], !IsDlgButtonChecked(hdlg,SysControls[i]));

			if (LOWORD(wParam) != IDC_OUTGOING)
				for (int i = 0; i < sizeof(InControls)/sizeof(InControls[0]); i++)
					CheckDlgButton(hdlg,InControls[i], !IsDlgButtonChecked(hdlg,InControls[i]));

			if (LOWORD(wParam) != IDC_INCOMING)
				for (int i = 0; i < sizeof(OutControls)/sizeof(OutControls[0]); i++)
					CheckDlgButton(hdlg,OutControls[i], !IsDlgButtonChecked(hdlg,OutControls[i]));
			break;

		case IDC_MSG:
			CheckDlgButton(hdlg,IDC_IN_MSG, !IsDlgButtonChecked(hdlg,IDC_IN_MSG));
			CheckDlgButton(hdlg,IDC_OUT_MSG, !IsDlgButtonChecked(hdlg,IDC_OUT_MSG));
			break;

		case IDC_URL:
			CheckDlgButton(hdlg,IDC_IN_URL, !IsDlgButtonChecked(hdlg,IDC_IN_URL));
			CheckDlgButton(hdlg,IDC_OUT_URL, !IsDlgButtonChecked(hdlg,IDC_OUT_URL));
			break;

		case IDC_FT:
			CheckDlgButton(hdlg,IDC_IN_FT, !IsDlgButtonChecked(hdlg,IDC_IN_FT));
			CheckDlgButton(hdlg,IDC_OUT_FT, !IsDlgButtonChecked(hdlg,IDC_OUT_FT));
			break;

		case IDC_OTHER:
			CheckDlgButton(hdlg,IDC_IN_OTHER, !IsDlgButtonChecked(hdlg,IDC_IN_OTHER));
			CheckDlgButton(hdlg,IDC_OUT_OTHER, !IsDlgButtonChecked(hdlg,IDC_OUT_OTHER));
			break;
		}
		break;
	}
	return FALSE;
}
示例#19
0
//Record movie dialog
static INT_PTR CALLBACK RecordDialogProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
	static struct CreateMovieParameters* p = NULL;
	std::wstring author = L"";
	std::string fname;
	SYSTEMTIME systime;
	switch(uMsg)
	{
		case WM_INITDIALOG: {
			CheckDlgButton(hwndDlg, IDC_START_FROM_SRAM, ((flag == 1) ? BST_CHECKED : BST_UNCHECKED));
			SetFocus(GetDlgItem(hwndDlg, IDC_EDIT_FILENAME));

			DateTime t = FCEUI_MovieGetRTCDefault();
			ZeroMemory(&systime, sizeof(SYSTEMTIME));
			systime.wYear = t.get_Year();
			systime.wMonth = t.get_Month();
			systime.wDay = t.get_Day();
			systime.wDayOfWeek = t.get_DayOfWeek();
			systime.wHour = t.get_Hour();
			systime.wMinute = t.get_Minute();
			systime.wSecond = t.get_Second();
			systime.wMilliseconds = t.get_Millisecond();
			DateTime_SetSystemtime(GetDlgItem(hwndDlg, IDC_DTP_DATE), GDT_VALID, &systime);
			DateTime_SetSystemtime(GetDlgItem(hwndDlg, IDC_DTP_TIME), GDT_VALID, &systime);

			union {
				struct { SYSTEMTIME rtcMin, rtcMax; };
				SYSTEMTIME rtcMinMax[2];
			};
			ZeroMemory(&rtcMin, sizeof(SYSTEMTIME));
			ZeroMemory(&rtcMax, sizeof(SYSTEMTIME));
			rtcMin.wYear = 2000;
			rtcMin.wMonth = 1;
			rtcMin.wDay = 1;
			rtcMin.wDayOfWeek = 6;
			rtcMax.wYear = 2099;
			rtcMax.wMonth = 12;
			rtcMax.wDay = 31;
			rtcMax.wDayOfWeek = 4;
			DateTime_SetRange(GetDlgItem(hwndDlg, IDC_DTP_DATE), GDTR_MIN, &rtcMinMax);
			DateTime_SetRange(GetDlgItem(hwndDlg, IDC_DTP_DATE), GDTR_MAX, &rtcMinMax);
			return false;
		}

		case WM_COMMAND:
			switch(LOWORD(wParam))
			{
			case IDOK: {
				author = GetDlgItemTextW<500>(hwndDlg,IDC_EDIT_AUTHOR);
				fname = GetDlgItemText<MAX_PATH>(hwndDlg,IDC_EDIT_FILENAME);
				std::string sramfname = GetDlgItemText<MAX_PATH>(hwndDlg,IDC_EDIT_SRAMFILENAME);
				if (fname.length())
				{
					struct tm t;

					DateTime_GetSystemtime(GetDlgItem(hwndDlg, IDC_DTP_DATE), &systime);
					t.tm_year = systime.wYear;
					t.tm_mon  = systime.wMonth;
					t.tm_mday = systime.wDay;
					t.tm_wday = systime.wDayOfWeek;
					DateTime_GetSystemtime(GetDlgItem(hwndDlg, IDC_DTP_TIME), &systime);
					t.tm_hour = systime.wHour;
					t.tm_min  = systime.wMinute;
					t.tm_sec  = systime.wSecond;
					DateTime rtcstart(t.tm_year,t.tm_mon,t.tm_mday,t.tm_hour,t.tm_min,t.tm_sec);

					FCEUI_SaveMovie(fname.c_str(), author, flag, sramfname, rtcstart);
					EndDialog(hwndDlg, 0);
				}
				return true;
			}

			case IDCANCEL:
				EndDialog(hwndDlg, 0);
				return true;
	
			case IDC_BUTTON_BROWSEFILE:
			{
				OPENFILENAME ofn;
				char szChoice[MAX_PATH]={0};
				GetDlgItemText(hwndDlg,IDC_EDIT_FILENAME,szChoice,MAX_PATH);

				// browse button
				ZeroMemory(&ofn, sizeof(ofn));
				ofn.lStructSize = sizeof(ofn);
				ofn.hwndOwner = hwndDlg;
				ofn.lpstrFilter = "Desmume Movie File (*.dsm)\0*.dsm\0All files(*.*)\0*.*\0\0";
				ofn.lpstrFile = szChoice;
				ofn.lpstrTitle = "Record a new movie";
				ofn.lpstrDefExt = "dsm";
				ofn.nMaxFile = MAX_PATH;
				ofn.Flags = OFN_OVERWRITEPROMPT | OFN_NOREADONLYRETURN | OFN_PATHMUSTEXIST;
				if(GetSaveFileName(&ofn))
				{
					fname = szChoice;
/* // windows does this automatically, since lpstrDefExt is set
					//If user did not specify an extension, add .dsm for them
					x = fname.find_last_of(".");
					if (x < 0)
						fname.append(".dsm");
*/
					SetDlgItemText(hwndDlg, IDC_EDIT_FILENAME, fname.c_str());
				}
				//if(GetSaveFileName(&ofn))
				//	UpdateRecordDialogPath(hwndDlg,szChoice);

				return true;
			}
			case IDC_BUTTON_BROWSESRAM:
			{
				OPENFILENAME ofn;
				char szChoice[MAX_PATH]={0};

				// browse button
				ZeroMemory(&ofn, sizeof(ofn));
				ofn.lStructSize = sizeof(ofn);
				ofn.hwndOwner = hwndDlg;
				ofn.lpstrFilter = "Desmume SRAM File (*.dsv)\0*.dsv\0All files(*.*)\0*.*\0\0";
				ofn.lpstrFile = szChoice;
				ofn.lpstrTitle = "Choose SRAM";
				ofn.lpstrDefExt = "dsv";
				ofn.nMaxFile = MAX_PATH;
				ofn.Flags = OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT;
				if(GetOpenFileName(&ofn))
				{
					fname = szChoice;
/* // windows does this automatically, since lpstrDefExt is set
				//If user did not specify an extension, add .dsv for them
				x = fname.find_last_of(".");
				if (x < 0)
					fname.append(".dsv");
*/
					SetDlgItemText(hwndDlg, IDC_EDIT_SRAMFILENAME, fname.c_str());
				}
				//if(GetSaveFileName(&ofn))
				//	UpdateRecordDialogPath(hwndDlg,szChoice);

				return true;
			}

			case IDC_EDIT_FILENAME:
				switch(HIWORD(wParam))
				{
					case EN_CHANGE:
					{
						FixRelativeMovieFilename(hwndDlg, IDC_EDIT_FILENAME);

						// disable the OK button if we can't write to the file
						char filename [MAX_PATH];
						GetDlgItemText(hwndDlg,IDC_EDIT_FILENAME,filename,MAX_PATH);
						EnableWindow(GetDlgItem(hwndDlg, IDOK), IsFileWritable(filename));
					}
					break;
				}
				break;
		}
	}

	HWND cur = GetDlgItem(hwndDlg, IDC_EDIT_SRAMFILENAME);
	
	IsDlgButtonChecked(hwndDlg, IDC_START_FROM_SRAM) ? flag=1 : flag=0;
	IsDlgButtonChecked(hwndDlg, IDC_START_FROM_SRAM) ? EnableWindow(cur, TRUE) : EnableWindow(cur, FALSE);

	cur = GetDlgItem(hwndDlg, IDC_BUTTON_BROWSESRAM);
	IsDlgButtonChecked(hwndDlg, IDC_START_FROM_SRAM) ? EnableWindow(cur, TRUE) : EnableWindow(cur, FALSE);

	return false;
}