Solved

Writing into CRichEditView

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

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
dog bark java program 15 109
countEvens challenge 2 112
twoTwo  challenge 35 107
Problem to event 3 102
Introduction: The undo support, implementing a stack. Continuing from the eigth article about sudoku.   We need a mechanism to keep track of the digits entered so as to implement an undo mechanism.  This should be a ‘Last In First Out’ collec…
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.
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…

829 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