Solved

Writing into CRichEditView

Posted on 1998-06-06
3
174 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
MFC Dialog 9 54
Whole sheet autoscrub still needed 19 54
SQUD PROXY SERVER, UNIX, SLL/HTTPS 5 133
Problem to open Excel file 15 258
This is to be the first in a series of articles demonstrating the development of a complete windows based application using the MFC classes.  I’ll try to keep each article focused on one (or a couple) of the tasks that one may meet.   Introductio…
Introduction: Finishing the grid – keyboard support for arrow keys to manoeuvre, entering the numbers.  The PreTranslateMessage function is to be used to intercept and respond to keyboard events. Continuing from the fourth article about sudoku. …
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.
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…

739 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