Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Create Bitmap from mousemovement in picturebox MFC

Create Bitmap from mousemovement in picturebox MFC

Scheduled Pinned Locked Moved C / C++ / MFC
c++graphicshelptutorialquestion
5 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • J Offline
    J Offline
    josipahutar
    wrote on last edited by
    #1

    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... :|

    A 1 Reply Last reply
    0
    • J josipahutar

      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... :|

      A Offline
      A Offline
      Alain Rist
      wrote on last edited by
      #2

      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)

      J 1 Reply Last reply
      0
      • A Alain Rist

        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)

        J Offline
        J Offline
        josipahutar
        wrote on last edited by
        #3

        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

        D A 2 Replies Last reply
        0
        • J josipahutar

          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

          D Offline
          D Offline
          David Crow
          wrote on last edited by
          #4

          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

          1 Reply Last reply
          0
          • J josipahutar

            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

            A Offline
            A Offline
            Alain Rist
            wrote on last edited by
            #5

            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)

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups