Create Bitmap from mousemovement in picturebox MFC
-
hi guys,,, i'm have a project about MFC. how to create bitmap from mousemovent?? for mousemovent i'm can write to picturebox. the code is written in mfc wizard exe in a dialog based application. for picturebox -> IDC_PIC for button -> IDC_SAVE my code: void CSignature1Dlg::OnMouseMove(UINT nFlags, CPoint point) { // TODO: Add your message handler code here and/or call default m_pic1.GetSafeHwnd(); HCURSOR hcur = NULL; CRect rc; m_pic1.GetClientRect(&rc); rc.NormalizeRect(); rc.left=0; rc.right=250; rc.top=0; rc.bottom=250; POINT MousePosition = point; BOOL isOnPictureControl = PtInRect(&rc, MousePosition); if((m_iPrevX >=rc.left && m_iPrevX <=rc.right) && (m_iPrevY >=rc.top && m_iPrevY <=rc.bottom )){ if((nFlags & MK_LBUTTON) == MK_LBUTTON) { CDC* pDC = m_pic1.GetDC(); CDC dcMem; dcMem.CreateCompatibleDC(pDC); dcMem.SelectObject(&m_bmpBitmap); CPen pen (PS_SOLID,2,RGB(0,0,0)); pDC->SelectObject (&pen); pDC->MoveTo(m_iPrevX,m_iPrevY); pDC->LineTo(point.x,point.y); pDC->SetPixel(point.x,point.y, RGB(0,0,0)) ; m_iPrevX=point.x; m_iPrevY=point.y; } } CDialog::OnMouseMove(nFlags, point); } void CSignature1Dlg::OnLButtonDown(UINT nFlags, CPoint point) { // TODO: Add your message handler code here and/or call default HCURSOR hcur = NULL; CRect rc; m_pic1.GetClientRect(&rc); rc.NormalizeRect(); m_iPrevX=point.x; m_iPrevY=point.y; CDialog::OnLButtonDown(nFlags, point); } void CSignature1Dlg::OnSave() { // TODO: Add your control notification handler code here ????????? } so give me advice, how to can create and save the mousemovent into bitmap??? :confused: i hope u can help me... :|
-
hi guys,,, i'm have a project about MFC. how to create bitmap from mousemovent?? for mousemovent i'm can write to picturebox. the code is written in mfc wizard exe in a dialog based application. for picturebox -> IDC_PIC for button -> IDC_SAVE my code: void CSignature1Dlg::OnMouseMove(UINT nFlags, CPoint point) { // TODO: Add your message handler code here and/or call default m_pic1.GetSafeHwnd(); HCURSOR hcur = NULL; CRect rc; m_pic1.GetClientRect(&rc); rc.NormalizeRect(); rc.left=0; rc.right=250; rc.top=0; rc.bottom=250; POINT MousePosition = point; BOOL isOnPictureControl = PtInRect(&rc, MousePosition); if((m_iPrevX >=rc.left && m_iPrevX <=rc.right) && (m_iPrevY >=rc.top && m_iPrevY <=rc.bottom )){ if((nFlags & MK_LBUTTON) == MK_LBUTTON) { CDC* pDC = m_pic1.GetDC(); CDC dcMem; dcMem.CreateCompatibleDC(pDC); dcMem.SelectObject(&m_bmpBitmap); CPen pen (PS_SOLID,2,RGB(0,0,0)); pDC->SelectObject (&pen); pDC->MoveTo(m_iPrevX,m_iPrevY); pDC->LineTo(point.x,point.y); pDC->SetPixel(point.x,point.y, RGB(0,0,0)) ; m_iPrevX=point.x; m_iPrevY=point.y; } } CDialog::OnMouseMove(nFlags, point); } void CSignature1Dlg::OnLButtonDown(UINT nFlags, CPoint point) { // TODO: Add your message handler code here and/or call default HCURSOR hcur = NULL; CRect rc; m_pic1.GetClientRect(&rc); rc.NormalizeRect(); m_iPrevX=point.x; m_iPrevY=point.y; CDialog::OnLButtonDown(nFlags, point); } void CSignature1Dlg::OnSave() { // TODO: Add your control notification handler code here ????????? } so give me advice, how to can create and save the mousemovent into bitmap??? :confused: i hope u can help me... :|
josipahutar wrote:
so give me advice, how to can create and save the mousemovent into bitmap???
See the Scribble MFC sample[^]. cheers, AR
When the wise (person) points at the moon the fool looks at the finger (Chinese proverb)
-
josipahutar wrote:
so give me advice, how to can create and save the mousemovent into bitmap???
See the Scribble MFC sample[^]. cheers, AR
When the wise (person) points at the moon the fool looks at the finger (Chinese proverb)
thx your reply sir.. i dont understand because i newbie in MFC.. :confused: so can u give me a example about my problem... Regard's Johannes
-
thx your reply sir.. i dont understand because i newbie in MFC.. :confused: so can u give me a example about my problem... Regard's Johannes
josipahutar wrote:
so can u give me a example about my problem...
This MFC tutorial gives a little bit of everything, even for newbies.
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"Man who follows car will be exhausted." - Confucius
-
thx your reply sir.. i dont understand because i newbie in MFC.. :confused: so can u give me a example about my problem... Regard's Johannes
Hi, The example is the
CScribbleView
class code for:virtual void OnDraw(CDC\* pDC); // overridden to draw this view afx\_msg void OnLButtonDown(UINT nFlags, CPoint point); afx\_msg void OnLButtonUp(UINT nFlags, CPoint point); afx\_msg void OnMouseMove(UINT nFlags, CPoint point);
. If you cannot study this code and understand how it is an answer to your question think of another kind of working area ;) cheers, AR
When the wise (person) points at the moon the fool looks at the finger (Chinese proverb)