CScrollBar: what's the secret?
-
I've torn out what little hair I have on this. I'm using VS 2005 Beta in case it makes a difference. I create a new Dialog-based MFC App. I put a picture control on it (CStatic with frame style). I align a couple of scrollbars to the frame edge. (I gave up trying to get the inherent CWnd scrollbars to work, but they behave the same.) I try to code behind the scrollbars with calls to: - SetScrollInfo() - EnableScrollBar() - ShowScrollBar() ( slightly different functions are required for the CWnd scrollbars) The effects of SetScrollInfo() can be seen in the thumb size, and the ShowScrollBar() works as expected. But do you think I can actually get the scroll bar to do anything -- let me move the thumb, or trip my breakpoint in the OnVScroll() handler I have waiting to pounce? I can't see the magic secret in any projects I've downloaded. Help!
-
I've torn out what little hair I have on this. I'm using VS 2005 Beta in case it makes a difference. I create a new Dialog-based MFC App. I put a picture control on it (CStatic with frame style). I align a couple of scrollbars to the frame edge. (I gave up trying to get the inherent CWnd scrollbars to work, but they behave the same.) I try to code behind the scrollbars with calls to: - SetScrollInfo() - EnableScrollBar() - ShowScrollBar() ( slightly different functions are required for the CWnd scrollbars) The effects of SetScrollInfo() can be seen in the thumb size, and the ShowScrollBar() works as expected. But do you think I can actually get the scroll bar to do anything -- let me move the thumb, or trip my breakpoint in the OnVScroll() handler I have waiting to pounce? I can't see the magic secret in any projects I've downloaded. Help!
What's more, in the resources, the scrollbars show in a nice Windows XP style. When the app runs, they are flat and ugly. Hmmm. If there is someone out there that can take 5 mins to do this in both VS 2005 Beta and VS 2003, and find that I'm beating my head against a bug in VS 2005 Beta, that would at least be partial relief!
-
I've torn out what little hair I have on this. I'm using VS 2005 Beta in case it makes a difference. I create a new Dialog-based MFC App. I put a picture control on it (CStatic with frame style). I align a couple of scrollbars to the frame edge. (I gave up trying to get the inherent CWnd scrollbars to work, but they behave the same.) I try to code behind the scrollbars with calls to: - SetScrollInfo() - EnableScrollBar() - ShowScrollBar() ( slightly different functions are required for the CWnd scrollbars) The effects of SetScrollInfo() can be seen in the thumb size, and the ShowScrollBar() works as expected. But do you think I can actually get the scroll bar to do anything -- let me move the thumb, or trip my breakpoint in the OnVScroll() handler I have waiting to pounce? I can't see the magic secret in any projects I've downloaded. Help!
Jamaica wrote:
But do you think I can actually get the scroll bar to do anything -- let me move the thumb, or trip my breakpoint in the OnVScroll() handler I have waiting to pounce?
The image is most certainly not going to move by itself, you need to write your OnPaint handler to show the image based on the scroll position, then call Invalidate() when a scroll event fires. You say you've got one, there's obviously a problem with it being hooked up at this point in time, if it's not fired. Christian Graus - Microsoft MVP - C++
-
Jamaica wrote:
But do you think I can actually get the scroll bar to do anything -- let me move the thumb, or trip my breakpoint in the OnVScroll() handler I have waiting to pounce?
The image is most certainly not going to move by itself, you need to write your OnPaint handler to show the image based on the scroll position, then call Invalidate() when a scroll event fires. You say you've got one, there's obviously a problem with it being hooked up at this point in time, if it's not fired. Christian Graus - Microsoft MVP - C++
What you say is all true... but has not advanced my cause :( There certainly is a hidden problem here. I've read the entire CScrollBar documentation several times, satisfied myself (e.g. by calling SetScrollPos()) that the scrollbar is just itching to be useful to me. The main problem appears to be getting any messages to or from it. There are handlers for WM_HSCROLL and WM_VSCROLL in the dialog containing the frame and scrollbars... but they simply don't respond, and nor do the scrollbars themselves. I get the sense I'm going to shoot myself when I discover how simple the answer is....
-
What you say is all true... but has not advanced my cause :( There certainly is a hidden problem here. I've read the entire CScrollBar documentation several times, satisfied myself (e.g. by calling SetScrollPos()) that the scrollbar is just itching to be useful to me. The main problem appears to be getting any messages to or from it. There are handlers for WM_HSCROLL and WM_VSCROLL in the dialog containing the frame and scrollbars... but they simply don't respond, and nor do the scrollbars themselves. I get the sense I'm going to shoot myself when I discover how simple the answer is....
Jamaica wrote:
What you say is all true... but has not advanced my cause
*grin* I'm sorry, without looking at the code, that's about all could offer.
Jamaica wrote:
There are handlers for WM_HSCROLL and WM_VSCROLL in the dialog containing the frame and scrollbars... but they simply don't respond, and nor do the scrollbars themselves.
I have vs2005 final, and I created an MFC app, added a scroll bar and a message handler, and it fired fine. Why don't you create a new app that just does those things and see if it works ? Christian Graus - Microsoft MVP - C++