Common Win32 types and macros

Source: Internet
Author: User

Common Win32 types and macros

Colorref

Hibyte

Hiword

Lobyte

Loword

Makelong

Max

Min

Makeintatom

Makeintresource

Makelparam

Makelresult

Makeword

 

 

Makewparam

Paletteindex

Palettergb

RGB

Colorref
1. Structure Definition
A colorref color value is a long integer that defines a color. A color parameter's GDI function (such as createpen and floodfill) is required to accept the colorref value as the parameter.
2. Structure Description
This type of value has three different forms based on the application's usage of the colorref type value. It can be defined as one of the following three methods:
(1) directly define the RGB Value
The low byte contains the relative intensity value defined in Red: The second byte contains the relative intensity value defined in green, the third byte contains the defined blue value, and the high byte must be zero, the maximum value of a single byte is FF (hexadecimal ). The following table describes the hexadecimal values of some colors:
---- 0x000000ff pure red
---- 0x0000ff00 pure green
---- 0x00ff0000 pure blue
---- 0x00000000 black
---- 0x00ffffff white color
---- 0x00808080 light gray
The RGB macro command accepts values in red, green, and blue colors and returns a displayed rgb_colorref value.
(2) palette Index
When you specify the index of the logical palette, The colorref value has the following hexadecimal format: 0x0100iiii
The two bytes at the low position constitute a 16-bit integer, which defines the index of a logical palette. The third byte is not required, and must be set to 0. The fourth byte (that is, the byte in the upper position) must be set to 1.
For example, the hexadecimal value 0x10000 defines the color represented by a color palette with an index of 0, 0x00000c defines the color represented by an element with an index of 12, and so on.
The paletteindex macro command receives an integer representing the logical palette and returns a colorref value defined as the palette index.
(3) color palette-related RGB
When a colorref value is defined as an RGB value related to the color palette, the value has the following format:
0x02bbggrr
As defined as a direct RGB value, the three bytes at the low position of the value contain the red, green, and blue intensity colors respectively. The byte at the high position must be 2.
For output devices that support the logical palette, Windows will match the RGB values related to the palette with the nearest color in the logical palette in the device description table, it is as if the application defines a table item corresponding to the palette index. If the output device does not support the logical color palette, Windows uses the RGB values related to the color palette as the direct RGB values.
The palettergb macro command receives values that represent red, green, and blue colors and returns a colorref value that represents the color palette index.
3. Description
Before passing a colorref value that represents a palette index or a palette-related colorref value to a function that requires the device to describe table parameters, an application that uses its own palette must put the palette in the device description table (by calling the realizepalette function) and use the palette to become the current palette (by calling the selectpalette function ), this ensures that the function uses the correct color of the table items. For functions that draw an object (such as createpen), the application must first select the color palette into the description table and use it as the current color palette before selecting an object for the device description table.
4. Related functions
See createpen, realizepalette, RGB, selectpalette.

----------------------------------------------------------------------
Hibyte
1. Define the structure
Byte hibyte (ninteger)
This macro command obtains its high byte value from the integer value specified by the ninteger parameter.
2. Parameters
Ninteger specifies the value for conversion
3. Description
The returned value is the high byte of the given value.
The hibyte macro is defined in windows. h as follows:
# Define hibyte (w) (byte) (Word) (W)> 8) & 0xff ))

Hiword
1. Structure Definition
Word hiword (dwinteger)
This macro command obtains its high-level characters from the 32-bit integer specified by the dwinteger parameter.
2. Parameters
Dwinteger: specify the value for conversion.
3. Description
The return value specifies the high value of the given 32-bit integer.
Hiword macros are defined in windows. h as follows:
# Define hiword (I) (Word) (DWORD) (I)> 16) & 0 xFFFF ))

Lobyte
1. Structure Definition
Byte lobyte (wval)
This macro command extracts its low byte from the short integer specified by wval.
2. Parameters
Wval: Specifies the value for conversion.
3. Description
The return value specifies the low byte of the given integer.
The lobyte macro is defined in windows. h as follows:
# Define lobyte (w) (byte) (w ))

Loword
1. Structure Definition
Word loword (dwval)
This macro command extracts all low-level words from a DWORD variable dwval.
2. Parameters
(1) dwval specifies a value for conversion
3. Description
The return value specifies a low number of 32 fully integer characters.
The loword macro is defined in windows. h as follows:
# Define loword (I) (Word) (I ))

Makelong
1. Structure Definition
DWORD makelong (wlow, whing)
Word wlow;
Word whing;
This macro command concatenates two word-type variables wlow and wheight to create an unsigned long integer.
2. Parameters
(1) wlow specifies the low-level word of the new long integer.
(2) whigh specifies the New Long Integer High.
3. Description
The return value specifies an unsigned long integer.
The makelong macro is defined in windows. h as follows:
# Define makelong (A, B) (long) (Word) (a) | (DWORD) (B) <16 ))

Max
1. Structure Definition
Max (value1, value2)
The max macro command compares two values and returns a large value. The data type can be any numeric data type, signed or unsigned. The parameter type is the same as the return value type.
2. Parameters
(1) value1: Specify the first value
(2) value2: Specifies the second value.
3. Description
The return value is value1, which is a large value in value2.
The max macro is defined in windows. h as follows:
# Define max (A, B) (A> B ))? (A) (B ))
4. Related functions
See MIN

Min
1. Define the structure
Min (value1, value2)
The min macro command compares two values and returns a smaller value. The data type can be any numeric data type, signed or unsigned. The parameter type is the same as the return value type.
2. Parameters
(1) value1: Specify the first value
(2) value2: Specifies the second value.
3. Description
The return value is value1, which is a large value in value2.
The max macro is defined in windows. h as follows:
# Define min (A, B) (A <B ))? (A) (B ))
4. Related functions
See Max

Makeintatom
1. Structure Definition
Lpstr makeintatom (winteger)
Word winteger
This macro command creates an integer atom representing a decimal number string.
Although the returned value of the makeintatom macro is of the lpstr type, it cannot be used as a string pointer unless it is passed to the atomic management function that requires the lpstr parameter.
The deleteatom function always performs operations on Integer atoms, although it does not do anything. The string returned by the getatomname function is a string ending with null. Its first character is "#", and the remaining characters are the word used in the makeintatom macro.
This macro is defined in WINBASE. h as follows:
# Define makeintatom (I) (lpstr) (DWORD) (Word) (I )))

Makeintresource
1. Structure Definition
Lpstr makeintresource (ninteger)
The makeintresource macro converts an integer to a resource type compatible with Windows resource management functions. This macro is used to replace a string containing the Resource Name.
2. Parameters
Ninteger: Specifies the integer used for conversion.
3. Description
The returned value can only be passed to Windows resource management functions as the lptype parameter.
The makeintresource macro is defined in windows. h as follows:
# Define makeintresource (I) (lptstr) (DWORD) (Word) (I )))

Makelparam
1. Structure Definition
Lparam makelong (wlow, whigh)
Word wlow;
Word whigh;
This macro command concatenates two word-type variables wlow and whigh to create an lparam-type value (long integer), which is used in the Message Parameter lparam.
2. Parameters
(1) wlow: Specify the low level of the new lparam.
(2) whigh: Specify the high level of the new lparam.
3. Description
The return value specifies that an lparam macro is defined in winuser. H, as follows:
# Define makelparam (L, H) (lparam) makelong (L, H ))

Makelresult
1. Structure Definition
Lresult makelresult (wlow, whigh)
Word wlow;
Word whigh;
This macro command concatenates two word-type variables wlow and whigh to create a value of the wparam type (long integer), which is used in the Message Parameter wparam.
2. Parameters
(1) wlow: Specify the low level of the new lresult.
(2) whigh: Specifies the high character of the new lresult.
3. Description
The return value specifies an lresult value.
The makelresult macro is defined in winuser. H, as follows:
# Define makelresult (L, H) (lresult) makelong (L, H ))

Makeword
1. Structure Definition
Word makeword (blow, bhigh)
Byte blow;
Byte bhigh;
This macro command concatenates two byte variables blow and bhihg to create an unsigned integer.
2. Parameters
(1) blow specifies the low byte of A New integer
(2) bhigh specifies the high byte of A New integer
3. Description
The return value specifies an unsigned integer.
Makeword macro is defined in windows. h as follows:
# Define makeword (A, B) (Word) (byte) (a) | (Word) (byte) (B) <8 ))

Makewparam
1. Structure Definition
Wparam makewparam (wlow, whigh)
Word wlow;
Word whigh;
This macro command concatenates two word-type variables wlow and whigh to create a value of the wparam type (long integer), which is used in the Message Parameter wparam.
2. Parameters
(1) wlow: Specify the low-level word of the new wparam.
(2) whigh: Specifies the upper level of the new wparam.
3. Description
The return value specifies that a wparam macro is defined in winuser. H, as follows:
# Define makewparam (L, H) (lparam) makelong (L, H ))

Paletteindex
1. Structure Definition
Colorref paletteindex (npaletteindex)
This macro takes the index of a logical palette table item as a parameter and returns a value with its high byte being 1 and low byte being the index value of the palette table item, it is called the index specifier of the logical palette table item. The application that uses the palette can pass this specifier without directly specifying the RGB value. This allows the application to use the color in this palette table item.
2. Parameters
Npaletteindex: Specifies the index of the palette table item. The color palette contains the color to be used for graphic operations.
3. Description
The return value is a logical color palette index indicator. When this logical color palette is used, the application can use this identifier to replace RGB values with the color-required GDI function.
The paletteindex macro is defined in windows. h as follows:
# Define paletteindex (I) (colorref) (0x0000000 | (DWORD) (Word) (I )))

Palettergb
1. Structure Definition
Colorref palettergb (cred, cgreen, cblue)
This macro command accepts three values indicating the relative strength of red, green, and blue, and then returns the return value of the three bytes indicating the high value of 2 and the low value of RGB, this is called the RGB identifier relative to the color palette. The application that uses the color palette can use this identifier to replace the exact RGB value and transmit it to the function of the desired color.
2. Parameters
(1) cred specifies the red intensity
(2) cgreen specifies the green intensity
(3) cblue specifies the blue intensity
3. Description
For the output device that supports the logical palette, windows matches the color closest to the RGB color in the logical palette in the device description table. If the output device does not support the system palette, in Windows, the relative RGB value of the color palette is used in the same way as that of the conventional rgb dword returned by the RGB macro command.
Return Value: Specifies the relative RGB value of the color palette.
The palettergb macro is defined in wingdi. H, as follows:
# Define palettergb (R, G, B) (0x02000000 | RGB (R, G, B ))

RGB
1. Structure Definition
Colorref RGB (byte bred, byte bgreen, byte bblue)
This macro command selects an RGB color based on the color types provided by the three parameters and the color features of the output device.
2. Parameters
(1) cred specifies the red intensity
(2) cgreen specifies the green intensity
(3) cblue specifies the blue intensity
3. Description
The return value specifies the selected RGB color. Each parameter can be obtained from 0 to 255. If all three parameters are 0, the returned result is black. If all parameters are 255, the returned result is white. For more information about the color values used in the color palette, see the macro paletteindex and palettergb.
The RGB macro is defined in wingdi. h as follows:
# Define RGB (R, G, B) (DWORD) (byte) (R) |/
(Word) (g) <8) |/
(DWORD) (byte) (B) <16 )))

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.