This problem occurs when the image scanned is very large. If you use the defaults to scan an A4 page on my HP scanner, you get a 14meg image. This image does not get displayed by the test program, but it can be viewed using paint-brush.
You can reduce the size of the data scanned by modifying the size of the data selected, the pixel type or the resolution. Frame selection is available as a button on the 'Acquire' screen. Pixel type and resolution are modified via attributes (i.e. select ICAP_PIXELTYPE or ICAP_XRESOLUTION with double-click and modify.
When an image is scanned, the scanner user interface is displayed (or at least takes some control of the message queue). This is a separate process from your application. When the scan is complete, the scanner user interface is closed. Windows finds a window to activate in another process.
There are some windows messages passed around e.g. WM_ACTIVATE, which may provide a facility to move the application window to the front. Alternatively, call the scanner from a modal dialog.