Solved

Writing into CRichEditView

Posted on 1998-06-06
3
170 Views
Last Modified: 2013-11-19
Im using CRichEditView as my base class and I have a menu popup (Insert\Date) that when click on should write the date in the CRichEditView, how do I do this?
0
Comment
Question by:VisualLR
  • 2
3 Comments
 

Accepted Solution

by:
midthune earned 50 total points
ID: 1316112
void CMyAppView::OnMenuTime()
{
    bool pm = FALSE;
    CString Output;
    int hour, minute;

    COleDateTime time;
    time = COleDateTime::GetCurrentTime();
    hour = time.GetHour();
    minute = time.GetMinute();

    if (hour  > 11)
        pm = TRUE;
    if (hour == 0)
        hour = 12;
    if (hour > 12)
        hour -= 12;
    if (minute < 10)
        Output.Format("<
3A0
", hour, minute);
    else
        Output.Format("<
3A
", hour, minute);
    if (pm)
        Output += "pm>";
    else
        Output += "am>";

    ReplaceSel(Output, TRUE);
}

If you want military-style time it's easier...

void CMyAppView::OnMenuTime()
{
    CString Output, Temp;
    int hour, minute;

    COleDateTime time;
    time = COleDateTime::GetCurrentTime();

    hour = time.GetHour();
    minute = time.GetMinute();
   
    if (hour < 10)  
        Output.Format("0
3A");
    else Output.Format("
3A");
   
    if (minute < 10)
        Temp.Format("0
22);
    else Temp.Format("
22);

    Output += Temp;

    ReplaceSel(Output, TRUE);
}



0
 

Expert Comment

by:midthune
ID: 1316113
Due to the nature of this message board, my percent signs in .Format had a weird effect... 3A should be replaced with (PERCENTSIGN)d: and 22 with (PERCENTSIGN)d
    May I point out a bug in this site's scripting? :^p>
    Are we expected to code in C and HTML at the same time?
0
 

Author Comment

by:VisualLR
ID: 1316114
Thanks. That'll work :)
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Need a Shell script to start a service checking the port 6 48
repeatEnd java challenge 42 84
Strange date stored 22 106
How to know only "File created" with EventLog 3 32
Introduction: Hints for the grid button.  Nested classes, templated collections.  Squash that darned bug! Continuing from the sixth article about sudoku.   Open the project in visual studio. First we will finish with the SUD_SETVALUE messa…
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.

911 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now