Solved

Writing into CRichEditView

Posted on 1998-06-06
3
169 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

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

Suggested Solutions

If you use Adobe Reader X it is possible you can't open OLE PDF documents in the standard. The reason is the 'save box mode' in adobe reader X. Many people think the protected Mode of adobe reader x is only to stop the write access. But this fe…
Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
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.
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…

708 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

17 Experts available now in Live!

Get 1:1 Help Now