This file briefly documents what the demo programs do, their objectives, etc. To check-out the demos, compile them, link, run, etc., you must first have the TWindowImage component installed into the Delphi development environment. If you have not already done so, you need to install the component before attempting to use the demo programs. Installation instructions, should they be needed, are contained in the file: install.txt. If you need further assistance with installation procedures, please consult the Delphi documentation on installing components. To reduce the size of this total package, no executables are included. Hence, to check-out the demo programs, you need to compile and link them to re-generate the executables for your testing purposes. The executables can always be regenerated from the source code, so they were excluded from the released package to reduce upload/download transmission time and reduce the storage space required in software libraries, etc. When tinkering around, checking out how the component works, don't change the demo program code and/or component properties. This documentation is valid for the demo programs as they existed when developed by the author. To tinker with the source code and/or component properties, please do so in some other test program, be it simply a copy of a demo program, or an entirely different program of your own design. If you don't change the demo programs themselves, then if you contact the author with problems we will be "on common ground", so-to-speak. The demo programs are enumerated according to the order of complexity of each. DEMO1 is the simplest, DEMO2 builds a bit on the capabilities shown by DEMO1, DEMO3 builds a bit more, etc. This allows a developer to choose where he/she begins, difficulty-wise. Please keep in mind that the demo programs are for example uses only, and do not contain error checking/trapping code, code optimizations, or many in-line comments. Last, as the other text documentation also states, the words "TWindowImage Demo" are inserted into the center of captured images (demo version only, registered version does not insert this text). Thus, if you see something that looks odd in the center of captured images, this explains what it is. Depending on the size of the displayed image in your test programs, you might or might not be able to actually read this text. DEMO1 - Uses the TWindowImage component to capture and display images of: the active window, the active window client area, and the entire/full display screen. DEMO1 images captured do stretch the images to fit the controls, but no code is present to preserve the proper aspect-ratios. The images are captured when the user clicks the "Refresh" button. DEMO2 - Works just like DEMO1, but DEMO2 contains code to do a "stretch-fit" of images into the controls. DEMO1 does "stretch" the images to fit the controls, but does not preserve the proper aspect ratio (i.e. the image is stretched/squeezed to fit the control size, regardless of image distortion due to fitting the image to the control). DEMO2 does a "stretch-fit" of images/controls (resizes the control to the proper aspect ratio, and stretches/squeezes the image to fit the adjusted control). You may find the "stretch-fit" code useful with other image (TImage) manipulations. DEMO3 - Builds on DEMO2. Displays messages when the images are clicked, to show that the inherited click events are still functional. Also displays messages when images are captured, via code added to the OnCapture event handlers. This just provides a sample of how to use the OnCapture event. Code could just as easily have been added to save the image to a file, and will be used this way in other demo programs. DEMO3 also shows how to use the component to capture images of other windows than the desktop, active window, or active window client area. DEMO3 captures an image of the Program Manager window, if the Program Manager is running. Of course, as DEMO3 is built on DEMO2, the image aspect ratios are preserved. DEMO4 - Shows how to capture the image of windowed controls (those controls that have Window handles). This demo also shows how to save captured images via adding code to the OnCapture event handler. This example captures images of: the active window, Program Manager's window, and a button on the form. These images are captured, displayed, and saved to files. The files are: activwin.bmp, progman.bmp, and button.bmp, respectively. DEMO5 - This demo loads a listbox with the window titles/names of all visible parent windows, and captures an image of a selected window. When a listbox window entry is selected/clicked, the selected window is captured and saved to file stuff.bmp. Of course, this could just as easily been some other name, determined by the designer of some "real-world" application. DEMO6 - This one is the biggy folks! This demo shows how to use the component, in conjunction with a windows keyboard hook, to implement a rudimentary screen-capture program. The keyboard hook provides the capability to trap the F2, F3, and F4 function keys from anywhere in the system (system-wide keyboard hook). When demo6 is executed, the hook DLL (demokbhk.dll) is loaded into memory, the hook function is installed, and demo6 passes its window handle to the DLL (via the initialize routine) for message posting purposes. Whenever F2, F3, or F4 are pressed, and released, the hook function posts a WM_USER message to the demo6 program window, passing the virtual key code for the pressed/released key F2, F3, or F4. The demo6 program has an event handler which is executed whenever there is a WM_USER message posted to the demo6 window message queue. When such a message is received, the wparam part of the message is used to determine what window capture type to do. As it is defined for example purposes, F2 keypresses will ultimately cause an image capture of the full-screen, F3 captures the active window only, and F4 captures the client area of the active window. If testing this demo, keep in mind that some windows in the system may have actions defined for presses of the F2, F3, and/or F4 keys. When images are captured, they are also saved to files. Full screen images are written to d6-full.bmp, active windows are written to d6-activ.bmp, and client areas are written to d6-clien.bmp. The keyboard hook DLL (demokbhk.dll) and the demo 6 program (demo6.exe) are designed specifically for each others use. Please examine/study the source code for both the DLL and the demo program, to understand how they relate to each other. Once you know how they work together, and with the TWindowImage component, you can change/modify/enhance the hook DLL and/or demo program to create screen capture programs of your own. Note that the selection of the F2/F3/F4 functions keys, the WM_USER message, and the window image selections were made arbitrarily. As such, you may wish to define/use different function keys, a different windows message word, or do some different image captures than the demo. When you do make these type of mods, just keep in mind that the changes must be compatible between both the application and DLL. For those who do not know, keyboard hooks can ONLY reside in DLL's, NOT in applications. The choice of using a messaging technique was also somewhat of an arbitrary decision, as a callback function/procedure into the application could also have been used just as easily, but with somewhat of an execution speed reduction. It is hoped that the foregoing explaination of the demo6 model provides enough details, but it is highly recommended that you study the source code of the application and the DLL together, to fully grasp the technique. Once you understand it, you are home-free, and can easily build system-wide screen/window capture programs via calls to the TWindowImage component. Note that, by "system-wide", this means that while DEMO6 is loaded any press and release of the defined function keys will capture the defined screen/window image and save it to a file, regardless of which application in the system has focus. This means that you could start DEMO6, switch to another application, press the F3 key, and the end-result will be the capture/save of an image of the application window that you just switched to.