Can not run the functions of Microsoft's API Magnification in C

I took from this page: http://msdn.microsoft.com/en-us/library/ms692402%28v=vs.85%29.aspx#initializing_the_magnifier_run-time_library

This function example:

BOOL SetZoom(float magnificationFactor)
{
    // A magnification factor less than 1.0 is not valid.
    if (magnificationFactor < 1.0)
    {
        return FALSE;
    }

    // Calculate offsets such that the center of the magnified screen content 
    // is at the center of the screen. The offsets are relative to the 
    // unmagnified screen content.
    int xDlg = (int)((float)GetSystemMetrics(
            SM_CXSCREEN) * (1.0 - (1.0 / magnificationFactor)) / 2.0);
    int yDlg = (int)((float)GetSystemMetrics(
            SM_CYSCREEN) * (1.0 - (1.0 / magnificationFactor)) / 2.0);

    return MagSetFullscreenTransform(magnificationFactor, xDlg, yDlg);
}

And I just did - Copy - Paste into Dev-C++

But when I compile this code I get an error:

'BOOL' does not name a type 

What did I do wrong?

Answers


First of all, the error message is telling you that the compiler doesn't know what BOOL means. This is not a built-in keyword in C++. Windows programs often use BOOL because it is defined in the windows.h header file. In order to use it, you must #include this file.

To explain a little bit further, the example code as given is not meant to be a complete program. There are several pieces missing in order to compile and run it:

  1. You need to #include <windows.h>.

  2. You need a main() or a WinMain() function which tells the computer where your program starts. Usually WinMain() is used for Windows programs and often contains a loop to start event handling.

  3. (optionally) You need a WinProc() function if you want to handle events and create a UI.

This assumes using the WinAPI. If you want to use MFC instead, you need similar setup code, but I am unfamiliar with the details. Programming with the WinAPI or MFC is fairly complex. You first need to learn the ins and outs of the C and/or C++ languages before venturing into this area.


Need Your Help

JavaScript Multidimensional arrays - column to row

javascript multidimensional-array

Is it possible to turn a column of a multidimensional array to row using JavaScript (maybe Jquery)? (without looping through it)

What is the need of Void class in Java

java void

I am not clear with the class java.lang.Void in Java. Can anybody elaborate in this with an example.

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.