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. Menubar problem

Menubar problem

Scheduled Pinned Locked Moved C / C++ / MFC
helpc++graphicshardwareperformance
4 Posts 2 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.
  • G Offline
    G Offline
    group7
    wrote on last edited by
    #1

    I use embedded visual c++ to write a video cam software, so that the pocket PC show the screen of the cam. But my menubar does not work.(I tick the top up box) When I click the top up button in menubar, the menubar hangs. But the screen still can show the video. void CGroup7Dlg::OnPreview() { unsigned char *pbuffer = (unsigned char *)malloc(m_PrvWidth * m_PrvHeight * 3); unsigned char *rpbuffer = (unsigned char *)malloc(m_PrvWidth * m_PrvHeight * 3); if ((PreviewFrame((unsigned char*) pbuffer)) == false) AfxMessageBox(_T("Preview Frame Fail!"), MB_OK); Rectify(pbuffer, rpbuffer); //<----- a CBitmap bitmap; bitmap.CreateBitmap(m_PrvWidth, m_PrvHeight, 1, 24, rpbuffer); CVOImage image; RECT pic_rect; m_picture_window.GetWindowRect(&pic_rect); HDC picDC = ::GetDC(m_picture_window.m_hWnd ); CString path_fname; ::WriteBitmapIntoJpegFile(TEXT("\\pic1.jpg"), 80, (HBITMAP)bitmap); UpdateData(true); path_fname ="\\My Documents\\pic1.jpg"; image.Load (picDC ,path_fname ); image.Draw (picDC ,2,13 ); free(pbuffer); pbuffer = NULL; free(rpbuffer); //<-------b rpbuffer = NULL; } There will be out of memory if I comment out line b but menubar works. There will be no problem but the screen pixel is in wrong order of course. I don't know how to fix this bug. Please help...

    A 1 Reply Last reply
    0
    • G group7

      I use embedded visual c++ to write a video cam software, so that the pocket PC show the screen of the cam. But my menubar does not work.(I tick the top up box) When I click the top up button in menubar, the menubar hangs. But the screen still can show the video. void CGroup7Dlg::OnPreview() { unsigned char *pbuffer = (unsigned char *)malloc(m_PrvWidth * m_PrvHeight * 3); unsigned char *rpbuffer = (unsigned char *)malloc(m_PrvWidth * m_PrvHeight * 3); if ((PreviewFrame((unsigned char*) pbuffer)) == false) AfxMessageBox(_T("Preview Frame Fail!"), MB_OK); Rectify(pbuffer, rpbuffer); //<----- a CBitmap bitmap; bitmap.CreateBitmap(m_PrvWidth, m_PrvHeight, 1, 24, rpbuffer); CVOImage image; RECT pic_rect; m_picture_window.GetWindowRect(&pic_rect); HDC picDC = ::GetDC(m_picture_window.m_hWnd ); CString path_fname; ::WriteBitmapIntoJpegFile(TEXT("\\pic1.jpg"), 80, (HBITMAP)bitmap); UpdateData(true); path_fname ="\\My Documents\\pic1.jpg"; image.Load (picDC ,path_fname ); image.Draw (picDC ,2,13 ); free(pbuffer); pbuffer = NULL; free(rpbuffer); //<-------b rpbuffer = NULL; } There will be out of memory if I comment out line b but menubar works. There will be no problem but the screen pixel is in wrong order of course. I don't know how to fix this bug. Please help...

      A Offline
      A Offline
      Anthony_Yio
      wrote on last edited by
      #2

      There will be out of memory if I comment out line b but menubar works There will be a memory leak if you did that. Howabout to set your pbuffer and rbuffer as a member variable? And why don't you use new/delete instead of malloc/free? Sonork 100.41263:Anthony_Yio

      G 1 Reply Last reply
      0
      • A Anthony_Yio

        There will be out of memory if I comment out line b but menubar works There will be a memory leak if you did that. Howabout to set your pbuffer and rbuffer as a member variable? And why don't you use new/delete instead of malloc/free? Sonork 100.41263:Anthony_Yio

        G Offline
        G Offline
        group7
        wrote on last edited by
        #3

        Thank you so much, I have tried your method: unsigned char *pbuffer = new unsigned char[m_PrvWidth * m_PrvHeight* 6]; unsigned char *rpbuffer = new unsigned char[m_PrvWidth * m_PrvHeight* 6]; . . . delete[] pbuffer; delete[] rpbuffer; But, the same problem is still there. And the "out of memory" dialog pop up continuously..........help.........please Do you have any idea?! >_<

        A 1 Reply Last reply
        0
        • G group7

          Thank you so much, I have tried your method: unsigned char *pbuffer = new unsigned char[m_PrvWidth * m_PrvHeight* 6]; unsigned char *rpbuffer = new unsigned char[m_PrvWidth * m_PrvHeight* 6]; . . . delete[] pbuffer; delete[] rpbuffer; But, the same problem is still there. And the "out of memory" dialog pop up continuously..........help.........please Do you have any idea?! >_<

          A Offline
          A Offline
          Anthony_Yio
          wrote on last edited by
          #4

          It could be that there is a memory leak in your program. Try CMemoryState to trace where is it. Sonork 100.41263:Anthony_Yio

          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