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. Other Discussions
  3. Article Writing
  4. Floating control within CView

Floating control within CView

Scheduled Pinned Locked Moved Article Writing
business
4 Posts 2 Posters 3 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.
  • F Offline
    F Offline
    ferdz
    wrote on last edited by
    #1

    How about a non-dockable control bar child of CView. I have an mapping application that needs a scale bar floating within the CScrollView client area. I tried experimenting with owner-drawn CButton but it scrolls too when the client area is scrolled! I also tried CControlBar and successfully restricted its dragging within the client area. But if we move the mainframe, ugh!! And it is always top window. So if we open several documents or views the control bars are sprawled all over!!! Requirements: 1. Non-docking 2. Can be dragged around client area but... 3. always stays within the client area 4. Preferably sticky on client edges 5. Moves when the childframe is moved 6. Not top-most window

    R 1 Reply Last reply
    0
    • F ferdz

      How about a non-dockable control bar child of CView. I have an mapping application that needs a scale bar floating within the CScrollView client area. I tried experimenting with owner-drawn CButton but it scrolls too when the client area is scrolled! I also tried CControlBar and successfully restricted its dragging within the client area. But if we move the mainframe, ugh!! And it is always top window. So if we open several documents or views the control bars are sprawled all over!!! Requirements: 1. Non-docking 2. Can be dragged around client area but... 3. always stays within the client area 4. Preferably sticky on client edges 5. Moves when the childframe is moved 6. Not top-most window

      R Offline
      R Offline
      Ray Hayes
      wrote on last edited by
      #2

      This really doesn't sound hard. My approach would be to make a standard child-window (of the view-frame). By being a child it will float above the view. Handle the WM_GETMINMAX handle to contain any movement to the view->GetClientRect [any coord tweaks necessary]. In the same handler you can weight positioning of the window when reaching the edges. You would also have to update the position of the window when its parent moves. A few dozen lines of code at most! Ray

      F 1 Reply Last reply
      0
      • R Ray Hayes

        This really doesn't sound hard. My approach would be to make a standard child-window (of the view-frame). By being a child it will float above the view. Handle the WM_GETMINMAX handle to contain any movement to the view->GetClientRect [any coord tweaks necessary]. In the same handler you can weight positioning of the window when reaching the edges. You would also have to update the position of the window when its parent moves. A few dozen lines of code at most! Ray

        F Offline
        F Offline
        ferdz
        wrote on last edited by
        #3

        Thank you for your idea. It works. This is very similar to my first approach which used a CButton. It is really not hard. But I have a slight problem - I get ugly flickers when I scroll the View. This is because of my desire the keep the control in the same position during scroll. So after every scroll, I have to MoveWindow. (That's why I tried before on WS_POPUP styles/control bars - I wanted the scrolls not affect the position of the control.) Any ideas? Thanx in advance. Ferdz

        R 1 Reply Last reply
        0
        • F ferdz

          Thank you for your idea. It works. This is very similar to my first approach which used a CButton. It is really not hard. But I have a slight problem - I get ugly flickers when I scroll the View. This is because of my desire the keep the control in the same position during scroll. So after every scroll, I have to MoveWindow. (That's why I tried before on WS_POPUP styles/control bars - I wanted the scrolls not affect the position of the control.) Any ideas? Thanx in advance. Ferdz

          R Offline
          R Offline
          Ray Hayes
          wrote on last edited by
          #4

          I don't really use the Doc/View system, but if I understand correctly, you are making the control a child of the view rather than a child of the "frame". If the control is a child of the frame, it will not be repositioned when the view is scrolled (it is a sibling rather than a child of the view). Ray

          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