R – Scrolling Dialog in MFC on Win CE / Windows Mobile

mfcscrollwindows-cewindows-mobile

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

Best Answer

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);