Page 19 - DCAP408_WEB_PROGRAMMING
P. 19
Unit 1: Windows Programming Basics
Notes
Self Assessment
Fill in the blanks:
10. In ........................ function, execution of the program starts and basic program initialization
is performed.
11. A ........................ function is called by Windows to process messages for the application.
1.7 Code and Resources
Resources are defined as the data that you can include to the applications executable file resources
can be:
standard: icon, cursor, menu, dialog box, bitmap, enhanced metafile, font, accelerator
table, message-table entry, string-table entry, or version.
custom: any sort of data that doesn’t fall into the preceding category (for instance a mp3
file or a dictionary database).
Add two new files to your project. Name them resource.h and resource.rc.
!
Caution Resource.rc will enclose the resource definitions and resource.h will define
constants.
This overview focuses on how Windows Presentation Foundation (WPF) resources can be accessed
or created by means of code instead of Extensible Application Markup Language (XAML) syntax.
1.7.1 Accessing Resources from Code
The keys that recognize resources if they are defined during XAML are also used to recover
particular resources if you demand the resource in code. The simplest manner to recover a
resource from code is to call either the FindResource or the TryFindResource method from
framework-level objects in your application. The behavioral dissimilarity between these methods
is what occurs if the needed key is not found. FindResource elevates an exception; TryFindResource
will not raise an exception but returns null.
LOVELY PROFESSIONAL UNIVERSITY 13