Solved

Writing into CRichEditView

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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
fix34  challenge 9 166
Execute multiple curl cmds with sleep and send output to file 10 114
mapBully challenge 6 177
Is there a simple front-end menu system. 9 121
Introduction: Dynamic window placements and drawing on a form, simple usage of windows registry as a storage place for information. Continuing from the first article about sudoku.  There we have designed the application and put a lot of user int…
Introduction: Dialogs (2) modeless dialog and a worker thread.  Handling data shared between threads.  Recursive functions. Continuing from the tenth article about sudoku.   Last article we worked with a modal dialog to help maintain informat…
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.
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

749 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