Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Native Development

New Contributor
Posts: 6
Registered: ‎09-27-2012
My Device: -
My Carrier: -
Accepted Solution

How to get a handle to screen window using just group id and window id?



We are trying to develop a video application, and we are using ForeignWindowControl to display the video on the screen.


We have those ForeignWindowControl declared and defined in a QML file which is shown as and when required.


Using the CameraAPI, we are able to get the local video displayed correctly on the local video ForiegnWindowControl. For that we are just passing the window group id and window id to camera api and it automatically configures the newly created window by camera API to the position and size defined in the QML file.


However, this does is not the case with remote video. Since there is no method/function similar to camera api's createViewFinder, we have to create a new window ourselves that goes under the group shared by the remote ForeignWindowControl, using screen_create_window_type, and set all the required parameters.


To show the video, we have to manually hard code the position and size of the newly created window so that it matches the position and size of remote ForeignWindowControl in QML file and is displayed properly.


My question is how to find the ForeignWindowControl using just the window group id and window id? the way the cameraAPi does internally?


Any help would be appreciated.


BlackBerry Development Advisor
Posts: 683
Registered: ‎11-29-2011
My Device: PRIV
My Carrier: Rogers

Re: How to get a handle to screen window using just group id and window id?

There are 3 ways to associate a window with a ForeignWindowControl.


1. Tell the ForeignWindowControl to expect a window with a given windowId.  Then after you use libscreen to create your window with the same windowId, use screen_join_window_group() to join it to the same group that the FWC is using.  The FWC should automatically catch that event and associate the window with itself.  This is how the camera does it.


2. invoke ForeignWindowControl's bindToWindow() method to associate the FWC with a particular windowId/groupId.  Similar to #1, but seems more useful if you are creating the FWC after the screen window was created.


3. invoke ForeignWindowControl's setWindowHandle() method.  Similar to #2, but instead of using windowId/groupId, you just pass in the actual handle.


See the FWC docs:



If you created the window yourself, you could use any of these 3 approaches.  If the window was created in a different process (eg. mm-renderer, or camera-service), then usually #1 is the approach you would use.




New Contributor
Posts: 6
Registered: ‎09-27-2012
My Device: -
My Carrier: -

Re: How to get a handle to screen window using just group id and window id?

Hi Sean,


Thanks for the reply. The first option you suggessted worked like a charm Smiley Happy

Am able to position the video correctly inside the FWC from QML.