Click here to Skip to main content
16,012,168 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: How to position the controls in a view? Pin
CodeBrain31-Aug-03 21:19
CodeBrain31-Aug-03 21:19 
GeneralRe: How to position the controls in a view? Pin
ben231-Aug-03 21:54
ben231-Aug-03 21:54 
AnswerRe: How to position the controls in a view? Pin
Vitali Halershtein1-Sep-03 0:45
Vitali Halershtein1-Sep-03 0:45 
GeneralCButton !!!!! Pin
Member 42425931-Aug-03 20:27
Member 42425931-Aug-03 20:27 
GeneralRe: CButton !!!!! Pin
Terry O'Nolley31-Aug-03 20:50
Terry O'Nolley31-Aug-03 20:50 
GeneralRe: CButton !!!!! Pin
Member 42425931-Aug-03 22:58
Member 42425931-Aug-03 22:58 
QuestionHow to get yesterdays day using MFC Classes like CTime,COleDateTIme Pin
sarathymail31-Aug-03 20:16
sarathymail31-Aug-03 20:16 
AnswerRe: How to get yesterdays day using MFC Classes like CTime,COleDateTIme Pin
Terry O'Nolley31-Aug-03 20:44
Terry O'Nolley31-Aug-03 20:44 
This function might work (pass it the current day, it returns the int for yesterday):

/* ***************************************** */
/* Parameters:                               */
/*     int nCurrentDay - the current day     */
/*                                           */
/* Returns:                                  */
/*     1-31 representing yesterday's ordinal */
/*     0 for error                           */
/* ***************************************** */
int YourClass::GetYesterday(int nCurrentDay)
{
   // Error check
   if(nCurrentDay < 1) || (nCurrentDay > 31))
      return 0;

   if(nCurrentDay == 1)
   {
      // Get the current month
      int month = COleDateTime::GetMonth();

      // subtract 1 to get last month
      int lastmonth = month - 1;

      // if you are at zero (meaning month is January) then make lastmonth December
      if(!lastmonth)
         lastmonth = 12;

      // since there is a workable number of months and they are unchanging, hardcode the switch
      switch(lastmonth)
      {
         case 4  :
         case 6  :
         case 10 :
         case 11 : return(30);
         break;


         case 1  :
         case 3  :
         case 5  :
         case 7  :
         case 8  :
         case 9  :
         case 12 : return(31);
         break;


         // for February - do leap year processing. See link for algorithm
         case 2  : 
         if((!COleDateTime::GetYear()%4) && ((COleDateTime::GetYear()%100) || (!COleDateTime::GetYear()% 400))) 
            return(29);
         else
            return(28);
      
      }
   }
   else
      return(nCurrentDay--);
}



See http://resurscentrum.nu/members/english/exercises/writing/leap_years.asp[^] for an explanation of the leap year algorithm - I probably wrote it wrong - I didn't check this code Smile | :)








AnswerRe: How to get yesterdays day using MFC Classes like CTime,COleDateTIme Pin
PJ Arends31-Aug-03 21:14
professionalPJ Arends31-Aug-03 21:14 
GeneralRe: How to get yesterdays day using MFC Classes like CTime,COleDateTIme Pin
Terry O'Nolley31-Aug-03 21:20
Terry O'Nolley31-Aug-03 21:20 
GeneralRe: How to get yesterdays day using MFC Classes like CTime,COleDateTIme Pin
PJ Arends31-Aug-03 21:26
professionalPJ Arends31-Aug-03 21:26 
GeneralRe: How to get yesterdays day using MFC Classes like CTime,COleDateTIme Pin
sarathymail1-Sep-03 1:46
sarathymail1-Sep-03 1:46 
AnswerRe: How to get yesterdays day using MFC Classes like CTime,COleDateTIme Pin
YaronNir1-Sep-03 1:15
YaronNir1-Sep-03 1:15 
Questionhow to add tab control to tree view? Pin
ben231-Aug-03 19:19
ben231-Aug-03 19:19 
AnswerRe: how to add tab control to tree view? Pin
ben231-Aug-03 19:57
ben231-Aug-03 19:57 
Generaloptimizd C code Pin
devvvy31-Aug-03 18:57
devvvy31-Aug-03 18:57 
GeneralRe: optimizd C code Pin
Michael Dunn31-Aug-03 19:27
sitebuilderMichael Dunn31-Aug-03 19:27 
GeneralRe: optimizd C code Pin
Joaquín M López Muñoz1-Sep-03 3:13
Joaquín M López Muñoz1-Sep-03 3:13 
GeneralRe: optimizd C code Pin
devvvy1-Sep-03 6:28
devvvy1-Sep-03 6:28 
GeneralRe: optimizd C code Pin
Gary R. Wheeler1-Sep-03 4:46
Gary R. Wheeler1-Sep-03 4:46 
GeneralLaunching program from resources Pin
Ricky Koh31-Aug-03 18:57
Ricky Koh31-Aug-03 18:57 
Generalsampling another apps pixels Pin
7stud31-Aug-03 17:56
7stud31-Aug-03 17:56 
Generalmillisecond time Pin
devvvy31-Aug-03 16:57
devvvy31-Aug-03 16:57 
GeneralRe: millisecond time Pin
PJ Arends31-Aug-03 18:03
professionalPJ Arends31-Aug-03 18:03 
GeneralRe: millisecond time Pin
DougW4831-Aug-03 18:31
DougW4831-Aug-03 18:31 

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.