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. GetWindowOrg fails..my metafile export is not working....

GetWindowOrg fails..my metafile export is not working....

Scheduled Pinned Locked Moved C / C++ / MFC
helpgraphicsdebuggingperformancequestion
1 Posts 1 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.
  • D Offline
    D Offline
    Dimitris Vikeloudas
    wrote on last edited by
    #1

    I have a CScrollView (my private class is U_W_SCROLL_VIEW) and try to draw it invisible to the screen and export the drawn picture into an enhanced metafile. The drawing is not right and I am getting various error or assertion failures in debug mode. Can anyone point me to anything that I might be missing or doing wrong?? Any help welcome. Here is the code AB_BOOL U_W_SCROLL_VIEW::handle_metafile_save(const AB_Text& filename) { AB_Integer handler; MetaNode * pMetaNode; CMetaFileDC * pDCMetaFile; DWORD dwError; CMDIChildWnd* pChildFrame = (CMDIChildWnd*)GetParent(); pChildFrame->ShowWindow(SW_HIDE); // Clear any error given by another thred if( ::GetLastError() ) ::SetLastError(0); OnInitialUpdate(); if( dwError = ::GetLastError() ) goto failed; // Our memory managment. handler = request_create_metafile(); pMetaNode = (MetaNode*)handler.to_long(); pDCMetaFile = pMetaNode->pDCMetafile; // Save the handlers set_export_metafile(handler, filename); OnPrepareDC(pDCMetaFile, NULL); if( dwError = ::GetLastError() ) goto failed; OnDrawn(pDCMetafile); ......................... } void U_W_SCROLL_VIEW::OnInitialUpdate() { TEXTMETRIC tm; CRect clientRect; CClientDC dc(this); m_hDC = dc.GetSafeHdc(); if( abstract_logic->isExporting() ) { dc.SetWindowOrg(0, 0); } // get the size of a line of text CFont* pOldFont = dc.SelectObject(&m_font); dc.GetOutputTextMetrics(&tm); m_sizeLine.cx = tm.tmAveCharWidth; m_sizeLine.cy = tm.tmHeight + tm.tmExternalLeading; dc.SelectObject(pOldFont); // get the size of a page GetClientRect(clientRect); m_sizePage.cx = clientRect.Width(); m_sizePage.cy = clientRect.Height(); // ensure that the page size is always a // multiple of the line size int rem_x = m_sizePage.cx % m_sizeLine.cx; int rem_y = m_sizePage.cy % m_sizeLine.cy; m_sizePage.cx -= rem_x; m_sizePage.cy -= rem_y; // Remove the cursor associated with this window - if we don't do this // Windows will try to reset the cursor every time the mouse moves ::SetClassLong( this->m_hWnd, GCL_HCURSOR, NULL ); // Now set a default arrow cursor for the window m_hDefaultCursor = ::LoadCursor( NULL, IDC_ARROW ); m_hCursor = m_hDefaultCursor; ::SetCursor(m_hCursor); SetScrollSizes( MM_TEXT, m_sizeScroll, m_sizePa

    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