I am writing a simple application on the BB10 simulator to capture the contents of an invoke preview window (which contains a scrollable view for emails). I want to capture the entire scrollview of the invoked window/email, not just what's on screen. In the code below, I can get a handle to the Window for the entire application and screen_read_window its contents, but how do I iterate over the invoke window's controls and find the handle to the scrollview, and capture that?
InvokeRequest request;
// Set the target app
request.setTarget("sys.pim.uib.email.previewer");
// Set the action that the target app should execute
request.setAction("bb.action.VIEW");
// Set the MIME type of the data
request.setMimeType("message/rfc822");
// Specify the location of the data
request.setUri(QUrl("pim:message/rfc822:" + QString::number(accountId) + ":" + QString::number(messageId)));
//InvokeTargetReply *reply =
invokeManager->invoke(request);
sleep(2);
screen_context_t screenshot_ctx = 0;
if (screen_create_context(&screenshot_ctx,
SCREEN_APPLICATION_CONTEXT) != 0) {
return;
}
screen_pixmap_t screen_pix;
screen_buffer_t screenshot_buf;
char *screenshot_ptr = NULL;
int screenshot_stride = 0;
int usage, format;
int size[2];
screen_create_pixmap(&screen_pix, screenshot_ctx);
usage = SCREEN_USAGE_READ | SCREEN_USAGE_NATIVE;
screen_set_pixmap_property_iv(screen_pix, SCREEN_PROPERTY_USAGE, &usage);
format = SCREEN_FORMAT_RGBA8888;
screen_set_pixmap_property_iv(screen_pix, SCREEN_PROPERTY_FORMAT, &format);
size[0] = 768;
size[1] = 1280;
screen_set_pixmap_property_iv(screen_pix, SCREEN_PROPERTY_BUFFER_SIZE, size);
screen_create_pixmap_buffer(screen_pix);
screen_get_pixmap_property_pv(screen_pix, SCREEN_PROPERTY_RENDER_BUFFERS,
(void**)&screenshot_buf);
screen_get_buffer_property_pv(screenshot_buf, SCREEN_PROPERTY_POINTER,
(void**)&screenshot_ptr);
screen_get_buffer_property_iv(screenshot_buf, SCREEN_PROPERTY_STRIDE,
&screenshot_stride);
screen_read_window(Application::instance()->mainWindow()->handle(), screenshot_buf, 0, NULL ,0);
QByteArray array;
int nbytes = size[0] * size[1] * 4;
write_bitmap_header(nbytes, array, size);
for (int i = 0; i < size[1]; i++)
{
array.append(screenshot_ptr + i * screenshot_stride, size[0] * 4);
}
QImage image = QImage::fromData(array, "BMP");
QFile outFile("shared/photos/temp1.jpeg");
outFile.open(QIODevice::WriteOnly);
image.save(&outFile, "JPEG");
//Close Email
invokeManager->closeChildCard();