Page 22 - DCAP408_WEB_PROGRAMMING
P. 22

Windows Programming




                    Notes          Using Resource Files

                                   To load a resource file, you can call the GetResourceStream method of the Application class,
                                   passing  a pack  URI that  identifies  the  desired  resource  file.GetResourceStream  returns  a
                                   StreamResourceInfo object, which exposes the resource file as a Stream and describes its content
                                   type.
                                   As an example, the following code shows how to use GetResourceStream to load a Page resource
                                   file and set it as the content of a Frame (pageFrame):

















                                   While  calling GetResourceStream gives you  access to  the Stream,  you need to perform the
                                   additional work of converting it to the type of the property that you'll be setting it with. Instead,
                                   you can let WPF take care  of opening and converting the Stream  by loading  a resource file
                                   directly into the property of a type using code.

                                   Self Assessment


                                   Fill in the blanks:
                                   12.  ........................ are defined as the data that you can include to the applications executable
                                       file.

                                   13.  The simplest manner to recover a resource from code is to call either the ........................ or
                                       the TryFindResource method from framework-level objects in your application.

                                   1.8 Program Instances

                                   A window is considered as parent when it can be used to host, hold, or take other windows. For
                                   instance, when the computer begins, it draws its main screen, also known as the desktop, which
                                   covers the widest area that the monitor screen can propose. This primary window turns out to be
                                   the host of all other window that will exhibit as long as the computer is own. This desktop is also
                                   a complete window in its own right. As declared already, to get its handle, you can call the
                                   GetDesktopWindow() function.
                                   After the desktop has been generated, a window of yours can display if the user begins your
                                   application. This signifies that an application must have been generated for the user to use it.
                                   When the user opens an application, we also say that the application has been instantiated or an
                                   instance of the application has been generated. Depending on this, any time you generate an
                                   application, you must offer an instance of it. This permits the operating system to handle your
                                   application with respect to its communication with the user and also its relationship with other
                                   resources. Thus, you must always generate an instance for your application. This is taken care of
                                   by the first argument of the WinMain() function.





          16                                LOVELY PROFESSIONAL UNIVERSITY
   17   18   19   20   21   22   23   24   25   26   27