Get Ready to Unleash the Power of
UCanCode .NET

UCanCode
Software focuses on general application software development. We provide complete solution for developers. No matter you want to develop a simple database
workflow application, or an large flow/diagram based system, our product will provide a complete solution for you. Our product had been used by hundreds of top companies around the world!

"100% source code provided! Free you from not daring to use components because of unable to master the key technology of components!"

MFC Example Multiple monitor support with
GetSystemMetrics EnumDisplayMonitors and
GetMonitorInfo

Introduction

Awhile back I decided to
write a screensaver
application as a way to pick
up
MFC. After I got
my first implementation up
and running I shipped it off
to a friend. Well the first
thing he noted was a a
glaring bug: he uses
multiple monitors
and my screen saver only
showed up on one.

After some scouring of
the internet and research
into MSDN I was able to to
get the screensaver running
on
multiple monitors
by using some API calls the
were introduced with Windows
98/2000. This project is a
couple of small
MFC
classes that wrap the
multiple-monitor
API.

These classes can be
safely used on Windows
95/NT4 as well. On those
platforms, they just provide
the properties of the one
and only monitor.

Background

Eveyrything you ever
wanted to know about the API
for multiple monitors
is described in a very well
written
article by David Campbell
in the June 1997 issue of
MSJ.

The API itself is simple
and straightforward. It has
some new constants to pass
to GetSystemMetrics
and a couple methods to
enumerate all of the
monitors currently attached
to the system and get the
properties of a given
monitor.

All of the types and
functions are defined by the
platform SDK in the file
multimon.h . If
you #define WINVER
to be greater than 0x400 you don't need
to link to multimon.h,
as the API gets defined in
windef.h for Windows 98 and
later targeted builds. Multimon.h
also provides some stub
functions that allow calls
to be safely made on Windows
95/NT4 machines. These
wrappers interrogate the
runtime OS and either make
fall-through calls into the
actual API or return the
propeties of the one (and
only) monitor on
those older platforms.

The multiple monitor
classes take care of
including multimon.h
correctly depending on the
value of WINVER.

Using the code

CMointor is
a basic
MFC
class that allows you to
safely use the
multiple-monitor
API on any Win32 platform.

There are three classes
in this library:

CMonitors
represents the collection of
monitors
currently attached to the
system and wraps the
EnumDisplayMonitors
API function.