Floating control within CView
-
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
-
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
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
-
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
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
-
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
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