看了EastDraw和DrawCli都没有相关的部分。我想要的效果是在View中点击了鼠标以后,在View中鼠标点击的地方出现一个闪烁的光标,这时候直接通过键盘输入文字,输入完了,当鼠标点击之,则所有输入的文字作为一个图元被保存和显示。最好能在输入文字的过程中支持回车换行功能!PS:通过对话框中输入文字然后再显示到View中的功能已经实现。故,如果让我那么做的意见就不要提了!如果有相关的程序代码请发到:[email protected]此贴的问题如能解决将送上1000分!以我个人的信誉作为担保!
解决方案 »
- 动态创建的CStatic如何使其自适应文字长度?
- dll数据共享..问题!
- 我编了个程序。有如下警告:但编译没有错误。程序运行的话,程序会不能运行。会是什么原因呢
- 请教,这样实现窗口滚动字幕为什么会不断消耗内存。
- 简单问题,关于VC连接SQL SERVER
- directx连接出错
- 有关资源释放的问题!!!!急救!!!
- 20分不要太好攒啊:vc中如何打开一个access数据库?使用ado
- 那位老兄有票据打印的码子
- 我用VC做了管理和通讯两个程序,我的同事用DELPHI做DCOM来连接这两个程序,结果不知道怎么会事,在VC中不能用这个DCOM
- 请holyeagle(一杯清茶) 接分。
- 终于可以提200分的问题了,高兴ing
首先在文档类中保存点的位置信息和文字信息,然后绘制即可.
//从路径中创建文本区域
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)
CDC* pDC = GetDC();
pDC->TextOut(...);
再扩展一下代码,改变鼠标形状什么的
能说的详细一点吗?
最好能发一个例子程序给我!!!
以前自己写的一段代码,也许对你有帮助
New一个CEdit能看到一个编辑框,看起来不是很好,我需要的是看起来是直接在View中写的效果。to zhaogaojian(米柑年成):
代码拿来参考,谢谢!
能给我完整的Demo程序吗?[email protected]
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);
}
可以给一个完整的程序吗?