Skip to content

Instantly share code, notes, and snippets.

@kou1okada
Last active November 1, 2018 07:06
Show Gist options
  • Save kou1okada/819f2852926d1c1501671a563ed962d0 to your computer and use it in GitHub Desktop.
Save kou1okada/819f2852926d1c1501671a563ed962d0 to your computer and use it in GitHub Desktop.
maginfo - An example of Windows Magnification API

maginfo

Display information of current magnification status.

This program is just an example of Microsoft Windows Magnification API.

Build and run

Type below commands on cygwin environment.

make
./maginfo

An example of result.

$ make
g++ -o maginfo maginfo.cpp `cygpath -S`/Magnification.dll
$ ./maginfo
MagInitialize: 1
maglevel     : 2.000000
offset       : 1080, 555
source rect  : -840, 555, 4280, 1635
target rect  : -3840, 0, 6400, 2160

Copyright

(c) 2018 Koichi OKADA. All rights reserves.

License

MIT licese.

#include <cstdio>
#include <cstdlib>
#include <windows.h>
#include <magnification.h>
#ifdef __cplusplus
extern "C" {
#endif
BOOL MagInitialize(
);
BOOL MagGetFullscreenTransform(
float *pMagLevel,
int *pxOffset,
int *pyOffset
);
BOOL MagGetInputTransform(
BOOL *pfEnabled,
LPRECT pRectSource,
LPRECT pRectDest
);
#ifdef __cplusplus
};
#endif
int main(int argc, char *argv[])
{
BOOL fResult;
fResult = MagInitialize();
printf("MagInitialize: %d\n", fResult);
float magLevel;
int xOffset, yOffset;
fResult = MagGetFullscreenTransform(&magLevel, &xOffset, &yOffset);
if (fResult) {
printf("maglevel : %f\n", magLevel);
printf("offset : %d, %d\n", xOffset, yOffset);
}
BOOL fInputTransformEnabled;
RECT rcSource;
RECT rcTarget;
fResult = MagGetInputTransform(&fInputTransformEnabled, &rcSource, &rcTarget);
if (fResult) {
printf("source rect : %d, %d, %d, %d\n", rcSource.left, rcSource.top, rcSource.right, rcSource.bottom);
printf("target rect : %d, %d, %d, %d\n", rcTarget.left, rcTarget.top, rcTarget.right, rcTarget.bottom);
}
return EXIT_SUCCESS;
}
.PHONY: all clean
TARGETS=maginfo
LIBS=`cygpath -S`/Magnification.dll
all: $(TARGETS)
maginfo: maginfo.cpp
$(CXX) -o $@ $< $(LIBS)
clean:
-rm $(TARGETS)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment