views:

618

answers:

2

Hi,

I'm building a dialog based Windows Mobile application. My main container dialog has a tab control which alternates between different child dialogs (as separate tab sheets).

As I have limited display real-estate I need my dialogs to scroll vertically. Following some online example, I added a vertical scroll bar, and the appropriate message and handler to deal with vertical scrolling.

The scroll bar itself behaves perfectly, changing it's position when I click on it or drag it. My dialog however remains static and doesn't scroll.

To isolate the problem, I modified the scroll message handler and hard-coded a ScrollWindow() command whenever a scroll occurs, like so:

void SettingsDialog::OnVScroll(UINT nSBCode, 
    UINT nPos, CScrollBar* pScrollBar)
{
    ScrollWindow(0,30,NULL,NULL);
}

The code is reached, but still no scrolling occurs in my dialog. Can anyone shed some light on this mystery?

By the way, i've found a thread on Coding Guru which discusses the exact same problem, but has not been resolved here: http://www.codeguru.com/forum/showthread.php?t=54304

+3  A: 

I've run across the same problem. I never use MFC, but the Win32 function to make it work correctly is this:

         ScrollWindowEx(hDlg, 0, currentPos - si.nPos, NULL, NULL, NULL, NULL, SW_SCROLLCHILDREN | SW_INVALIDATE);
BitBank
This solved my problem.I still have no clue why the regular ScrollWindow call fails, but at this point, I couldn't care less... :)Thanks!
LeChuck2k
+1  A: 

MSDN says this... !

Note The ScrollWindow function is provided for backward compatibility. New applications should use the ScrollWindowEx function.

http://msdn.microsoft.com/en-us/library/bb787591%28VS.85%29.aspx