Change from fixed client window to scrolling client window
-
Using Visual C++ 6.0 MFC in SDI application. I setup an application using fixed client windows. Now I see that I need to add scrolling to the client windows for my drawing. I don't understand what and where exactly needs to change now. Thanks
-
Using Visual C++ 6.0 MFC in SDI application. I setup an application using fixed client windows. Now I see that I need to add scrolling to the client windows for my drawing. I don't understand what and where exactly needs to change now. Thanks
One possibility (the more obvious) is to add a ScrollBar to your view and the implement all the other things by yourself. Other possibility is to have two different views attached (although it is SDI) to your application, one "normal" view, as you have and another one derived from CScrollView, it will already have almost all the functionality that you need for your scrolling implemented. And another one, is to choose the CScrollView as parent of your main view from the beggining when you create your application and then change the size of the view dinamically according to your needs. If the size of the view is smaller than your window, the scroll will automatically disabled.
Greetings. -------- M.D.V. ;) If something has a solution... Why do we have to worry about?. If it has no solution... For what reason do we have to worry about? Help me to understand what I'm saying, and I'll explain it better to you “The First Rule of Program Optimization: Don't do it. The Second Rule of Program Optimization (for experts only!): Don't do it yet.” - Michael A. Jackson Rating helpfull answers is nice, but saying thanks can be even nicer.
-
One possibility (the more obvious) is to add a ScrollBar to your view and the implement all the other things by yourself. Other possibility is to have two different views attached (although it is SDI) to your application, one "normal" view, as you have and another one derived from CScrollView, it will already have almost all the functionality that you need for your scrolling implemented. And another one, is to choose the CScrollView as parent of your main view from the beggining when you create your application and then change the size of the view dinamically according to your needs. If the size of the view is smaller than your window, the scroll will automatically disabled.
Greetings. -------- M.D.V. ;) If something has a solution... Why do we have to worry about?. If it has no solution... For what reason do we have to worry about? Help me to understand what I'm saying, and I'll explain it better to you “The First Rule of Program Optimization: Don't do it. The Second Rule of Program Optimization (for experts only!): Don't do it yet.” - Michael A. Jackson Rating helpfull answers is nice, but saying thanks can be even nicer.
I tried changing things but there is one area of the code that I don't understand. I have two views that I switch between. void CMainFrame::CreateActivateView(CRuntimeClass *pNewViewClass, UINT nID) { CView* pOldView = GetActiveView(); CView* pNewView = NULL; // plus code to switch between views. } But when I try to Change the class to CScrolView I cannot compile the line CScrollView* pOldView = GetActiveView(); But I don't understand how to change that from CView* to CScrollView* Thanks
-
I tried changing things but there is one area of the code that I don't understand. I have two views that I switch between. void CMainFrame::CreateActivateView(CRuntimeClass *pNewViewClass, UINT nID) { CView* pOldView = GetActiveView(); CView* pNewView = NULL; // plus code to switch between views. } But when I try to Change the class to CScrolView I cannot compile the line CScrollView* pOldView = GetActiveView(); But I don't understand how to change that from CView* to CScrollView* Thanks
Try casting: CScrollView* pOldView = (CScrollView*) GetActiveView (); Hope it helps
Greetings. -------- M.D.V. ;) If something has a solution... Why do we have to worry about?. If it has no solution... For what reason do we have to worry about? Help me to understand what I'm saying, and I'll explain it better to you “The First Rule of Program Optimization: Don't do it. The Second Rule of Program Optimization (for experts only!): Don't do it yet.” - Michael A. Jackson Rating helpfull answers is nice, but saying thanks can be even nicer.