看了EastDraw和DrawCli都没有相关的部分。我想要的效果是在View中点击了鼠标以后,在View中鼠标点击的地方出现一个闪烁的光标,这时候直接通过键盘输入文字,输入完了,当鼠标点击之,则所有输入的文字作为一个图元被保存和显示。最好能在输入文字的过程中支持回车换行功能!PS:通过对话框中输入文字然后再显示到View中的功能已经实现。故,如果让我那么做的意见就不要提了!如果有相关的程序代码请发到:[email protected]此贴的问题如能解决将送上1000分!以我个人的信誉作为担保!

解决方案 »

  1.   

    注意是矢量绘图!并不是一个直接再CEditView中写字!
      

  2.   

    矢量绘图可以用Gdi+的GraphicsPath类来实现.
    首先在文档类中保存点的位置信息和文字信息,然后绘制即可.
    //从路径中创建文本区域
    graphics.SetTextRenderingHint(TextRenderingHintAntiAlias);
    graphics.SetSmoothingMode(SmoothingModeAntiAlias);
    FontFamily fontFamily(L"黑体");
    GraphicsPath path;
    path.AddString(L"文字区域东软集团", -1, &fontFamily, FontStyleRegular, 100, Point(0, 0), NULL);
    Pen pen(Color(100, 0, 255, 0),3);
    graphics.DrawPath(&pen, &path);
    graphics.FillPath(&SolidBrush(Color(150, 255, 0, 0)), &path);
    graphics.TranslateTransform(0, 120);
    graphics.FillPath(&SolidBrush(Color(255, 255, 0, 0)), &path)
      

  3.   

    CreateFont
    CDC* pDC = GetDC();
    pDC->TextOut(...);
    再扩展一下代码,改变鼠标形状什么的
      

  4.   

    to  broadoceans(broadoceans) :
    能说的详细一点吗?
    最好能发一个例子程序给我!!!
      

  5.   

    在需要输入的位置new、create一个CEdit,输入完毕后,delete它不就完了。我这样做了n次,当然,也是用于矢量图形和文本的录入。
      

  6.   

    http://community.csdn.net/Expert/topic/3286/3286647.xml?temp=.3797724
    以前自己写的一段代码,也许对你有帮助
      

  7.   

    同意CaptainIII(山上人) 的方法 实现起来也很简单 不过要支持回车就只有自己重载消息了
      

  8.   

    to  CaptainIII(山上人):
    New一个CEdit能看到一个编辑框,看起来不是很好,我需要的是看起来是直接在View中写的效果。to zhaogaojian(米柑年成):
    代码拿来参考,谢谢!
      

  9.   

    to zhaogaojian(米柑年成):
    能给我完整的Demo程序吗?[email protected]
      

  10.   

    创建CEdit时不要框框就行了,偶就是这样的。给你一个这样的:
    IMPLEMENT_DYNAMIC(CHoverRichEdit,CRichEditCtrl)CHoverRichEdit::CHoverRichEdit()
    {
    m_bHover = FALSE;
    m_bTracking = FALSE;
    m_ctrlTip = NULL;
    m_csTip = _T("可直接输入"); m_brushBkgnd.CreateSolidBrush(RGB(192,128,128));
    m_pWndOldFocus = NULL;
    }CHoverRichEdit::~CHoverRichEdit()
    {
    delete m_ctrlTip;
    }
    BEGIN_MESSAGE_MAP(CHoverRichEdit, CRichEditCtrl)
    //{{AFX_MSG_MAP(CHoverRichEdit)
    ON_WM_CREATE()
    ON_WM_MOUSEMOVE()
    ON_MESSAGE(WM_MOUSELEAVE, OnMouseLeave)
    ON_MESSAGE(WM_MOUSEHOVER, OnMouseHover)
    ON_WM_ERASEBKGND()
    ON_WM_SETFOCUS()
    ON_WM_KILLFOCUS()
    ON_WM_RBUTTONDBLCLK()
    //}}AFX_MSG_MAP
    END_MESSAGE_MAP()/////////////////////////////////////////////////////////////////////////////
    // CHoverRichEdit message handlersint CHoverRichEdit::OnCreate(LPCREATESTRUCT lpCreateStruct) 
    {
    if (CRichEditCtrl::OnCreate(lpCreateStruct) == -1)
    return -1;

    // TODO: Add your specialized creation code here
    CHARFORMAT cfm; 
        cfm.cbSize = sizeof(CHARFORMAT); 
        cfm.dwMask = CFM_FACE | CFM_SIZE | CFM_COLOR | CFM_BOLD | CFM_ITALIC | CFM_UNDERLINE | CFM_STRIKEOUT | CFM_PROTECTED | CFM_CHARSET | CFM_OFFSET; 
        cfm.dwEffects = CFE_BOLD; 
        cfm.yHeight = 600;
    cfm.crTextColor = RGB(0,0,0);
        ::lstrcpy(cfm.szFaceName, "宋体");

    SetDefaultCharFormat(cfm); return 0;
    }BOOL CHoverRichEdit::PreTranslateMessage(MSG* pMsg) 
    {
    // TODO: Add your specialized code here and/or call the base class
    if(m_ctrlTip != NULL)
    if(::IsWindow(m_ctrlTip->m_hWnd))
    m_ctrlTip->RelayEvent(pMsg);
    if(pMsg->message == WM_KEYDOWN && pMsg->wParam == VK_RETURN)
    {
    OnKillFocus(m_pWndOldFocus);
    GetParent()->SendMessage(WM_COMMAND,IDM_EDIT_INPUT_HIDE,0);
    } return CRichEditCtrl::PreTranslateMessage(pMsg);
    }void CHoverRichEdit::OnMouseMove(UINT nFlags, CPoint point) 
    {
    // TODO: Add your message handler code here and/or call default
    if (!m_bTracking)
    {
    TRACKMOUSEEVENT tme;
    tme.cbSize = sizeof(tme);
    tme.hwndTrack = m_hWnd;
    tme.dwFlags = TME_LEAVE|TME_HOVER;
    tme.dwHoverTime = 1;
    m_bTracking = _TrackMouseEvent(&tme);
    m_ptLast = point;
    }

    CRichEditCtrl::OnMouseMove(nFlags, point);
    }void CHoverRichEdit::OnMouseHover(WPARAM wparam, LPARAM lparam) 
    {
    // TODO: Add your message handler code here and/or call default
    m_bHover=TRUE;
    /* This line corrects a problem with the tooltips not displaying when 
    the mouse passes over them, if the parent window has not been clicked yet.
    Normally this isn't an issue, but when developing multi-windowed apps, this 
    bug would appear. Setting the ActiveWindow to the parent is a solution to that.
    */
    ::SetActiveWindow(GetParent()->GetSafeHwnd());
    Invalidate();
    DeleteToolTip();
    // Create a new Tooltip with new Button Size and Location
    SetToolTipText(m_csTip);
    if (m_ctrlTip != NULL)
    if (::IsWindow(m_ctrlTip->m_hWnd))
    //Display ToolTip
    m_ctrlTip->Update();
    }
    LRESULT CHoverRichEdit::OnMouseLeave(WPARAM wparam, LPARAM lparam)
    {
    m_bTracking = FALSE;
    m_bHover=FALSE;
    Invalidate();
    return 0;
    }void CHoverRichEdit::DeleteToolTip()
    {
    if(m_ctrlTip != NULL)
    {
    delete m_ctrlTip;
    m_ctrlTip = NULL;
    }
    }void CHoverRichEdit::SetToolTipText(CString csTip, BOOL bActivate)
    {
    // We cannot accept NULL pointer
    if (csTip.IsEmpty()) return; // Initialize ToolTip
    InitToolTip();
    m_csTip = csTip; // If there is no tooltip defined then add it
    if (m_ctrlTip->GetToolCount() == 0)
    {
    CRect rectBtn; 
    GetClientRect(rectBtn);
    m_ctrlTip->AddTool(this, m_csTip, rectBtn, 1);
    } // Set text for tooltip
    m_ctrlTip->UpdateTipText(m_csTip, this, 1);
    m_ctrlTip->Activate(bActivate);
    }void CHoverRichEdit::InitToolTip()
    {
    if (m_ctrlTip == NULL)
    {
    m_ctrlTip = new CToolTipCtrl;
    // Create ToolTip control
    m_ctrlTip->Create(this);
    m_ctrlTip->Activate(TRUE);
    }
    }BOOL CHoverRichEdit::Create(DWORD dwStyle, const RECT& rect, CWnd* pParentWnd) 
    {
    // TODO: Add your specialized code here and/or call the base class return CRichEditCtrl::Create(dwStyle, rect, pParentWnd, 10987);
    }BOOL CHoverRichEdit::OnEraseBkgnd(CDC* pDC) 
    {
    // TODO: Add your message handler code here and/or call default
    CRect rtWnd;
      GetClientRect(&rtWnd);
    rtWnd.InflateRect(1,1,1,1); CPen pen;
    pen.CreatePen(PS_SOLID,1,RGB(255,0,0));  CPen* pOldPen = pDC->SelectObject(&pen);
      pDC->MoveTo(rtWnd.left,rtWnd.top);
    pDC->LineTo(rtWnd.left,rtWnd.bottom);
      pDC->LineTo(rtWnd.right,rtWnd.bottom);
      pDC->LineTo(rtWnd.right,rtWnd.top);
      pDC->LineTo(rtWnd.left,rtWnd.top);
    pDC->SelectObject(pOldPen);
    return TRUE;
    // return CRichEditCtrl::OnEraseBkgnd(pDC);
    }void CHoverRichEdit::OnSetFocus(CWnd* pOldWnd) 
    {
    m_pWndOldFocus = pOldWnd; CRichEditCtrl::OnSetFocus(pOldWnd);

    // TODO: Add your message handler code here
    }void CHoverRichEdit::OnKillFocus(CWnd* pNewWnd) 
    {
      if(m_pWndOldFocus->GetSafeHwnd() != NULL)
      m_pWndOldFocus->SetFocus(); CRichEditCtrl::OnKillFocus(pNewWnd);

    // TODO: Add your message handler code here
    }
    void CHoverRichEdit::OnRButtonDblClk(UINT nFlags, CPoint point) 
    {
    // TODO: Add your message handler code here and/or call default
    CFontDialog dlg;
    if(dlg.DoModal() == IDOK)
    {
    CHARFORMAT cfm;
    dlg.GetCharFormat(cfm);
    cfm.cbSize = sizeof(CHARFORMAT); 
    cfm.dwMask = CFM_FACE | CFM_SIZE | CFM_COLOR | CFM_BOLD | CFM_ITALIC | CFM_UNDERLINE | CFM_STRIKEOUT | CFM_PROTECTED | CFM_CHARSET | CFM_OFFSET; 
    SetDefaultCharFormat(cfm);
    } CRichEditCtrl::OnRButtonDblClk(nFlags, point);
    }
      

  11.   

    to csdn_cht(欣欣兽):
    可以给一个完整的程序吗?