Programming Microsoft Windows Ce Net 3Rd [Electronic resources] نسخه متنی

اینجــــا یک کتابخانه دیجیتالی است

با بیش از 100000 منبع الکترونیکی رایگان به زبان فارسی ، عربی و انگلیسی

Programming Microsoft Windows Ce Net 3Rd [Electronic resources] - نسخه متنی

| نمايش فراداده ، افزودن یک نقد و بررسی
افزودن به کتابخانه شخصی
ارسال به دوستان
جستجو در متن کتاب
بیشتر
تنظیمات قلم

فونت

اندازه قلم

+ - پیش فرض

حالت نمایش

روز نیمروز شب
جستجو در لغت نامه
بیشتر
لیست موضوعات
توضیحات
افزودن یادداشت جدید






GAPI Initialization

An application using GAPI must initialize the GAPI subsystem by calling the following function:

int GXOpenDisplay (HWND hWnd, DWORD dwFlags);

The two parameters are the handle to the application's window and a flag parameter that can be either 0 or the constant GX_FULLSCREEN. Using GX_FULLSCREEN indicates to GAPI that the application will assume control over the entire screen. If the flag isn't set, GAPI assumes the application won't be overwriting the navigation bar. GXOpenDisplay should be called only once during the life of an application. Subsequent calls will fail.


Getting Display Information


GAPI provides three functions to query the hardware support. The first function, GXGetDisplayProperties, returns information about the display and is prototyped as

GXDisplayProperties GXGetDisplayProperties();

The function returns a GXDisplayProperties structure, defined as

struct GXDisplayProperties {
DWORD cxWidth;
DWORD cyHeight;
long cbxPitch;
long cbyPitch;
long cBPP;
DWORD ffFormat;
};

The first two fields, cxWidth and cyHeight, specify the width and height of the display in pixels. The next two fields, cbxPitch and cbyPitch, specify the distance, in bytes, between adjacent pixels in the frame buffer. For example, if the application has a pointer to pixel x and needs to address the pixel to the immediate right of the current pixel, the address would be at the current address plus the value in cbxPitch. To access the pixel immediately below the current pixel, the value in cbyPitch would be added to the address of the current pixel. These values aren't necessarily obvious and can even be negative depending on the layout of the frame buffer.

For frame buffers that have less than 8 bits per pixel (bpp), the addressing is somewhat more complex. In these cases, the pixel offset must be divided by the pixels per byte, which in a 4-bpp display is 8 / 4 = 2. So the formula to compute the address in the frame buffer of a pixel that has a 4-bpp display would be

pPxl = frame_base + ((x / 2) + (y * cbyPitch));

This line isn't complete. To get to the specific pixel, the application has to read the byte, modify only the appropriate upper or lower half, and then write the byte back. This example also assumes the frame buffer is in a portrait configuration, in which the adjacent bytes of the display are on the same row. In a landscape configuration, adjacent bytes are in the same column.

The final field in the GXDisplayProperties structure is the ffFormat field, which describes the format of the frame buffer. The flags in this field are



kfLandscapeThe frame buffer is oriented on its side. Sub-8bpp displays have consecutive column pixels in the same byte.



kfPaletteThe frame buffer is palettized.



kfDirectThe frame buffer colors are directly mapped.



kfDirect555The format is a 16 bpp with 5 bits per color.



kfDirect565The format is 16 bpp with 6 bits for green and 5 each for red and blue.



kfDirect888The format is 24 bpp with 8 bits per color.



kfDirectInvertedThe monochrome frame buffer has inverted color format with 1 representing black and 0 representing white.




Querying Button Information


The next informational function, GXGetDefaultKeys, returns the suggested layout for the buttons. The prototype for this function is

GXKeyList GXGetDefaultKeys (int iOptions);

The one parameter is the system orientation: GX_NORMALKEYS for portrait orientation and GX_LANDSCAPEKEYS for landscape orientation.

The structure returned is defined as

struct GXKeyList {
short vkUp;
POINT ptUp;
short vkDown;
POINT ptDown;
short vkLeft;
POINT ptLeft;
short vkRight;
POINT ptRight;
short vkA;
POINT ptA;
short vkB;
POINT ptB;
short vkC;
POINT ptC;
short vkStart;
POINT ptStart;
};

Each field starting with vk in the structure specifies the suggested virtual key code to use for that action. The pt fields represent the physical coordinates of the buttons in relation to the screen.


Accessing the Buttons


When a GAPI application is ready to start its game, it can take control of the buttons on the Pocket PC by calling

int GXOpenInput();

This function redirects all button input to the GAPI application. Clearly, once this function is called it is the responsibility of the GAPI application to provide a way to quit the game and restore the buttons to the system.

/ 169