Click here to Skip to main content
15,895,462 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
QuestionRe: How to change day with button click. Pin
Rajesh R Subramanian10-Mar-08 22:58
professionalRajesh R Subramanian10-Mar-08 22:58 
GeneralRe: How to change day with button click. Pin
Ashish Chauhan10-Mar-08 23:09
Ashish Chauhan10-Mar-08 23:09 
QuestionRe: How to change day with button click. Pin
Rajesh R Subramanian10-Mar-08 23:23
professionalRajesh R Subramanian10-Mar-08 23:23 
GeneralRe: How to change day with button click. Pin
Ashish Chauhan10-Mar-08 23:24
Ashish Chauhan10-Mar-08 23:24 
QuestionRe: How to change day with button click. Pin
Rajesh R Subramanian11-Mar-08 0:09
professionalRajesh R Subramanian11-Mar-08 0:09 
GeneralRe: How to change day with button click. Pin
Ashish Chauhan11-Mar-08 1:38
Ashish Chauhan11-Mar-08 1:38 
GeneralRe: How to change day with button click. [modified] Pin
Ashish Chauhan11-Mar-08 2:38
Ashish Chauhan11-Mar-08 2:38 
AnswerRe: How to change day with button click. Pin
Rajesh R Subramanian11-Mar-08 9:57
professionalRajesh R Subramanian11-Mar-08 9:57 
Please try this code and tell me if it helped.
//Thanks to Rehen, as I'm using a portion of his idea here.
//Function which will find the next day of the week
void NextDayOfWeek(const SYSTEMTIME& st, SYSTEMTIME *calculatedTime)
{
     FILETIME ft;
     
    //convert system time to file time
     SystemTimeToFileTime(&st, &ft);
    
     ULARGE_INTEGER nenoSeconds, nenoseconds_in_a_day;;
     
     nenoseconds_in_a_day.QuadPart = 24*60*60*1000;
     nenoseconds_in_a_day.QuadPart *= 10000;
     nenoSeconds.HighPart= ft.dwHighDateTime;
     nenoSeconds.LowPart= ft.dwLowDateTime;

     //Increment one day
     nenoSeconds.QuadPart += nenoseconds_in_a_day.QuadPart;

     ft.dwHighDateTime = nenoSeconds.HighPart;
     ft.dwLowDateTime = nenoSeconds.LowPart;


     //convert it back to system time
     FileTimeToSystemTime(&ft, calculatedTime);
}


case IDC_BUTTON1:
{
	SYSTEMTIME myTime, ans;
	HWND hdt;
	
	GetDlgItem(IDC_DATETIMEPICKER6, &hdt);

	//put your code to format the string here!       

	//Get the info stored in the CDateTimeCtrl and store it at &myTime.
        if(DateTime_GetSystemtime(hdt, &myTime) == GDT_VALID)
	{
		//Call the function, which will calculate and store the next day of week at &ans.
		NextDayOfWeek(myTime, &ans);
		
		//send a message to the control to set the system time from &ans!
		::SendMessage(hdt, (UINT)DTM_SETSYSTEMTIME, (WPARAM)(DWORD)GDT_VALID, (LPARAM)(LPSYSTEMTIME)&ans);

	}
}

I'd also suggest you read a little bit about FILETIME on MSDN.


Nobody can give you wiser advice than yourself. - Cicero
.·´¯`·->Rajesh<-·´¯`·.
Codeproject.com: Visual C++ MVP

GeneralRe: How to change day with button click. Pin
Ashish Chauhan11-Mar-08 21:09
Ashish Chauhan11-Mar-08 21:09 
AnswerRe: How to change day with button click. Pin
Rajesh R Subramanian11-Mar-08 21:55
professionalRajesh R Subramanian11-Mar-08 21:55 
GeneralRe: How to change day with button click. Pin
Ashish Chauhan11-Mar-08 22:43
Ashish Chauhan11-Mar-08 22:43 
GeneralRe: How to change day with button click. Pin
Rajesh R Subramanian11-Mar-08 23:21
professionalRajesh R Subramanian11-Mar-08 23:21 
GeneralRe: How to change day with button click. Pin
Ashish Chauhan11-Mar-08 23:30
Ashish Chauhan11-Mar-08 23:30 
GeneralRe: How to change day with button click. Pin
Ashish Chauhan11-Mar-08 23:33
Ashish Chauhan11-Mar-08 23:33 
GeneralRe: How to change day with button click. Pin
Rajesh R Subramanian11-Mar-08 23:41
professionalRajesh R Subramanian11-Mar-08 23:41 
AnswerRe: How to change day with button click. Pin
Rajesh R Subramanian12-Mar-08 0:05
professionalRajesh R Subramanian12-Mar-08 0:05 
GeneralRe: How to change day with button click. Pin
Ashish Chauhan12-Mar-08 0:58
Ashish Chauhan12-Mar-08 0:58 
GeneralRe: How to change day with button click. Pin
Rajesh R Subramanian11-Mar-08 4:31
professionalRajesh R Subramanian11-Mar-08 4:31 
QuestionQuestion about how to kill thread that i create with _beginthreadex ? Pin
Yanshof10-Mar-08 20:35
Yanshof10-Mar-08 20:35 
AnswerRe: Question about how to kill thread that i create with _beginthreadex ? Pin
Maxwell Chen10-Mar-08 20:40
Maxwell Chen10-Mar-08 20:40 
AnswerRe: Question about how to kill thread that i create with _beginthreadex ? Pin
Peter Weyzen10-Mar-08 20:41
Peter Weyzen10-Mar-08 20:41 
GeneralRe: Question about how to kill thread that i create with _beginthreadex ? [modified] Pin
Yanshof10-Mar-08 21:15
Yanshof10-Mar-08 21:15 
GeneralRe: Question about how to kill thread that i create with _beginthreadex ? Pin
Cedric Moonen10-Mar-08 21:33
Cedric Moonen10-Mar-08 21:33 
GeneralRe: Question about how to kill thread that i create with _beginthreadex ? Pin
Yanshof10-Mar-08 21:39
Yanshof10-Mar-08 21:39 
GeneralRe: Question about how to kill thread that i create with _beginthreadex ? Pin
Peter Weyzen10-Mar-08 21:54
Peter Weyzen10-Mar-08 21:54 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.