text:
Windows Programming/Programming Windows with OSS Tools

Getting an Open Source Compiler
With a fast internet connection, gcc — a free compiler that can compile C, C++, and Fortran, as well as other languages and works on Windows — can be obtained through Cygwin. When installing Cygwin, select to install the "devel/gcc" package and optionally also "graphics/opengl", depending on what type of program you're planning to write. Another Windows port of the GCC compiler collection is MinGW (Minimalist GNU for Windows), an approximately 10MB download 1/10th the size of Cygwin. You could also download DJGPP, but it is designed more for 32-bit console programs. An alternative to obtaining the gcc compiler via porting is to compile from command line within a virtualized version of Linux, which not only comes with gcc, but whose kernel "... is written in the version of the C programming language supported by GCC..."

Command Line GCC Illustration
To compile, open a command-line interface and use the commands:

c:\cygwin\bin\gcc -s -Os -mno-cygwin -o

for command-line programs and

c:\cygwin\bin\gcc -s -Os -mwindows -mno-cygwin -o -lopengl32 -lwinmm

for GUI programs.

Description of command-line flags:
 * -s: makes the output program smaller by stripping out information that is useful for debugging crashed applications
 * -Os: optimizes for size (-O3 for execution speed)
 * -mno-cygwin: makes the program work without any external nonstandard .dll-files
 * -mwindows: makes it a GUI application
 * -lopengl32: optionally lets you use OpenGL for graphics
 * lwinmm: optionally adds some multimedia support such as sound, joysticks, and high resolution timers

One compiler must be in the bin directory of Cygwin in order to compile with Cygwin, whereas in Linux gcc is already aliased to work in all directories.

Graphical Integrated Development Environments
For a more user-friendly environment, like Visual Studio, an excellent open source IDE for Windows is Bloodshed's Dev-C++. It has a well-organised Graphical User Interface, and comes with everything necessary for setting up a Windows C/C++ development environment, installing and using the Mingw port of GCC by default (though it can be configured to work in combination any other GCC-based compiler such as Cygwin). Its source (written in Delphi) is available from the Bloodshed Website, as are the pre-compiled binaries. Dev-C++ has not been updated in quite some time, though, and alternatives like Code::Blocks or CodeLite have since emerged. Netbeans is an IDE developed by Sun Microsystems as the official IDE for Java however Netbeans now supports multiple languages and is very extensible via its plugin system. Another open source IDE is Eclipse, which was initially developed by IBM. One more IDE, created specifically for C++, is Ultimate++.

GCC, DJGPP, MinGW and others
These are three well-known FOSS development toolsets for compiling applications, although they function in a way slightly different to Microsoft and Borland's Windows programming tools.

GCC
GCC stands for the GNU Compiler Collection. Although it provides support for compiling sources in several programming languages, it is most commonly used for C and C++ code. Because it is a compiler and not an IDE, approaches such as DJGPP wrap some more arcane details away from the user, easing the creation of programs, as well as providing other features, described below.

DJGPP
DJGPP is an Integrated Development Environment (IDE) developed by DJ Delorie since 1989. It is a DOS application with 32-bit awareness and allows the creation of software with DPMI support. As a combined port of GCC and other GNU utilities, it is commonly used to write, compile and debug console applications. It can make use of libraries such as Allegro, in order to create applications with graphics, Other add-ons extend its functionality. It has support for cross-platform development, meaning that you may create software without needing a physical instance of a target machine type or operating system in order to build the executable that will be shipped to that configuration.

MinGW
MinGW stands for the Minimalist GNU for Windows and includes the needed header files for using the Win32 API; it supports creation of native Windows executables. As of late December 2006, Wikipedia defines the goal of MinGW as to "provide only a free compiler and toolchain, prioritizing performance". This contrasts the Cygwin objective of creating a POSIX compliant development environment. Like DJGPP, it can be used for cross-platform development. Because MinGW is available for other systems outside of Windows (such as Linux), even developers lacking a copy of Windows can create Win32 API applications. Furthermore, PE executables (.exe files) can be run using the WINE program (which translates Windows API calls to the corresponding UNIX system functions) to get a taste of what the application will look like - without actually having to install Windows.

The original MinGW project (from mingw.org) has been forked and there is now a MinGW64 project. The original project provides only a 32 bit compiler. The forked project provides both 32 and 64 bit compilers. The goals of the projects differ. The original MinGW project strives to work with only Windows APIs that are publicly documented. The MinGW64 project maintains that they've reverse engineered missing information using a clean room technique and so it's not violating copyright to use the APIs.

Dev-C++
Dev-C++ is a free graphical IDE that comes packaged with MinGW and can also use the Cygwin compiler.

llvm
llvm is an alternative Open Source compiler. One of its goals is improved optimization of programs. It can be used in conjunction with other compiler suites such as Microsoft's C/C++ compiler or MinGW64. As of this writing, it requires a separate linker (such as the one's offered by the GNU compiler suite via MinGW64).

midipix
If you only want to use the gcc for Windows development (cross-compiling to Windows) on a Linux machine another option is the midipix project. It uses the lightweight musl C library along with the gnu compiler suite. They're creating a POSIX compatibility layer to port musl to Windows using ntdll. This avoids requiring the Windows C runtime (which MinGW needs). The project already has several Open Source applications ported and running using their version of the GNU gcc compiler.

Other tools
GCC, DJGPP and MinGW do not have support for graphic-oriented resource and GUI editing commonly needed for Windows programming.

MinGW supplies the w32api package which includes the headers and a way to link to the DLLs that support the native WIN32 API. Windows OpenGL and DirectX can also be used with MinGW. The MinGW versions of DirectX headers are not as complete as the official Microsoft headers.

However open source libraries such as QT, GTK+, wxWidgets and FLTK provide user interface frontends as well as simplified models wrapping around the complexities of the Windows API. The minimal trade-off is that these may require special licensing and the bundling of runtime DLLs.

One can also use graphics libraries such as SDL, Allegro, SFML to create user interfaces or draw graphics.

Console based text user interface libraries such as PDCurses and ncurses also work on Windows. There is a port of PDCurses with a SDL backend that will allow developers to integrate graphics with a text user interface. Nano-X can be built with an Allegro or SDL backend on Windows and can be used to build some X Windows compatible applications.

All of the above GUI and graphics libraries mentioned work with MinGW. Versions of PDCurses, Nano-X, FLTK and Allegro work with DJGPP.

Cygwin
Cygwin is an environment made for Windows that emulates Unix behavior. It can be obtained from cygwin.com via a small setup.exe package that when run, asks for a selection of features that are then fetched. A fast internet connection is suggested, since Cygwin comprises many non-trivial shells, programs, and even GUIs.

The setup program allows the user to download the following parts, among others:

 * Bash shell
 * Development tools, with debugger, several languages supported by gcc compilers, as well as AWK, SED, YACC and Bison support
 * Network tools, such as ssh, lynx web browser, nmap, and others
 * Programmer text editors, such as GNU Emacs, nano and vi
 * X, which is a very difficult environment to fetch for free on Windows otherwise (unless built from source)

The software, after selected, is downloaded and installed to a folder at the root of the user's hard drive. It does not repartition the drive, require installation of any Unix system nor use a disk image. Files are simply installed in a Unix hierarchy within the cygwin folder.

To run Cygwin, the user will have a Start Menu program or Desktop shortcut called Cygwin Bash Shell. Upon opening it, a DOS-like window opens and displays a classic bash prompt. It is color coded, unlike its DOS underpinnings, and can interact with DOS by being aware of path settings and other system variables, so be aware of the fact that your Windows applications may be located from your system path variable and conflict with a folder's current filename because of DOS's implicit EXE extension expansion.

Directory information
As an added detail, if you need access to different drives in your computer, instead of using /mnt/, you have to cd into /cygdrive/ to see your drives listed. Seeing your C: drive's root, then, is just a matter of typing cd /cygdrive/c at the command line.

Emacs editor information
When using Emacs, the normal key combination to exit the program has no effect, by default, though adept users will probably find an Emacs keybinding trick to overcome this issue. Thus, when you want to exit the editor from command line mode, you may end up getting tired, and suspend the program to do a later kill of the process at the command line. Instead of pressing C-x C-c, to leave emacs, you must press F10 to get the menu. Once there, press f and then e. This summons the File Menu and later its Exit option, returning to the command line and prompting for the appropriate saving when some changed files need to be committed to disk.

Compiling without Cygwin library bindings
Compiling with g++, as stated in a previous section, needs to include the appropriate flags. gcc will normally bind the executable code to the cygwin1.dll file, unless your gcc flags explicitly include "-mno-cygwin" as a switch. To solve this, you can add this and all other switches to your .bashrc file, by using a known Unix option:

Open the .bashrc file at your Cygwin home directory in any editor. Look for the lines starting with "alias". There, you will see some shell commands tweaked to have specific options. Under the line containing

alias l='ls -CF'

you may add:

alias g++='g++ -mno-cygwin' #do not depend on cygwin1.dll on target system

In case you need to add more fine tuning tags, you may either add them to that same line after the -mno-cygwin switch, or just re-alias the g++ command so that the shell stacks up the current meaning of g++ to further tags. For example, you may add

alias g++='g++ -Wno-deprecated' #silence deprecation talk.

To keep the g++ compiler from reminding you about the standard practice of including instead of the now deprecated  header.

No root nor su switching
Cygwin was created with a few differences in mind. It does not have a different root account, though it may claim files are owned by the Administrator user. Though this may be beyond the scope of the book, it is worth a line or two to say that you won't easily be able to experiment with programs that run under different user rights, because it does not seem that Cygwin tries to enforce account security. You may read any file in the OS that Windows allows Cygwin to access.

Next Chapter

 * Resource Scripts


text:
Windows Programming/Windows System Architecture

History
Windows was originally a 16-bit graphical layer for MS-DOS that was written by Microsoft. As it grew, it gained the ability to handle 32-bit programs and eventually became totally 32-bit when Windows NT and 2000 came out. After Windows 95, Microsoft began to remove dependencies on DOS and finally fully implemented the separation in Windows 2000. Windows has many advanced features as well as many platform specific problems. It possesses an Application Programming Interface that consists of thousands of mostly undocumented GUI functions as well as having varying degrees of MS-DOS compatibility. Additionally, with the advent of NT (New Technology), Windows relies completely on the NT kernel instead of its MS-DOS subsystem, the NT kernel is capable of emulating the necessary DOS functionality. In addition to the NT kernel, Microsoft has also introduced many API wrappers, such as the MFCs (Microsoft Foundation Classes), COM (Component Object Model), and .NET technologies.

The most popular languages for use on Windows include Visual Basic/VB6 and C/C++, although C++ is quickly being replaced by the .NET platform, specifically C# (C Sharp).

Windows Kernels
Windows 1.0, 2.0, and 3.11 are considered to be an older generation of Windows systems that were built to be a simple graphical layer over the MS-DOS operating system. Windows 95, Windows 98, and Windows ME were designed to bypass MS-DOS (although DOS was still present), and were all based on the same code structure known as the "9x Kernel". Windows NT 4.0, Windows 2000, Windows XP, Windows Vista, Windows 7, and Windows Server are all based on a collection of code known as the "NT Kernel".

System Architecture
Today we’re starting a new series of posts focused on understanding the Windows System Architecture itself. In our first post, we’re going to quickly review some basic Windows concepts and terms including a brief overview of the Windows API, Services and the difference between a Process and a Thread. Think of this as laying the groundwork for our future posts which will cover topics such as the Registry, Session Space and Desktop Heap. So, without further ado – let’s start with an introduction to the Windows API.

The Windows NT Kernel is divided into several sections, here we will briefly discuss how the Windows operating system is put together. At the most basic level is the file NTOSKRNL.EXE, the kernel of the Windows operating system, and the most important file on your computer. If you are interested in seeing this for yourself, you can find it in the C:\Windows\System32 folder (this can also be found using the following path %systemroot%\system32 ) on your own Windows NT machines.

NTOSKRNL.EXE provides some of the basic functionality of Windows, but one file alone cannot make the whole system work. NTOSKRNL relies heavily on a Dynamic Link Library (DLL) known as HAL.DLL. HAL stands for "Hardware Abstraction Layer", and is the portion of code that allows low-level mechanisms such as interrupts and BIOS communication to be handled independently.

If we consider Windows architecture as a layered architecture, with NTOSKRNL.EXE and HAL.DLL on the bottom layer, the next layer up contains two important files, NTDLL.DLL, and WIN32K.SYS. NTDLL contains a number of user-mode functions such as system call stubs and the run-time library (RTL) code, collectively known as the (largely undocumented) "Native API". Much of the run-time library code is shared between NTOSKRNL and NTDLL. WIN32K.SYS is a kernel-mode driver that implements windowing and graphics, allowing for user interfaces to be created.

The next layer up contains a number of libraries that will be of primary interest to us. This layer comprises what is called the Win32 API, and it contains (almost) all the functions that a user will need in order to program in Windows. The Win32 API is divided into 4 component parts, each one a .DLL:

 * kernel32.DLL: This contains most of the system-related Win32 API functions. Most of these functions are just wrappers around the lower-level NTDLL functions, but some functionality such as National Language Support (NLS) and console handling are not available in NTDLL.

 * advapi32.DLL: This contains other system-related functions such as registry and service handling.

 * gdi32.DLL: This contains a number of basic functions for drawing. These functions are all relatively simple, and allow the user to draw shapes (circles, rectangles, etc.) on the screen, to display and manipulate bitmaps, etc.

 * user32.DLL: This contains a number of functions that implement the familiar user-interface of Windows. Programs, message boxes, prompts, etc are all implemented using the User32 functions. User32 performs its tasks by calling system calls implemented by WIN32K.SYS.

In addition to the 4 primary libraries in the Win32 API, there are a number of other important libraries that a Windows programmer should become familiar with:

 * MSVCRT.DLL: MSVCRT.DLL is the dynamic link library that contains the implementations of the C standard library (stdlib) functions that C programmers should be familiar with. These are the functions defined in the common header files stdio.h, string.h, stdlib.h, etc.

 * WS2_32.DLL: This is the Winsock2 library, that contains the standard Berkeley socket API for communicating on the internet. We will talk about winsock programming later in this book.

Windows Does It
The Windows system, it might be surprising for some people to learn, is a very hands-on system. This is not a familiar concept for people who are just beginning C programming using the standard library. In a normal software project, there is typically a main function, and the main function in turn calls other functions that are defined in your project. In a Windows function, typically the programmer provides function pointers to the system, and Windows will make calls into your program. Also, in a Windows program, your code will sit idle when there is nothing to be done. Using the message loop architecture, Windows will send messages to your program when an event needs to be handled, and the program responds to the messages. If the program doesn't respond, the message is ignored.

For each program, Windows sets up a message queue structure to handle the message transmission process. Windows will maintain a listing of all the objects and system resources in use by a program, and will assign each one a handle. These handles are useless by themselves, but they can be passed to the system to reference particular objects and resources.

Next chapter

 * User Mode vs Kernel Mode

license: Creative Commons - Attribution Share-Alike - https://creativecommons.org/licenses/by-sa/4.0/


text:
Windows Programming/Obtaining the SDK

The Windows Platform SDK
The Microsoft Windows Software Development Kit is a simple, free set of tools and libraries to create windows programs in C and C++. The SDK contains the standard windows header files, the link libraries, the compiler (cl.exe), and the linker (link.exe). The SDK is available as a free download from Microsoft.

Download the SDK

Visual Studio
Another option is Microsoft Visual C++, a commercial IDE and is an option worth looking into for serious Windows programmers. Microsoft Visual Studio is almost a de facto standard Windows programming IDE.

The best option for a beginner is Microsoft's .NET platform. .NET developers can use Microsoft Visual Studio.NET, Borland C#Builder (discussed earlier), the Visual Studio Express products and SharpDevelop.

Borland Compiler
In addition, Borland has released several of its compilers for free (although still proprietary) as Borland Command Line compiler tools. Borland requires users to log in in order to download these tools. They are quite small and fast, more so than gcc and DJGPP, and can build Windows applications with ease, especially for those accustomed with Borland tools.

Other notable downloads from Borland are C++BuilderX and C#Builder, both with IDEs. Both products impose restrictions on your software and must not be for commercial use.

Other Tools
SharpDevelop is a free and small IDE. It supports C# and partially supports Visual Basic.NET. However, you also need to obtain Microsoft's .NET SDK, which can be freely downloaded from Microsoft's site.

It's also possible to develop Windows programs in Forth (see the Forth article at Wikipedia) using WinForth, Win32Forth, SwiftForth, and RetroForth. Several of these can generate native Windows applications with much less bloat than C/C++.

title: Windows Programming/Obtaining the SDK


text:
Windows Programming/Obtaining the DDK

What is the DDK?
Microsoft offers a free Driver Development Kit, for people who are interested in writing device drivers, system services, and other kernel-mode code. The DDK comes with a number of different libraries, extensive documentation, link libraries, a special compiler and linker, and many examples for new driver programmers.

This book discusses the DDK in depth in throughout Section 4, but specifically in the chapter about the DDK.

Obtaining the DDK
The DDK is available free from microsoft, but not as a download. To obtain the DDK, you must order the software on CD, and this comes with a small shipping and handling fee. The DDK has a number of different options, and installing the DDK with every option will require a large amount of disk space.

The DDK used to be available as a download, but to conserve bandwidth, Microsoft has changed their policy to only offer the DDK as a CD. The SDK, and a number of other CDs are also available to order from Microsoft for free (plus shipping and handling), so this might be worthwhile to check out as well.

Order the DDK

title: Windows Programming/Obtaining the DDK


text:
Windows Programming/Obtaining MASM

Obtaining MASM
Many people claim that Microsoft has discontinued the use of MASM, but this is not the case. MASM is still maintained by Microsoft for use in house, and is updated on a needs basis. This means that MASM is only updated when presented with a specific need, such as the migration to 64 bits, or the migration to Vista. MASM comes as part of the standard DDK distribution (on the CD), and can also be found for download on the Internet, or can be ordered separately by contacting Microsoft sales and service at 1-800-426-9400.

title: Windows Programming/Obtaining MASM


text:
Rosacea

Rosacea (IPA:) is a common but often misunderstood condition that is estimated to affect over 45 million people worldwide.

Chapters

 * 1) /Authors and Contributors/
 * 2) /What Is Rosacea?/ [[File:25%.svg]]
 * 3) /Basic Skin Care/ [[File:25%.svg]]
 * 4) /Treatments/ [[File:25%.svg]]
 * 5) /Intense Pulsed Light and Laser/ [[File:50%.svg]]
 * 6) /Intense Pulsed Light and Laser manufacturers/ [[File:50%.svg]]
 * 7) /Insurance/ [[File:50%.svg]]
 * 8) Researching [[File:25%.svg]]
 * 9) /Glossary/
 * 10) /Resources/ [[File:75%.svg]]

title: Rosacea


text:
Rosacea/Treatments

Antibiotics
Oral antibiotics are usually the first line of defence prescribed by doctors to relieve papules, pustules, inflammation and some redness. There are two families of antibiotics normally used, traditionally the tetracycline family and now macrolide families have been proven to help treat rosacea. Antibiotics are used for their anti-inflammatory properties rather than their ability to kill micro-organisms. Generally they are prescribed in quantities too small for them to be effective at stopping the growth of micro-organisms.

The Tetracyclines family include: Aureomycin, Demeclocycline, Doxycycline, Minocycline, Oxytetracycline and Tetracycline.

Tetracycline use should be avoided during pregnancy and in the very young (less than 6 years) because it will result in permanent staining of teeth causing an unsightly cosmetic result.

Doxycycline is commonly prescribed by medical doctors for infections and to treat acne. It may also be used to treat urinary tract infections, gum disease, and other bacterial infections such as gonorrhea and chlamydia. Doxycycline is also used commonly as a prophylactic treatment for infection by Bacillus anthracis (anthrax). It is also effective against Yersinia pestis and malaria. At subantimicrobial doses, doxycycline is an inhibitor of matrix metalloproteinases, and has been used in various experimental systems for this purpose.

Oracea is a 40mg modified-release formulation of doxycycline that is taken once daily for the treatment of rosacea and is patented by Collagenex Pharmaceuticals. Oracea works by reducing inflammation.

Minocycline hydrochloride, also known as minocycline, is an antibiotic of the tetracycline class. It is marketed under several trade names, including Minomycin, and Dynacin. It is primarily used to treat acne.

Metronidazole can be taken orally or as a gel or cream. It is sold as MetroLotion®, Metrocream® and Metrogel® by Galderma Laboratories]] and as Noritate® by Dermik.

Metronidazole tastes very bitter, and can cause headaches. Long term or high dosage administration of metronidazole can lead to peripheral neuropathy, which often manifests itself as a tingling or numbness in the fingers or toes. Patients who experience neuropathy should stop taking the drug and immediately contact their physician. Patients taking metronidazole must avoid consuming alcohol in any form (including cough syrup), as it will react badly with the medication, leading to severe nausea and cramping. Another common side effect is the darkening of the urine. Patients should drink plenty of water to avoid constipation. Patients taking metronidazole have also reported loss of appetite and mild nausea. Forcing oneself to eat, despite lack of appetite and fatigue, may reduce the nausea.

Clonidine
Flushing and blushing can be reduced with a centrally-acting alpha-2 agonist Clonidine. Clonidine has side effects of drowsiness and lowered blood pressure. Moxonidine can be used as an alternative to Clonidine as it has less side effects but most people find Clonidine more effective. Beta-Blockers like Propanol are similar to alpha-2 agonists and work better for anxiety and chronic social blushing. More information about Clonidine can be found at the following page (http://www.angelfire.com/journal2/sadhelp/clonidine.htm).

Beta blockers
Beta blockers or beta-adrenergic blocking agents are a class of drugs used to treat a variety of cardiovascular conditions and some other diseases.

There are two types of beta receptors: β1-receptors located mainly in the heart, and β2-receptors located all over the body, but mainly in the lungs, muscles and arterioles.

Drugs that block beta 2 receptors generally have a relaxing effect and are prescribed for anxiety, migraine, esophageal varices and alcohol withdrawal syndrome, among others. Many beta blockers affect both type 1 and type 2 receptors; these are termed non-selective blockers. Some non-cardio selective beta blockers are Nadolol, Oxprenolol, Propranolol, Pindolol and Sotalol.

 * Wikipedia - Full Beta blocker article
 * Rosacea Support archives msg:9717 - A patient talks about their experiences with taking atenolol.

Isotretinoin
Isotretinoin is a powerful medication normally used for the treatment of acne but in low dosage can be used to treat rosacea. It is a retinoid, meaning it is derived from Vitamin A and is found naturally in the body, produced by the liver in small quantities. Isotretinoin is sold under many brand names, including Accutane® and Roaccutane® by Roche. It is also marketed as Accure® (Alphapharm), Oratane® (Douglas Pharmaceuticals), Isohexal® (Hexal Australia), Amnesteem® (Bertek) and Claravis® (Barr).

Isotretinoin is effective at treating rosacea but because of the many side effects it is normally prescribed after other treatments such as antibiotics have been tried. Isotretinoin is typically prescribed at between 0.5 mg/kg/day to 2.0 mg/kg/day for severe acne. For rosacea it is normally prescribed at a dose of 0.5 mg/kg/day to 1.0 mg/kg/day or lower.

17 of a study of 20 patents in a follow up one year after stopping treatment had no relapses showing a long-lasting favourable effect in rosacea.

Dr. Richard B. Odom in a article for Skin & Allergy News suggests using 10 mg of oral isotretinoin two or three times a week or 20 mg twice a week.

There is some anecdotal evidence that high dosages of isotretinoin caused or contributed to the development of rosacea.

Topicals
There are many acne treatments topicals which are used by mistake for rosacea. A lot of the time the acne products can have a drying effect which can further irritate the redness. A a popular rosacea treatment

title: Rosacea/Treatments


text:
Rosacea/Intense Pulsed Light and Laser

Intense Pulsed Light (IPL)

Intense Pulsed Light (IPL) is a treatment where a broad spectrum of light is applied to the skin. IPL differs to dermatological lasers in that they emit a large spectrum of light while lasers emit a single wavelength, but in practice they are quite similar. IPL machines are expensive and the treatments are normally only available from dermatologists and beauty salons. Using different settings IPL machines can be used for treating vascular lesions, fine wrinkles and also for hair removal. For vascular treatments the goal is to destroy blood vessels in the inner layers of the skin by heating them to 70 °C. Although blood vessels are targeted, the light energy is also absorbed by other structures in the skin such as melanin (pigment for skin and hair) and water. IPL has only been around since 1995 and new research to maximise effectiveness while reducing side effects and new technologies and procedures are still being developed.

IPL Machine
IPL machines are powered using a xenon flash lamp. Xenon, which is also used for camera flashes produces a flat spectrum of light from 400nm to 1200nm when excited with electricity. Different filters can be used to filter out lower wavelengths depending on the treatment performed. The size of the glass prism (spot size) varies between machines but at ~4.5x1cm they are much larger than typical lasers at ~1cm circle. A light pulse can be triggered by the operator using the hand piece. There is a delay between pulses while the capacitors recharge and the flash lamp cools down.

Settings
For the Matrix system of Medical Assist the settings are: 380nm-1800nm / upto 15 pulses times two. maximum 80 joules per square centimeter. This is the most powerfull IPL system in the world with the best effect. The machines are available in two different types, the first is a salon equipment and the other is a hospital use. Both are very reliable machines with high quality.
 * Wavelength or Filter: A Xenon flash lamp produces a wavelength from 400nm to 1200nm. For vascular/rosacea treatments the light is filtered generally at the lower end. A 590nm filter would reduce the wavelength from 400-1200nm to 590-1200nm. Lower wavelengths penetrate lower and higher wavelengths penetrate more deeply into the skin.
 * Fluence or energy level: The amount of energy applies over the whole pulse generally ranges from 20-60 joules per square centimetre (J/cm2) and may be spread over a series of short pulses. A joule is equal to 1 W·s (watt second).
 * Pulse width: The duration of each pulse. Can be a single pulse or three short pulses.
 * Repetition rate: The delay between the short pulses.

How it works
Selective photothermolysis. The absorption of haemoglobin is significantly higher than the absorption by melanin the skins natural pigment. The haemoglobin absorb the light heating up causing the blood vessel walls to heat up causing coagulation of the blood vessels which are eventually reabsorbed by the body and replaced by scar tissue. Their are two systems. The first one is a ELOS system, which is working only for 70% for black or dark hair with a white skin. It wont work for blond, red or grey hair. Also it is not safe to use on dark skin. The second system is a Matrix system from Medical Assist. This system works on a thin part of the hair follicle which is effective for all colours of hair and is safe for every type of skin.

Cost
Generally treatments are sold as single treatments or as discounted packages of five treatments with a period of 3-4 weeks or 6 weeks with the Matrix system, between each treatment. Prices per treatment are usually between US$300-700 (€230-500) but can vary depending on country, IPL machine type and the qualifications and skill of the operator.

Treatment procedure
Topical anaesthesia can be applied 10-30 minutes before the treatment. Eye protection is generally worn by the patient and the operator. The operator selects the settings based on the skin type and similar characteristics and proceeds with the treatment. Each pulse of the IPL feels like having a rubber band snapped against the face. The skin will be redder and painful after the treatment and improves over the day continues to improve for months after the treatment. Newer procedures include pre flushing using a heating pad on the back of the neck and macrolide antibiotics because of their anti-angiogenesis properties which stop the regrowth of blood vessels shortly after treatments.

Risks/parameters that affect outcome

 * For men if the area of facial hair growth is treated then it could result in temporary stunted hair growth and possible hair loss.
 * If the patient has dark skin or has a tan or sunburn then this will reduce the effectiveness of the treatment, this is not for the Matrix system from Medical Asist which can treat all skin types and skin colors.
 * If the operator presses too hard with the handpiece on your skin, the effectiveness of the treatment will be reduced because the blood will be pushed out of the area being treated.
 * If the energy levels are too high then purpura or bruising can result. Purpura is the appearance of purple discolourations on the skin caused by bleeding underneath the skin. Purpura can last up to 2 weeks.
 * Blisters
 * Alcohol, isotretinoin

Effectiveness
In a study of 63 patents with telangiectasia owing to rosacea that were treated with IPL concluded that IPL is an effective tool in achieving meaningful and lasting rosacea clearance. The study found a mean clearance of 77.8% was achieved and was maintained for a follow-up period averaging 51.6 months (range 12-99 months). >

Another study was performed in order to detect the effect of IPL application with simultaneous topical antibiotics in inflammatory rosacea and to assess the efficacy of IPL therapy in routine treatment of rosacea. Twenty patients aged between 34 and 70 with papulopustular rosacea (14 female and 7 male) were included in the study. Ten patients (group I) were treated for 21 weeks with topical metronidazole. The other ten patients (group II) received an additional 3 sessions with IPL 515-755 nm Photoderm VL technology over 4 weeks. Treatment effectiveness was recorded by digital visualisation and patient satisfaction scale before each IPL session. In all patients, significant reductions in papulopustular elements were observed. Eight out of 10 patients (group I) still showed permanent erythema and telangiectasias despite topical treatment. In 3/10 patients a few telangiectasias remained following the treatment in contrast to 5/10 satisfied group I patients. MD Ferdinand Bisselink did a study on 116 patients for the treatment rosacea and found out that 103 from the 116 patients see that there whas a reduction of more as 70% after four treatments with the Medical Assist Matrix IPL system.

Trademarks and procedures

 * Photoderm®: ESC Medical (now Lumenis) first introduced IPL machines for dermatological use in 1995. The Photoderm VL machine for vascular lesions was among the line-up and the treatments were often marketed as "Photoderm".
 * Photofacial™: A trade secret procedure developed by Dr. Patrick Bitter Sr. M.D. and Dr. Patrick Bitter Jr, who train IPL operators in their protocols for a fee.
 * FotoFacial™: Dr. Patrick Bitter Jr later developed the Fotofacial protocol and the FotofacialRF using Syneron ELOS technology.
 * Photorejuvenation is not trademarked.
 * Intens Pulsed Light Matrix system is developed by Medical Assist (medicalassist@hotmail.com)

Laser
Dermatological Lasers can be used to treat rosacea and work by applying a high energy single wavelength beam to the skin to target blood vessels. This heats them up, damaging them and they are then removed by the body's defence mechanism.

title: Rosacea/Intense Pulsed Light and Laser


text:
Rosacea/Insurance

There are still many insurance companies that refuse to cover Laser/IPL treatments because they view rosacea as a "cosmetic concern". Here are some simple steps taken by previous rosacea sufferers to get insurance to reimburse both fully or partly.

Ring up your insurer and ask if it will be covered. Even if your insurance company will cover the procedures, they usually require pre-certification outlining the number of treatments and type of laser. Prepare a submission outlying your rosacea symptoms and how they affect and limit your lifestyle. Get photos of your severe flushing so the insurance company can see what you are really dealing with. Include peer-reviewed articles photocopied from books or medical journals or printed from the Internet.

The following symptoms are viewed as cosmetic (less important): Papules, pustules, redness and visible telangiectasias. The following are not cosmetic (more important): Flushing, blushing, burning, itching, facial swelling and pain.

Other major points to include:
 * A letter of medical necessity from a physician in your plan including the CPT code for the procedure. (It was 17108 in 2003)
 * A list of all other remedies you have tried (antibiotics, prescription topicals, diet and lifestyle changes, etc)
 * In your letter explain that when lasers are used for cosmetic purposes the settings are different than when treating rosacea.
 * As of 2004 many Laser/IPL machines are approved by the Food and Drug Administration (FDA) of the United States.

 * If it is not treated it will progress into more advances stages
 * You may be able to stop taking current rosacea medications after the Laser/IPL treatments

Be persistent. Fax your request and then send it with signature verification of the recipient. Call in a few days to confirm receipt, find out when the review committee will be meeting, follow up the day after that and keep on top of your request. Document the names and dates of people you speak with, it may be beneficial if you need to appeal a rejection. If your claim is rejected, ask why your claim was rejected then refute those claims with evidence. Ask at one of the online support groups for help if you need it.

Sample Letter
Below is a sample letter that was used by Adam to convince his insurance company to provide full coverage.

Dear Committee Members: My name is Adam. I am 19 years old. Dr. xxxxxx xxxxxxxx, M.D., my dermatologist, submitted a request for Photoderm device coverage to alleviate my disabling rosacea. Dr. xxxxxx's request on my behalf was denied based on your determination that this procedure would be a cosmetic one. I believe you have made a mistake.

I have a tentative appointment set up to have my first Photoderm treatment on December 6, 2001 at Dr. xxxxxx's (different doc, this is the one who im actually getting the procedures done by) Office based on your decision after reading this letter. I am not doing this for cosmetic reasons - I am doing this for reasons that are medically necessary. My Rosacea is accompanied by severe flushing, swelling, inflammation, and worst of all a disabling burning pain. My condition is worsened by almost everything imaginable. Most foods, sun exposure, hot weather, warm rooms, cold weather, wind, humidity, exercise, embarrassment, anger, mental concentration, stress, facial movements such as chewing and smiling, certain medications, most topicals, lotions, sunscreens, soaps, cleansers, showering, shaving, daily physical activities (walking up a flight of stairs), cuddling up with someone, my head touching my pillow, and the heat from talking on the phone, are just SOME of the things that I run into each and every day that cause my facial pain to get substantially worse.

I have tried numerous creams, lotions and oral medications in an effort to alleviate the severe discomfort caused by my facial rosacea. The cost before insurance of all the prescription medications I have used in connection with my condition since the beginning of this calendar year totals over $2,500. In recent weeks I have begun experimenting with different antihistamines in an attempt to reduce the swelling, inflammation, and pain associated with the majority of foods I eat. This has not helped much, and I will soon be looking into adding a Cox-2 inhibitor such as Celebrex into my daily regimen.

The physical pain I live with every day, which is worsened by almost any movement I make, has become extremely debilitating. This disabling pain has caused me to become very depressed. My condition impairs my ability to function normally in society. I am unable to work, and have come close to dropping out of school more than once. I need to be able to get rid of the pain I live with every day so that I will be able to function normally once again.

This condition continues to be extremely costly for all parties involved. The insurance portion alone of the payment for the Psychiatrist I have begun seeing as a result of the depression this pain causes me, is $160 every month. Additional costs include doctor and dermatologist visits that I have needed as a result of my condition. In addition, I have already gone through one month of outpatient hospitalization at a substantial cost, because of the depression my Rosacea has caused me. By eliminating the need for most of these, five to ten treatments with Photoderm (which would cost a total of $1200-$1950) would be substantially less expensive than my current course of therapy has been. Payment for these five to ten treatments would be an extreme hardship for me, as my condition leaves me unable to seek employment. I have also begun to develop early-stage Rhynophymia as a direct result of my Rosacea, which if left untreated may eventually require an even more costly medically necessary surgery. Photoderm will prevent this aspect of my condition from getting worse, eliminating the possible need for more costly surgery in the future. It is important to remember that Rosacea is a progressive disease. Every symptom I have mentioned will more than likely continue to become more and more debilitating in the future without proper treatment.

My condition and the constant, debilitating pain it causes has left me unable to work. Since developing this condition I have been unable to maintain a steady job. The pain caused by simply placing my face against my pillow at night has left me unable to sleep properly. I usually am finally able to fall asleep around 4 A.M. with the help of powerful prescription sleep aids such as Ambien. Basically, my condition has left me unable to live a normal life. As you may or may not know, Photoderm has many different settings associated with it. The shallow filters are used to remove superficial, cosmetic redness from a person's skin. These are used for many cosmetic procedures. The deeper filters, which the doctor who would be performing the procedure has assured me will be used almost exclusively in my treatment, can be used to treat the underlying vascular reactivity, permanently decreasing my facial swelling, inflammation, and burning. This is why I require treatment with Photoderm.

I am asking you to please reconsider your decision. I am not having these treatments done for cosmetic reasons. I am having these treatments done because nothing else has worked. In my case, this is anything BUT a cosmetic problem. I have submitted supporting documentation from Dr. xxxxxx (my derm) with my request that you reconsider your original determination. Thank you for your review."

title: Rosacea/Insurance


text:
X86 Assembly/NASM Syntax

The Netwide Assembler is an x86 and x86-64 assembler that uses syntax similar to Intel. It supports a variety of object file formats, including:

 * 1) ELF32/64
 * 2) Linux a.out
 * 3) NetBSD/FreeBSD a.out
 * 4) MS-DOS 16-bit/32-bit object files
 * 5) Win32/64 object files
 * 6) COFF
 * 7) Mach-O 32/64
 * rdf
 * 1) binary

NASM runs on both Unix/Linux and Windows/DOS.

NASM Syntax
The Netwide Assembler (NASM) uses a syntax "designed to be simple and easy to understand, similar to Intel's but less complex". This means that the operand order is dest then src, as opposed to the AT&T style used by the GNU Assembler. For example,

mov ax, 9

loads the number 9 into register ax.

For those using gdb with nasm, you can set gdb to use Intel-style disassembly by issuing the command:

set disassembly-flavor intel

Comments
A single semi-colon is used for comments, and functions the same as double slash in C++: the compiler ignores from the semicolon to the next newline.

Macros
NASM has powerful macro functions, similar to C's preprocessor. For example,

Example I/O (Linux and BSD)
To pass the kernel a simple input command on Linux, you would pass values to the following registers and then send the kernel an interrupt signal. To read in a single character from standard input (such as from a user at their keyboard), do the following:

After the,   will contain the number of bytes read. If this number is < 0, there was a read error of some sort.

Outputting follows a similar convention:

BSD systems (MacOS X included) use similar system calls, but convention to execute them is different. While on Linux you pass system call arguments in different registers, on BSD systems they are pushed onto stack (except the system call number, which is put into eax, the same way as in Linux). BSD version of the code above:

Hello World (Linux)
Below we have a simple Hello world example, it lays out the basic structure of a nasm program:

In order to assemble, link and run the program we need to do the following:

Hello World (Using only Win32 system calls)
In this example we are going to rewrite the hello world example using Win32 system calls. There are several major differences:

 * 1) The intermediate file will be a Microsoft Win32 (i386) object file
 * 2) We will avoid using interrupts since they may not be portable and, this is Windows, not DOS, therefore we need to bring in several calls from kernel32 DLL

In order to assemble, link and run the program we need to do the following:

In this example we use the  command line option when invoking   to specify the entry point for program execution. Otherwise we would have to use  as the entry point rather than. This example was run under cygwin, in a Windows command prompt the link step would be different. One last note,  does not behave well within a cygwin console, so in order to see output the final exe should be run within a Windows command prompt.

Hello World (Using C libraries and Linking with gcc)
In this example we will rewrite Hello World to use  from the C library and link using. This has the advantage that going from Linux to Windows requires minimal source code changes and a slightly different assemble and link steps. In the Windows world this has the additional benefit that the linking step will be the same in the Windows command prompt and cygwin. There are several major changes:

 * 1) The  string now becomes the format string for   and therefore needs to be null terminated. This also means we do not need to explicitly specify its length anymore.
 * 2) gcc expects the entry point for execution to be main
 * 3) Microsoft will prefix functions using the  calling convention with a underscore. So   and   will become   and   respectively in the Windows development environment.

In order to assemble, link and run the program we need to do the following.

The Windows version with prefixed underscores:

In order to assemble, link and run the program we need to do the following.

title: X86 Assembly/NASM Syntax


text:
Rosacea/Basic Skin Care

Prior to beginning any new rosacea treatment, one needs to prepare the skin, and allow the skin to heal from the effects of previous treatments, which may have left the skin damaged or overly sensitive. We often hear people tell us that the rosacea treatments they had been using left their skin so sensitive that “even water hurts their skin” which can be very true. If one then uses a harsh acidic or invading rosacea treatment such as laser, skin rejuvenation or anti-wrinkle treatment, or retinoids, then obviously the rosacea sufferer is going further down the wrong rosacea treatment pathway.

So many times rosacea or the worsening of rosacea from a mild stage to a more severe stage is the result of treatments that we have used in the past or are currently using. Use of acne treatments containing ingredients such as salicylic acid or benzoyl peroxide cause increased redness to the facial skin; often we overuse these products because we feel they are not working. For instance you have more pimples so you use more of the acne treatment. When you do this, the skin reacts by trying to form a barrier of more oil to protect itself from the harmful effects of the offending treatment. So you tend to use more to counteract this effect and in doing so the pores tighten and close resulting in clogged pores, pimples and papules.

While coping with Rosacea, a way to successful skin care is to avoid doing anything to irritate your skin which may cause a flare up and worsen the condition. Anything that makes your skin (more)red is just worsening the problem. When selecting a skin care regimen, it is important to avoid ingredients that may irritate the skin. Alcohol, alpha-hydroxys, glycolic acid, should generally be avoided. Additionally, exfoliation should be avoided, particularly in affected areas. The key to managing skin with Rosacea is recognizing that the skin is suffering an inflammatory response.

Rosacea is very often associated with sun exposure, so protection of the skin with sunscreens is important.

Cleansing
Experts agree that a gentle cleansing regime is very important. Avoiding chemicals that aggravate the rosacea, but will clean and moisturise the skin is a step in the right direction. Routine everyday care of skin is an essential part of optimal patient management. Common problems such as xerosis, dermatitis, eczema, psoriasis, acne, rosacea, and photodamage leave the skin vulnerable to external insults, partly as a result of varying levels of barrier dysfunction. Cosmetic surgery procedures also typically damage the stratum corneum (SC) and leave skin with a very weak barrier during recovery phase. Cleansing is an important aspect of any skin care, since it not only removes unwanted dirt, soil, and bacteria from skin, but also removes dead surface cells, preparing skin to better absorb topically applied drugs/medication. Care must be taken to minimize any further weakening of the SC barrier during cleansing. Cleansers based on mild synthetic surfactants and/or emollients that cause minimal barrier perturbation are ideal for these patients.

Absolutely no way should harsh cleansers and toners be used. The natural oils on the skin must be regulated to allow the skin to form it’s own defenses against any harmful bacteria or environmental distress. Stick with mild cleansers targeted at sensitive skin. Cetaphil is one of the mildest cleansers out there and an ideal choice for delicate, irritable skin. Avoid cleansers that are heavily perfumed or contain detergents, alcohol, or other known irritants. Just because a cleanser says it provides "mild cleansing" doesn't mean it will be kind to rosacea skin. When looking for a cleanser, look for "Sensitive Skin Tested" on the label. The bottom line: If it stings, don't use it. It's as simple as that. Return it, throw it out, or give it away and start again.

After using the cleaner, the face will be rinsed with plentifulness of water and smudge with a soft towel in order not to irritate your skin. Because the skin touched of rosacea is very dry, you should avoid using coppices or rough towels to rub your face skin. When washing your face you should utilise lukewarm water instead of hot water.

Basic Skin Care
Never rub the skin. This can be difficult rule to follow, particularly when applying makeup, shave, or dry the skin after cleansing, but it is important. All these activities should be done in a way that does not move the skin. Use a very light touch at all times. An alternative to using a cleanser is to use a warm water rinse. Let your skin air dry as much as possible, and if needed blot very lightly with a soft towel.

Use a moisturizer free of fragrance, dyes, and other known irritants. As with washing and drying, do not rub the product into your skin. Rub the product between your hands before applying very gently and use more product than may seem needed, as this will prevent friction, If you find it easier, simply blot the moisturizer onto your skin after you have rubbed it onto your hands. Any extra product can be removed by placing a tissue over your face and neck and blotting it off. Lay it flat and lightly press and peel off. This method should be used by those who wear a foundation to cover redness. Also of course, pay attention to ingredients in your makeup as well.

Sunscreen
An unexpected day out at the beach or a sport game in the back yard in the searing heat will leave a rosacea sufferer red all over. The heat from the sunlight can cause flushing and the sunburn cause extra redness. Even when not out in the sun wearing a sunscreen is recommended.

UV light is of a shorter wavelength than visible light and is subdivided into three bands UVA, UVB and UVC. UVA light penetrates deeply and contributes to ageing, UVB causes burning and redness. Very little UVC light makes it past the atmosphere.

The SPF (sun protection factor) of a sunscreen is a laboratory measure of its effectiveness against UVB light that causes sunburn. SPF 15 means that a user can nominally remain in the sun 15 times longer than would otherwise cause them to have sunburn, but this varies with a number of factors. The SPF is not a linear measure of the amount of Ultraviolet blocked. A sunscreen rated 15 blocks 93.3% of UV, and an SPF 30 sunscreen blocks 96.7%. The SPF does not measure a sunscreens effectiveness against UVA light.

Sunlight was identified as the most common trigger by a survey by the national rosacea society. In many studies it has been found beneficial for rosacea patients to use sunscreen everyday to reduce their symptoms. Sunscreen is also highly recommended for patients taking treatments that cause photo sensitivity such as various antibiotics and isotretoin.

Find a broad sprectrum sunscreen preferably with zinc oxide or titanium dioxide as the main active ingredient that is also noncomedogenic and nonirritating skin. zinc oxide and titanium dioxide both block UV light instead of absorb then like most sunscreens. They also work immediately after application while other sunscreens need to be applied 30 minutes beforehand.

It is important to have sun protection while in the sun, but it is also important to use a sunscreen that will not cause irritation. Select a sunscreen target toward those for rosacea or sunscreens that have good reviews by rosaceans.

Shaving
Shaving will always cause some irritation but it can be minimised.

Get a good rotary head electric razor, a wet/dry one if possible so you can use it in the shower. You can use a shaving lotion to allow the shaver to glide easily over your face. Recommended lotions are jojoba oil, an aloe-based shaving cream or Edge Gel for Sensitive skin. Don't use anything with alcohol in it. You can shave before bed time, in the shower or after having a shower. Shave with light, short strokes in the direction of hair growth. Shaving with the grain helps prevent ingrown hairs, razor burn, and cuts. Instead of shaving against the grain to get a close shave, shave twice. If you use a blade, make sure that your face is coated with a thin stream of hot water before applying shaving cream. Give the cream a few minutes to settle in. Use a sharp razor that has a double blade attached to it. Take your time and rinse with cold water, not hot. Allowing the steam of a shower or hot towel to soften the follicles of a tough beard can be a better preparation.

Do not forget to shave gently and shaving too frequent shaving will irritate skin.

Concealers and makeup
Both men and women can benefit from the vast range of rosacea friendly makeup products. Give yourself the edge by testing the impact that correctly applied makeup can have. We hope that in reading this, you're armed with the information you need to make this a success.

Make yourself familiar with ingredients which may aggravate or irritate rosacea skin. Some find that they are only able to use mineral makeup. Ingredients to various brands of mineral makeup can be found at the Mineral Powder Foundation Ingredients List website (http://people.delphiforums.com/tracikenyon/IngredList22405.html). Many of the main stream commercial brands may include ingredients that may irritate. Sometimes the only way to know is to try so it's a good idea to do a bit of research in regards to ingredients. Lots of great brand name foundations out there though. No one product will work for everyone! If you wanted a more sheer look, find a liquid foundation that matches your skin tone and doesn't irritate and mix a few drops into your daily moisturiser. It will give sheer coverage, natural and it may be all you need. Lighter, oil free foundations are better for those with oily skin, and more emollient products are better for dry skin.

Always go for a foundation with a yellow base. Some opt for a green makeup base or primer. Some use concealers with a green tint. For the most part, this is just an added step, with more products now on your skin. Most people find that once they find the appropriate foundation, using green based products isn't necessary.

Application
Open your mouth when applying foundation to expose the neck area and eliminate an obvious line at the jaw line. When testing, apply a sample to the jawline and then go outside with a small mirror. If you can't see where the foundation is, then you've got the right colour.

Buy 2 different shades of the same foundation, one lighter and one darker, so that as the seasons change you can mix the colours to accommodate any changes in your natural skin colour. Some find that this is not necessary.

As far as application, always apply your makeup in natural daylight. And for novices, spend time at how perfecting application. Always start with less as it is easier to add more as you go along if needed. Put a little foundation on the hand (add a complimentary tone if necessary). Dot it over the face-on the nose, the cheeks, the chin and the temples and in between the brows. Using the tips of two fingers or a small clean, dampened sponge(from which excess water has been removed) blend the foundation. Always work from the face outwards, to avoid an accumulation of the foundation around the hairline-move from the cheeks to the ears, from between the brows down over the nose, from the chin out towards the jaw, then onto the neck. Work quickly, carefully and lightly. Blend well around the hairline, on the neck, below the eyes and behind the ears. Also take the foundation over the eyelids. Finally blot the face with a clean dry tissue, pressing it lightly over the skin. Apply a little powder to set the foundation if necessary. Go lightly the first time and go back to focus on certain areas the second time. Try to make everything look better, not look perfect. Whatever isn't covered by your first application/subsequent spot treating (very light spot treating) you might want to just leave alone. It has to match exactly. Even if you get "Wow, this is nearly invisible", try to see if you can get to the point where you say "Wow, this is invisible." It's absolutely critical it matches. If you try something and for whatever reason this brand doesn't offer you a good enough match, don't buy it just because. Try a different brand, first. When testing, apply a sample to the jawline and then go outside with a small mirror. If you can't see where the foundation is, then you've got the right colour. But, don't judge your match in blinding sunlight, this light will "blend" almost anything seamlessly and will not be accurate.

Extra bit For Men
Although the above information applies to everyone, I figured I'd touch on this subject further. Don't gravitate to products that say "For Men" on them. The color selections are almost always horrible and they are either too expensive or lacking in formulation. Or both. In short: The men who want to buy this stuff have already bought it and don't care if something is designated "For Men." The difference is in the packaging. "For Men" is for the men with fragile egos. Stick with bigger brands, they have more color selection, better formulations, you name it. MAC, Clinique, Estée Lauder, Armani, Becca, etc. You can do some browsing online for products you might want to try but just jot down the names of the products, don't bother remembering the name of the color. They're usually far off base in person. If going to a counter makes you uncomfortable, you might want to go in the morning when there are less people. Remember: You're not the only guy they've done this for! Sometimes sales associates will try to sell you things you don't need, so in case you didn't already know: you don't need primer, you don't need separate cleansers, etc. While you're learning, sponges and brushes are not necessary. Tell them you'll stick to using your fingers for now. (Unless of course you want to buy them.) Ask them for samples! Even if they have to put them in a little jar or something. Most if not all counters/stores do this. Keep in mind you will need a cleanser that is able to remove makeup. Lastly, if you're going to worry all the time that you have makeup on, always running to the mirror, being self conscious, etc, it defeats the purpose of wearing it. Don't feel forced into this. This should be something to help you feel better about yourself. Not worse.

Introduction links

 * About-Rosacea.com "A Daily Skin Care Program" (http://www.about-rosacea.com/lifestyle2.htm#Further%20Reading)
 * Rosacea-Ltd International News "Rosacea Treatment And Skin Care" (http://www.bassandboney.com/news/rosacea-ltd/?p=7)
 * Cosmetic Connection "Rosacea 101: Basic guide" (http://www.cosmeticconnection.com/rosacea101.html)

Cleansing links

 * Frequently Asked Rosacea Questions v.1.15 (http://www.faqs.org/faqs/medicine/rosacea/)
 * Rosacea Support "Mild cleanser is important" (http://rosacea-support.org/mild-cleanser-is-important.html)
 * Cosmetic Connection "Rosacea 101: Basic guide" (http://www.cosmeticconnection.com/rosacea101.html)
 * Journal a day "How to Take Care of a Rosacea Skin?" (http://www.journal-a-day.com/Health_And_Fitness/394969-how-to-take-care-of-a-rosacea-skin.html)

Makeup links

 * Rosacea Support archives msg:11538 - Article on foundations (http://health.groups.yahoo.com/group/rosacea-support/message/11538)

title: Rosacea/Basic Skin Care


text:
Windows Programming/User Mode vs Kernel Mode

In Windows (and most modern operating systems), there is a distinction between code that is running in "user mode", and code that is running in "kernel mode". This chapter is going to point out some of the differences. Firstly, Intel CPUs have modes of operation called rings which specify the type of instructions and memory available to the running code. There are four rings:

 * Ring 0 (also known as kernel mode) has full access to every resource. It is the mode in which the Windows kernel runs.
 * Rings 1 and 2 can be customized with levels of access but are generally unused unless there are virtual machines running.
 * Ring 3 (also known as user mode) has restricted access to resources.

The reason for this is because if all programs ran in kernel mode, they would be able to overwrite each others' memory and possibly bring down the entire system when they crashed.

Virtual Memory

When a program is started (e.g. a web browser or a word processor), it runs in its own process. A process contains its own "virtual" memory space and resources. Its memory is "virtual" because the process thinks memory that is at address  may actually be at address   in physical memory. Similarly, two different processes may have different data stored at (to them). This is implemented by dividing memory into chunks called pages; on x86 systems one page is 4 kilobytes in size. Each page can have its own set of attributes, such as read-only/read-write. The CPU has a transparent mechanism for translating virtual addresses to physical addresses through a page table which the operating system sets up.

Virtual memory is useful for many reasons:

 * 1) The process cannot access other process' memory,
 * 2) Each page can have different protection settings (read-only or read-write, kernel-mode-only), and
 * 3) Inactive memory regions of the process can be "paged out" (stored) to the pagefile and be retrieved by the operating system when needed. This is also done when the system is low on physical memory.

User Mode
Every process started by Windows (with the exception of the System "process") runs in user mode. In this mode, programs cannot modify paging directly and so have no way of accessing other programs' memory except through API functions. Programs in user mode also cannot interfere with interrupts and context switching.

Kernel Mode, Interrupts, and System Calls
When Windows is first loaded, the Windows kernel is started. It runs in kernel mode and sets up paging and virtual memory. It then creates some system processes and allows them to run in user mode. How does the CPU ever switch back to kernel mode then? This is not done automatically by the CPU. The CPU is often interrupted by certain events (timers, keyboard, hard disk I/O), and these are called interrupts. The kernel must first set up interrupt handlers to deal with these events. Then, whenever interrupts occur, the CPU stops executing the currently running program, immediately switches to kernel mode, and executes the interrupt handler for that event. The handler saves the state of the CPU, performs some processing relevant to that event, and restores the state of the CPU (possibly switching back to user mode) so the CPU can resume execution of the program.

When a program wants to call a Windows API function1, it triggers an interrupt2 which causes the CPU to switch to kernel mode and begin executing the desired API function. When the API function has finished processing, it switches back to user mode and resumes execution of the program. This is because API functions like  cannot work in user mode; the program can't access other programs' memory. In kernel mode, however, the API function can read any memory region without restriction.

1. Actually, Windows API functions eventually call a different API: the Native API. This is the API used by the Windows NT family of kernels. This is when the CPU switches to kernel-mode.

2. Modern CPUs have special, faster instructions for system calls, such as  and   on x86. These instructions cause the CPU to switch to ring 0, and then begin executing a handler set up by the operating system.

Context Switching
So, a program runs and calls API functions. How do other programs get a chance to run, then? Most of the time, programs simply allow the operating system to switch to another program because they are waiting for something (human input, hard disk). These programs are known as unrunnable programs, and since they make calls to the kernel to wait for something, the kernel knows to perform context switching to allow another program to run. This is done by:

 * 1) Saving the current program's state (including registers),
 * 2) Figuring out which program to run next,
 * 3) and restoring a different program's state.

If a program (thread or process to be more accurate) runs for more than a certain period of time (the thread quantum or a process's time slice), the operating system will context switch to another program. This idea is called preemption. Preemption is accomplished by setting a timed interrupt in the processor that will invoke context switching. The time slice that is used may be different for each process.

Next Chapter

 * C and Win32 API


text:
Windows Programming/C and Win32 API

C and Windows
Many of the low-level functions in Windows were created using the C programming language. C code tends to be relatively small and fast compared to VB code or even C++ code, and has a shorter development time compared to raw assembly code. All of the DLLs in the Win32 API, and most of the kernel-level structures are implemented in C code.

Visual Basic and Windows
Visual Basic is essentially a "Windows-only" programming language - although some ports either exist or are in development for other systems, VB is not nearly as popular on other operating systems as it is on Windows. The VB runtime libraries tap into the Win32 API and the MFC libraries, to implement its functionality. The new version of VB, "VB.NET", uses the .NET platform, and therefore will not be covered in this wikibook. Old versions of VB, or "VB Classic" utilize the same Win32 API and MFC interfaces that C and C++ use to communicate with Windows. However, not all of the functions are identical, because VB uses different data types, and stores data differently than C or C++. As we discuss the Win32 API and MFC, we will attempt to show how the same functionality is implemented in VB.

Visual Basic uses the STDCALL calling convention for implementing function calls. Most of the Win32 API uses the STDCALL calling convention as well, so much of the hard work for interfacing the two is done by the compiler. C and C++, on the other hand, do not use STDCALL by default, and if you want to manually link a VB object code file    with a C object file, you will need to explicitly make the C interface a STDCALL one.

COM and Windows
Microsoft implemented a technology known as the Component Object Model for Windows. COM essentially takes the object-oriented programming paradigm to the next level, by standardizing the class interface, and allowing classes to be written in different languages (C++, VB, etc.) and interfaced together seamlessly. COM programs (or "COM clients") can be written in most languages that allow object-orientation. More specifically, the only language requirement for COM is that code is generated in a language that can create structures of pointers and, either explicitly or implicitly, call functions through pointers.

Other Languages
Many other programming languages have been implemented on Windows systems, and many of them have some sort of method for interfacing the Win32 API, or the MFC libraries. These interfaces are known collectively as wrappers, because they wrap the functionality of the Win32 API in another programming language. Common wrappers are provided for Perl, Ada, Python, PHP, AutoIT, etc.

Next Chapter

 *

title: Windows Programming/C and Win32 API


text:
Windows Programming/windows.h

windows.h
The primary C header file for accessing the Win32 API is the  header file. To make a Win32 executable, the first step is to include this header file in your source code. The windows.h header file should be included before any other library include, even the C standard library files such as stdio.h or stdlib.h. This is because the windows.h file includes macros and other components that may modify, extend, or replace things in these libraries. This is especially true when dealing with UNICODE, because windows.h will cause all the string functions to use UNICODE instead. Also, because many of the standard C library functions are already included in the Windows kernel, many of these functions will be available to the programmer without needing to load the standard libraries. For example, the function  is included in windows.h automatically.

Child Header Files
There are a number of header files that are automatically included with windows.h. Many of these files cannot simply be included by themselves, because of dependencies. The windows.h header file is actually a relatively small file, that provides conditional inclusion for a number of other header files, definitions of a few important macros, etc.

- For a list of child header files visit-- http://en.wikipedia.org/wiki/Windows.h

Additional Header Files
This section will talk about some other interesting header files and libraries that can be included with your project, but which are not included by default with windows.h.

windows.h Macros
This section will briefly detail some of the changes that the user can make in the windows.h structure at compile time using macros.

WIN32_LEAN_AND_MEAN
The WIN32_LEAN_AND_MEAN macro causes several of the child headers to not be included in the build. This can help to speed up the compilation process.

UNICODE and _UNICODE
These macros, which we will discuss later, can generally be used interchangeably, but are frequently both defined together. These cause the program to be compiled with UTF-16 encoded strings instead of ASCII encoded strings. UTF-16 is one internationalized encoding based on the UNICODE standard and allows for more characters than the American ASCII encoding, although UTF-8 is often preferred in modern programming.

WINVER and _WIN32_WINNT
You must set these to a number greater or equal to 0x500 or you will not get some of the useful functions that are in Windows 2000 (and thus in any modern Windows) but were not in Windows 98.

Next Chapters

 * Handles and Data Types

title: Windows Programming/windows.h


text:
Windows Programming/Unicode

For a reference of Unicode standard, see Unicode.

Introduction to Unicode
Unicode is an industry standard whose goal is to provide the means by which text of all forms and languages can be encoded for use by computers. Originally, text-characters were represented in computers using byte-wide data: each printable character (and many non-printing, or "control" characters) were implemented using a single byte each, which allowed for 256 characters total. However, globalization has created a need for computers to be able to accommodate many different alphabets from around the world.

The old codes were known as ASCII or EBCDIC, but it was apparent that neither of these codes were capable of handling all the different characters and alphabets from around the world. The solution to this problem created Unicode. Windows NT implements many of its core functions with a "wide" 16-bit characters set, close to Unicode standard, although it provides a series of functions that are compatible with the standard ASCII characters as well.

UNICODE characters are frequently called "Wide Characters", "Generic Characters", or "T Characters". This book may use any of these terms interchangeably.

Variable-Width Characters
Before Unicode, there was an internationalization attempt that introduced character strings with variable-width characters. Some characters, such as the standard ASCII characters would be 1 byte long. Other characters, such as extended character sets, were two bytes long. These types of character formats fell out of favor with the advent of UNICODE because they are harder to write and much harder to read. Windows does still maintain some functionality to deal with variable-width strings, but we won't discuss those here.

Unfortunately all advantages of using wide characters were lost because the number of characters needed quickly exceeded the 65,536 possible 16-bit values. Windows actually uses what is called UTF-16 to store characters, where a large number of characters actually take //two// words, these are called "surrogate pairs". This development is after much of the Windows API documentation was written and much of it is now obsolete. You should never treat string data as an "array of characters", instead always treat it as a null-terminated block. For instance always send the entire string to a function to draw it on the screen, do not attempt to draw each character. Any code that puts a square bracket after a LPSTR is wrong.

At the same time, variable-width character-based strings made a big comeback in the multi-platform standard called UTF-8, which is pretty much the same idea as UTF-16 except with 8-bit units. Its primary advantage is that there is no need for two APIs. The 'A' and 'W' APIs would have been the same if this were used, and since both are variable-sized, it has no disadvantage. Although most Windows programmers are unfamiliar with it, you may see increased references to using the non-UNICODE API.

Windows Implementation
The Win32 API classifies all of its functions that require text input into two categories. Some of the functions have an "A" suffix (for ASCII), and some have a "W" suffix (for Wide characters, or Unicode). These functions are differentiated using the macro "UNICODE":

 * 1) ifdef UNICODE
 * 2) define MessageBox MessageBoxW
 * 3) else
 * 4) define MessageBox MessageBoxA
 * 5) endif

Because of this differentiation, when you receive a compiler error, you will get an error on "MessageBoxW" instead of simply "MessageBox". In these cases, the compiler is not broken. It is simply trying to follow a complex set of macros.

Unicode Environment
All Windows functions that require character strings are defined in this manner. If you want to use unicode in your program, you need to explicitly define the UNICODE macro before you include the windows.h file:

 * 1) define UNICODE
 * 2) include

Also, some functions in other libraries require you to define the macro _UNICODE. The standard library functions can be provided in unicode by including the  file as well. So, to use unicode in your project, you need to make the following declarations in your project:

 * 1) define UNICODE
 * 2) define _UNICODE
 * 3) include
 * 4) include

Some header files include a mechanism like the following, so that when one of the two UNICODE macros is defined, the other is automatically defined as well:

#ifndef _UNICODE #define _UNICODE #endif
 * 1) ifdef UNICODE
 * 1) endif

#ifndef UNICODE #define UNICODE #endif
 * 1) ifdef _UNICODE
 * 1) endif

If you are writing a library that utilizes UNICODE, it might be worthwhile for you to include this mechanism in your header files as well, so that other programmers don't need to worry about including both macros. It's generally a pitfall to define only one of both macros, so watch out!

TEXT macro
In C, to make a string of wide characters, you need to prefix the string with the letter "L". Here is an example:

char *asciimessage = "This is an ASCII string."; wchar_t *unicodemessage = L"This is a Wide Unicode string.";

The data type "TCHAR" is defined as being a char type if unicode is not defined, and is defined as being a wide type if UNICODE is defined (in tchar.h). To make strings portable between unicode and non-unicode, we can use the TEXT macro to automatically define a string as being unicode or not:

TCHAR *automessage = TEXT("This message can be either ASCII or UNICODE!");

Using TCHAR data types, and the TEXT macro are important steps in making your code portable between different environments.

Also, the TEXT macro can be written as:

TEXT("This is a generic string"); _T("This is also a generic string"); T("This is also a generic string");

All three of these statements are equivalent.

The TEXT macro is typically defined like this:

 * 1) ifdef UNICODE
 * 2) define TEXT(t) L##t
 * 3) define _T(t) L##t
 * 4) define T(t) L##t
 * 5) else
 * 6) define TEXT(t) t
 * 7) define _T(t) t
 * 8) define T(t) t
 * 9) endif

Unicode Reference

 * see Unicode

Control Characters
Unicode characters 0 to 31 (U+0000 to U+001F) are part of the C0 Controls and Basic Latin block. They are all control characters. These characters correspond to the first 32 characters of the ASCII set.

Beware: Control characters have different meaning in Windows API compared to command-line programs! Often, control characters are not processed at all and displayed like non-printable characters, see ExtTextOut and all GDI functions. For USER functions like DrawText, MessageBox and multi-line buttons, '\n' is processed to break text into lines. For menus, '\a' and '\t' has special meaning and is preprocessed. To ring the bell, '\a' never works. Use Beep or sndPlaySound for this.

Next Chapter

 * Dynamic Link Libraries (DLL)

title: Windows Programming/Unicode


text:
User:לערי ריינהארט/monobook.js

/* commons:, meta:, b:, n:, q:, s:, wikt:, w: /* Work-around for 01229 */ /* source: w:en:Wikipedia:WikiProject User scripts/Scripts/Fix diff width This script adds scroll bars to wide diffs such as. It replaces the table-based diff layout with a CSS-based layout where the column width is always exactly 50%. Known to work in Firefox, Konqueror, Opera and at least some versions of Internet Explorer. This script is a workaround for Bug 01229. If you have any problems with this script, please let me know. */

// // inline style sheet to keep this whole thing self-contained: document.write('' +   ' .xdiff { width: 100%; background: white; }' +    ' .xdiff-row { width: 100%; margin: 0 0 3px 0; overflow: hidden; }' +    ' .xdiff-col { width: 49%; margin: 0; float: left; clear: none; position: relative; }' +    ' .xdiff-sign, .xdiff-outer, .xdiff-inner { display: block; margin: 0; }' +    ' .xdiff-sign { position: absolute; top: 0; left: 0; width: 2em; text-align: center; }' +    ' .xdiff-outer { padding: 0 0 0 2em; }' +    ' .xdiff-inner { overflow: auto; overflow-y: visible; width: 100%; }' +    ' .xdiff-inner.diff-addedline { font-size: 85%; background: #cfc; }' +    ' .xdiff-inner.diff-deletedline { font-size: 85%; background: #ffa; }' +    ' .xdiff-inner.diff-context { font-size: 85%; background: #eee; }' +    (!document.recalc ? '' : // IE kluge: ' * html .xdiff-inner { padding-bottom: expression(this.scrollWidth > this.offsetWidth ? "16px" : 0); }' + ' * html .xdiff-sign { top: expression((this.parentNode.clientHeight - this.offsetHeight)/2 + "px"); }') +   '<'+'/style>');

$(function {    var diffSigns = new Array;    var fixDiffWidth = function  {        var tables = document.getElementsByTagName('table');

for (var i = 0; i < tables.length; i++) { if (tables[i].className != 'diff') continue; var rows = tables[i].getElementsByTagName('tr');

var diffDiv = document.createElement('div'); diffDiv.className = 'xdiff';

for (var j = 0; j < rows.length; j++) { var rowDiv = document.createElement('div'); rowDiv.className = 'xdiff-row';

var colDiv = null; var cols = rows[j].getElementsByTagName('td'); for (var k = 0; k < cols.length; k++) { if (!colDiv) { colDiv = document.createElement('div'); colDiv.className = 'xdiff-col'; rowDiv.appendChild(colDiv); }                   if (cols[k].getAttribute('colspan') == 2 || cols[k].className.substring(0,5) == 'diff-') { // use spans instead of divs so that an eventual non-js solution will look nice in lynx! var outerSpan = document.createElement('span'); var innerSpan = document.createElement('span'); outerSpan.className = 'xdiff-outer'; innerSpan.className = 'xdiff-inner ' + cols[k].className; innerSpan.style.textAlign = cols[k].getAttribute('align'); for (var node = cols[k].firstChild; node; node = node.nextSibling) innerSpan.appendChild(node.cloneNode(true)); innerSpan.appendChild(document.createTextNode(String.fromCharCode(0xa0))); // add nbsp outerSpan.appendChild(innerSpan); colDiv.appendChild(outerSpan); colDiv = null; // start new column }                   else if (cols[k].firstChild && (cols[k].firstChild.nextSibling || cols[k].firstChild.nodeType != 3 || cols[k].firstChild.nodeValue.match(/\S/))) { // use spans instead of divs so that an eventual non-js solution will look nice in lynx! var signSpan = document.createElement('span'); signSpan.className = 'xdiff-sign'; if (!signSpan.style.setExpression) diffSigns[diffSigns.length] = signSpan; for (var node = cols[k].firstChild; node; node = node.nextSibling) signSpan.appendChild(node.cloneNode(true)); colDiv.appendChild(signSpan); }               }                diffDiv.appendChild(rowDiv); }           tables[i].parentNode.replaceChild(diffDiv, tables[i]); }   };    // finally, a kluge to vertically center the +/- signs var centerDiffSigns = function { for (var i = 0; i < diffSigns.length; i++) { var parentHeight; if (!( parentHeight = diffSigns[i].parentNode )) continue; if (!( parentHeight = parentHeight.clientHeight )) continue; diffSigns[i].style.top = ((parentHeight - diffSigns[i].offsetHeight)/2) + "px"; }   };    fixDiffWidth; if (diffSigns.length) { hookEvent('resize', centerDiffSigns); setTimeout(centerDiffSigns, 250); } });

function bidiSwitchSetup { var editform = document.getElementById("editform"); if (editform == null) { return; }	bidiAddButton(editform, "Default", function(style) {		style.direction = "inherit";		style.unicodeBidi = "inherit";	}); bidiAddButton(editform, "dir=ltr", function(style) {		style.direction = "ltr";	}); bidiAddButton(editform, "dir=rtl", function(style) {		style.direction = "rtl";	}); bidiAddButton(editform, "bidi=normal", function(style) {		style.unicodeBidi = "normal";	}); bidiAddButton(editform, "bidi=override", function(style) {		style.unicodeBidi = "bidi-override";	}); }

function bidiAddButton(before, label, action) { var button = document.createElement("input"); button.type = "button"; button.value = label; button.onclick = function(event) { var box = document.getElementById("wpTextbox1"); if (box == null) { alert("Broken! Edit box missing."); } else { //var style = document.getOverrideStyle(box, null); var style = box.style; action(style); }	}	before.parentNode.insertBefore(button, before); }

hookEvent('load', bidiSwitchSetup);

//

title: User:לערי ריינהארט/monobook.js


text:
Talk:Rosacea

Is this not truly better suited as an article in WikiPedia? How is this a "textbook"? DSYoungEsq 22:44, 30 January 2006 (UTC)

Cover page
Since there seems to be some activity here on this book, I figured I'd not be too bold, but leave a note on it instead. This book has a cover image on the main page and places the main contents on a sub-page. This is discouraged by the Manual of Style. --Swift (talk) 02:13, 1 April 2009 (UTC)

title: Talk:Rosacea


text:
Windows Programming/Message Loop Architecture

WinMain
Programming Windows in C can be a little bit different from what most people are used to. First off, there isn't a main function, but instead there is a _tWinMain function to start your program off. _tWinMain is defined as a macro in tchar.h as such:

 * 1) ifdef _UNICODE
 * 2) define _tWinMain wWinMain
 * 3) else
 * 4) define _tWinMain WinMain
 * 5) endif

This means that Windows functions can be written easily in Unicode or ASCII. Besides the difference in function name, _tWinMain also has different parameters than the standard main function:

int WinMain(HINSTANCE hThisInstance,               HINSTANCE hPrevInstance,                LPSTR lpszArgument,  // LPWSTR for wWinMain               int iCmdShow);

HINSTANCE objects are references to a program instance. hThisInstance is a reference to the current program, and hPrevInstance is a reference to any previously running versions of this same program. However, in Windows NT, the hPrevInstance data object is always NULL. This means that we can't use the hPrevInstance value to determine if there are other copies of the same program running on your system. There are different ways of checking for other copies of a program running, and we will discuss those methods later.

lpszArgument essentially contains all the information that the argc and argv variables used to show, except that the command-line arguments are not broken up into a vector. This means that if you want to sort individual arguments from the command line, you need to either break them up yourself, or call one of the available functions to break it up for you. We will discuss these functions later.

The last argument, "int iCmdShow" is a data item of type int (integer) that determines whether or not a graphical window should be displayed immediately, or if the program should run minimized.

WinMain has a number of different jobs:

 * 1) Register the window classes to be used by the program
 * 2) Create any Windows used by the program
 * 3) Run the message loop

We will explain each of those tasks in more detail.

Register Window Classes
Every little graphical detail you see on the screen is known as a "window". Each program with a box around it, each button, each text box are all called windows. In fact, all of these various objects all get created in the same manner. This must mean that there are a large number of options and customizations available in order to get things as different as textboxes and scroll bars from the same method. Each window has an associated "Window Class" that needs to be registered with the system, to specify the different properties of the window. This is done by following 2 steps:

 * 1) Fill in the fields of the WNDCLASS data object
 * 2) Pass the WNDCLASS object to the RegisterClass function.

Also, there is an "extended" version of this procedure, that can be followed with similar results:

 * 1) Fill in the fields of the WNDCLASSEX object
 * 2) Pass the WNDCLASSEX object to the RegisterClassEx function.

Either of these methods can be used to register the class, but the -Ex version has a few more options.

Once the class is registered, you can discard the WNDCLASS structure, because you don't need it anymore.

Create Windows
Creating Windows can be done with the CreateWindow or the CreateWindowEx functions. Both perform the same general task, but again, the -Ex version has more options. You pass some specifics to the CreateWindow function, such as the window size, the window location (the X and Y coordinates), the window title, etc. CreateWindow will return a HWND data object, that is a handle to the newly created window. Next, most programs will pass this handle to the ShowWindow function, to make the window appear on the screen. The way CreateWindow creates a window is as follows: The first parameter WS_EX_CLIENTEDGE is the extended window style. Next we have the class name g_szClassName, this tells the system what kind of window to create. Since we want to create a window from the class we just registered, we use the name of that class. After that we specify our window name or title which is the text that will be displayed in the caption, or title bar on our window. The parameter we have as WS_OVERLAPPEDWINDOW is the Window Style parameter. There are quite a few of these and you should look them up and experiment to find out what they do. The next four parameters (CW_USEDEFAULT,CW_USEDEFAULT,240,120) are the X and Y co-ordinates for the top left corner of your window, and the width and height of the window. The X and Y co-ordinates are set to CW_USEDEFAULT to let the window choose where on the screen to put the window. Next, (NULL,NULL,hInstance,NULL) we have the parent window handle, the menu handle, the application instance handle, and a pointer handle to window creation data. In windows, the window on the screen is arranged in a hierarchy of the parent and child windows. When one sees a button on a window, the button is the Child and it is contained within the window that is it's Parent. In this example, the parent handle is NULL because we have no parent, this is our main or top level window. The menu is NULL for now since we don't have one yet. The instance handle is set to the value that is passed in as the first parameter of the WinMain. The creation data that can be used to send additional data to the window that is being created is NULL.

Message Loop
Once the window is created, the window will interact with the rest of the system by way of messages. The system sends messages to the window, and the window sends messages back. Most programs in fact don't do anything but read messages and respond to them!

Messages come in the form of an MSG data type. This data object is passed to the GetMessage function, which reads a message from the message queue, or waits for a new message from the system. Next, the message is sent to the TranslateMessage function, which takes care of some simple tasks such as translating to Unicode or not. Finally, the message is sent to the window for processing using the DispatchMessage function.

Here is an example:

MSG msg; BOOL bRet; while( (bRet = GetMessage( &msg, NULL, 0, 0 )) != 0) {    if (bRet == -1) {       // handle the error and possibly exit }   else {       TranslateMessage(&msg); DispatchMessage(&msg); } } return msg.wParam;

That last line will be explained later.

The Window Procedure
A window procedure may be named anything you want, but the general prototype for one is as follows:

LRESULT CALLBACK WinProc (HWND hwnd,                           UINT msg,                            WPARAM wParam,                            LPARAM lParam);

An LRESULT data type is a generic 32-bit data object, that can be type-casted to contain any 32-bit value (including a pointer). The hwnd parameter is a handle to the window itself. The msg data value contains the current message from the operating system, and the WPARAM and LPARAM values contain the arguments for that message. For instance, if a button is pressed on the keyboard, the msg field will contain the message WM_KEYDOWN, and the WPARAM field will contain the actual letter pressed ('A' for instance), and the LPARAM field will contain information on whether or not the CTRL, ALT, or SHIFT buttons are down, and whether the type-matic repeat function has been triggered. Several macros have been defined that are very useful in separating out the WPARAM and LPARAM into different sized chunks:

 * LOWORD(x): returns the low 16-bits of the 32-bit argument
 * HIWORD(x): returns the high 16-bits of the 32-bit argument
 * LOBYTE(x): returns the low 8-bits of the 16-bit argument
 * HIBYTE(x): returns the high 8-bits of the 16-bit argument

For instance, to access the 2nd byte in the wParam field, we will use the macros as follows:

HIBYTE(LOWORD(wParam));

Since the window procedure only has two available parameters, these parameters are often packed with data. These macros are very useful in separating that information out into different fields.

Here is an example of a general Window Procedure, that we will explain:

LRESULT CALLBACK MyWinProc (HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) {   switch (msg) {       case WM_DESTROY: PostQuitMessage(0); break; default: return DefWindowProc (hwnd, msg, wParam, lParam); }   return 0; }

Most window procedures only contain a simple loop that searches for particular messages from the system, and then acts on them. In this example, we are only looking for the WM_DESTROY message, which is the message that the kernel sends to the window when the window needs to close. In response to the WM_DESTROY message, the window calls the PostQuitMessage function, which puts a WM_QUIT message (which is defined as 0) into the message queue. When the message loop (described above) gets the WM_QUIT message, it breaks from the loop, and returns the value from the PostQuitMessage function.

Any message that is not handled by the loop should be (must be) passed to the DefWindowProc function. DefWindowProc will perform some default actions based on the messages received, but it won't do anything interesting. If you want your program to do something, you will need to handle these messages yourself.

Messages
There are a few other messages that we will talk about later on:

 * WM_CREATE: Your window receives this message only once, when it is first created. Use this message to perform tasks that need to be handled in the beginning, such as initializing variables, allocating memory, or creating child windows (buttons and textboxes).
 * WM_PAINT: This message indicates that it is time for the program to redraw itself. Use the graphical functions to redraw whatever is supposed to be on the window. If you don't draw anything, then the window will either be a boring white (or grey) background, or if the background was not erased, will keep whatever image is already shown on it (which looks unstable.)
 * WM_COMMAND: This is a general message that indicates that the user has done something on your window. Either the user has clicked a button, or the user has selected a menu item, or the user has pressed a special "Accelerator" key sequence. The WPARAM and LPARAM fields will contain some descriptions on what happened, so you can find a way to react to this. If you do not process the WM_COMMAND messages, the user will not be able to click any buttons, or select any menu items, and that will be very frustrating indeed.
 * WM_CLOSE: The user has decided to close the window, so the kernel sends the WM_CLOSE message. This is the final chance to preserve the window as necessary - if you don't want it closed completely, you should handle the WM_CLOSE message and ensure that it does not destroy the window. If the WM_CLOSE message is passed to the DefWindowProc, then the window will next receive the WM_DESTROY message.
 * WM_DESTROY: The WM_DESTROY indicates that a given window is removed from the screen and will be unloaded from memory. Normally, your program can post the WM_QUIT message to exit the program by calling PostQuitMessage.

These are some of the most basic messages, and we will discuss other messages as the need arises.

- Hint SendMessage(hwnd,MACRO,NULL,NULL) can be used to send user defined messages.

Next Chapter

 * Interfacing


text: Statics/Print version

title: Statics/Print version