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. Moving a single control in on HScroll in a CScrollView class

Moving a single control in on HScroll in a CScrollView class

Scheduled Pinned Locked Moved C / C++ / MFC
question
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.
  • V Offline
    V Offline
    VanHlebar
    wrote on last edited by
    #1

    I need to move just a single control in my view to keep it centered on the screen. I have tried overriding the OnHScroll() and adding code to MoveWindow() for my control to move it. I can't seem to keep it visible. Here is the code sample: void CMYView::OnHScroll(UINT nSBCode, UINT nPos, CScrollBar *pScrollBar) { CRect r; int nNewCalPos; if(pScrollBar) return; //should be NULL; switch(nSBCode) { case SB_LINERIGHT: m_nHPos += 204; if(m_nHPos > m_nMaxRange) { m_nHPos = m_nMaxRange; nNewCalPos = m_nMaxRange - 204; } break; case SB_LINELEFT: m_nHPos -= 204; if(m_nHPos < 0) { m_nHPos = 0; nNewCalPos = 150; } break; } CScrollView::OnHScroll(nSBCode, nPos, pScrollBar); //Size the control m_cCalanderCtrl.GetMinReqRect(&r); m_cCalanderCtrl.MoveWindow(nNewCalPos, 0, ((r.right * 4) + 20), r.bottom, TRUE); } Any ideas? Thanks, -Eric

    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