Create a child window

You can use the screen_create_window_type() function to create a child window.

To create a child window:

  1. Create a variable for each of the context and window instances.
    screen_context_t screen_context = 0;
    screen_window_t  screen_child_window = 0;
  2. Create a context. The context describes the relationship between the application and the underlying windowing system.
    screen_create_context(&screen_context, SCREEN_APPLICATION_CONTEXT);
  3. Create a child window. The screen_create_window_type() function takes the window and context variables and an integer representing the window type. In this case, the window is of type SCREEN_CHILD_WINDOW.
    int wintype = SCREEN_CHILD_WINDOW;
  4. Join a window group. The window_group_name must be the name of the window group created by the parent (or main) window through the screen_create_window_group() function.
    screen_join_window_group(screen_child_window, window_group_name);

Although any instances created are destroyed when the application exits, it is best practice to destroy any window and context instances that you created but no longer require. In some cases you must destroy windows and contexts. For example, when an app outlasts the lifespan of contexts and windows without destroying the process, then you must call the appropriate destroy functions.

In this example, you should destroy the window and the context once you have finished using them.


Last modified: 2015-03-31

Got questions about leaving a comment? Get answers from our Disqus FAQ.

comments powered by Disqus