VB Programming Basics Course
What is APIAPI text browser
API function declaration data type and "type safety"
constant structure
Summarize some API function sets: control and message functions, hardware and system functions, menu functions, drawing functions
What is API
First of all, it is necessary to tell everyone what an API is. The so-called API was originally written for C and C++ programmers. To put it simply, API is a kind of function. They are included in an additional dynamic link library file called DLL. According to the standard definition, API is the 32-bit application programming interface of Windows. It is a series of very complex functions, messages and structures. It allows programmers to use different types of programming languages to compile programs that run on Windows 95 and Windows NT. applications on the system. It can be said that if you have ever studied VC, API is not a problem for you. But if you have not learned VC, or you are not familiar with the structure of Windows95, then it can be said that learning API will be a very hard thing.
If you open the SYSTEM folder of WINDOWS, you can find that there are many additional files named DLL. A DLL contains not just one API function, but dozens or even hundreds. Can we all master it? The answer is no: it is impossible to master it. But in fact, we really don’t need to master them all. We just need to focus on mastering the API functions that come with the Windos system itself. However, functions that duplicate VB's own functions should also be discarded. For example, VB
The etAttr command can get file attributes, and SetAttr can set file attributes. There are also corresponding functions for the API
GetFileAttributes and SetFileAttributes have similar performance. After such a calculation, there are only 500 or 600 left. Yes, quite a few. However, I can dare to tell you that as long as you master 100 of them familiarly, your programming level will be at least twice as high as it is now. Although people say that VB and WINDOWS have a close relationship, I think that API is closer
WINDOWS. If you learn the API, the first gain is your understanding of the WINDOWS architecture. This gain is not easy.
What would happen if you didn't rely on APIs? I can tell you that most of them are advanced programming books (of course, this is not because the title of the book is "advanced" but "advanced" in the "Contents of this Book" at the beginning). The books are intended for readers with a certain VB foundation), and the first questions usually start with the API. Therefore, it can be said that if you don’t learn API, you will probably stay at the junior level and be unable to climb up. The only way may be to ask for help from others: I am dying, come and save me, what should I do with this, what should I do with that? Are you annoyed? Of course, there are too many good people online now (including me, hehe) , but you should understand that through this method, you will not be able to produce good works in your hands. This is because without this knowledge you cannot form an overall design concept in your mind.
API text browser[return]
Many API functions are very long. Want to see what it looks like? Here is the APIDdeClientTransaction function as an example:
DeclareFunctionDdeClientTransactionLib"user32"(pDataAsByte,ByValcbDataAsLong,ByValhConvAsLong,ByValhszItemAsLong,ByValwFmtAsLong,ByValwTypeAsLong,ByValdwTimeoutAsLong,pdwResultAsLong)AsLong
Wow! So long? If you have never been exposed to API, I think you must be intimidated. You may be thinking about whether you should continue learning. But don't worry, fortunately Microsoft designers provide us with useful tools, this is the API
Text viewer.
Through the API text viewer, we can easily find the function declarations, structure types and constants required by the program, then copy it to the clipboard, and finally paste it into the code segment of the VB program. In most cases, as long as we determine the three aspects of functions, structures and constants required by the program, we can add them to the program segment through the above operations on the API text browser, so that these can be used in the program. function. These are the most basic common sense questions for learning API, and they are far less than the huge system content of API. Where will we waste our energy in the future (this is by no means a waste)? That is:
When to use which function, when to use what structure type, when to use what constant.
API function declaration
Let's think back. In VB, how to declare a function? I think if you are reading this article, then you can definitely answer this question. Here is a function declaration that should be familiar to you:
FunctionSetFocus(ByValhwndAsLong)AsLong
That is, this line of code defines a function named SetFocus. This function has a parameter of Long data type and is passed by value (ByVal). After the function is executed, a Long data will be returned.
The declaration of API functions is also very similar. For example, the SetFocus function in the API is written like this:
DeclareFunctionSetFocusLib"user32"Alias"SetFocus"(ByValhwndAsLong)AsLong
It's a little more complicated. Yes, it's a little more complicated. But I can tell you that except for these extra parts, the other parts are still the same as what you learned before. The same goes for function calls in programs. like:
DimdlAsLong
dl&=SetFoucs(Form1.Hwnd)
But, one thing is clear. It is not like a program you write yourself where you can see the operating mechanism, nor is it like VB
Like the built-in functions, you can find out their usage from VB's online help. The only way is to learn and look up information other than VB.
The Declare statement is used to declare a reference to an external procedure in a dynamic link library (DLL) at the module level. For this, you just need to remember that any API function declaration must write this statement.
Iib indicates the dynamic link library or code resource that contains the declared procedure or function. In other words, it explains the question of where the function or process comes from.
As in the above example, SetFocusLib "user32" indicates that the function SetFocus comes from the user32.dll file. The main dll dynamic link library files are:
user32.dllWindows management. Generate and manage the application's user interface.
GDI32.dll graphics device interface. Produce graphical output for Windows devices
Kernel32.dll system service. Access the operating system's computer resources.
Note that when the DLL file is not in the Windows or System folder, its source must be stated in the function (
path). For example, SetFocusLib "c:/Mydll/user32"
Alias in function declarations are optional. Indicates that the procedure to be called has another name (alias) in the dynamic link library (DLL). For example, Alias "SetFocus" indicates that the other name of the SetFocus function in User32.dll is,
SetFocus. Why are the two names the same? Of course, they can also be different. In many cases, the function name described by Alias, that is, the last character of the alias is often the character A. For example, another name of the SetWindowsText function is
SetWindowsTextA, expressed as Alias "SetWindowsTextA". This A is just a naming convention used by designers, indicating that the function belongs to the ANSI version.
So, what exactly is the use of aliases? In theory, aliases provide functional methods for calling APIs with another name. If you specify an alias, then although we call the function according to the function after the Declare statement, the alias is the first choice for the actual call of the function. For example, the following two function (Function, ABCD) declarations are valid, and they call the same SetFocus function:
DeclareFunctionSetFocusLib"user32""SetFocus"(ByValhwndAsLong)AsLong
DeclareABCDSetFocusLib"user32"Alias"SetFocus"(ByValhwndAsLong)AsLong
It should be noted that when choosing Alias, you should pay attention to the case of the alias; if you do not choose Alias, the function name must pay attention to the case and cannot be changed. Of course, in many cases, since the function declaration is directly from the API
It is copied from the text browser, so the chance of this error happening is very small, but it is necessary for you to know this.
One final reminder, API declarations (including structures and constants) must be placed in the "GeneralDeclarations" section of the form or module.
Data types and "type safety"
The data types used in API functions are basically the same as those in VB. But as an API function of WIN32, Integer does not exist
Data type. Another point is that the Boolean data type cannot be seen in API functions. The Variant data type appears in the form of Any in API functions, such as DataAsAny. Although the implication is that any parameter type is allowed to be passed as a parameter of this API function, there are certain disadvantages in doing so. The reason is that this will turn off all type checking of the target parameters. This naturally creates opportunities for errors in various types of parameter calls.
In order to enforce strict type checking and avoid the problems mentioned above, one way is to use the Alias technology mentioned above in the function. For example, another declaration method can be used for the API function GetDIBits. As follows:
Prototype of GetDIBits function:
PublicDeclareFunctionGetDIBitsLib"gdi32"Alias"GetDIBits"(ByValaHDCAsLong,ByValhBitmapAsLong,ByValnStartScanAsLong,ByValnNumScansAsLong,lpBitsAsAny,lpBIAsBITMAPINFO,ByValwUsageAsLong)AsLong
Modification of GetDIBits function:
PublicDeclareFunctionGetDIBitsLongLib"gdi32"Alias"GetDIBits"(ByValaHDCAsLong,ByValhBitmapAsLong,ByValnStartScanAsLong,ByValnNumScansAsLong,lpBitsAsLong,lpBIAsBITMAPINFO,ByValwUsageAsLong)AsLong
Through the knowledge learned earlier in this course, we can already know that whether the prototype GetDIBits function or the modified GetDIBitsLong function will actually call the original GetDIBits function specified by Alias. But you should see that the difference between the two is that we force the lpBits parameter to be Long in the modified function. This will minimize the chance of errors occurring in function calls. This approach is called a "safe type" declaration.
The data types often seen in API functions are: Long, String, Byte, Any.... (That's it.)
constant
There is nothing too special about API constants. Please look at the following code in VB:
Msg=MsgBox("Hello",vbOKCancel)
We know that the value of the constant vbOKCancel is equal to 1. We can write the above code like this without affecting the function of the code:
Msg=MsgBox("Hello",1)
But you may not be willing to choose the latter option, because it will make it difficult to understand the code. This approach is also taken by the API. It’s just that the API constants must be initialized and declared before the event, which VB itself cannot understand. Its content still comes from the API
Text browser. The specific form is as follows:
PublicConstABM_ACTIVATE=&H6
PublicConstRIGHT_CTRL_PRESSED=&H4
PublicConstRPC_E_SERVER_DIED=&H80010007
PrivateConstRPC_S_CALL_FAILED_DNE=1727&
In the initialization of constants, some programs use Global, such as GlobalConstABM_ACTIVATE=&H6, but I think Public can completely replace it. I have used Global in the past, but not much now. If you use this one now and that one now, you can't maintain consistency between the programs, or at least it looks awkward.
structure[return]
Structure is the language of C and C++. Generally called custom data types in VB. Presumably many friends already know it. In the API field, I prefer to call it a structure, because the various structure types of the API are not defined by me at all (
customized).
In VB, the API structure is also defined by the TYPE....ENDTYPE statement. For example, in the API, the point structure is defined as follows:
PublicTypePOINTAPI
XAsLong' coordinate value of point on X coordinate (abscissa)
YAsLong'The coordinate value of the point on the Y coordinate (ordinate)
EndType
For another example, the definition of the rectangular (Rect) structure in the API is as follows:
PublicTypeRECT
LeftAsLong'X coordinate of the upper left corner of the rectangle
TopAsLong' Y coordinate of the upper left corner of the rectangle
RightAsLong'X coordinate of the lower right corner of the rectangle
BottomAsLong' Y coordinate of the lower right corner of the rectangle
EndType
This content can also be copied from the API text browser. The variable names in these structures can be changed at will without affecting the structure itself. In other words, these member variables are all virtual. For example, the POINTAPI structure can be changed to the following:
PublicTypePOINTAPI
MyXAsLong'The coordinate value of the point on the X coordinate (abscissa)
MyYAsLong'The coordinate value of the point on the Y coordinate (ordinate)
EndType
However, generally speaking, this is not necessary. The structure itself is a data type. Therefore, when using it, you must declare the specific variable to be of the structure type before you can actually use the structure in the program. The declaration method of the structure is the same as the declaration method of other data. For example, the following statement declares the variable MyPoint as the POINTAPI structure type:
MyPointAsPOINTAPI
It is also very simple to reference the member variables in the structure. Just add a "." after the structure name, and then write the member variable to be referenced. This is much like referencing a property of an object in VB. For example, if we assign the value of the X variable in the MyPoint structure declared above to the variable Temp&
The code is as follows:
Temp&=MyPoint.X
However, it is important to note that you must not think that MyPoint in the above example is a value. It is not a value, but an address (
pointer). Value and address are completely different concepts. Structure requirements are passed by reference to WINDOWS functions, i.e. all APIs
In functions, structures are passed by ByRef (ByRef is the default type in the Declare statement). For passing structures, don't try to use ByVal, you will get nothing. Since the structure name is actually a pointer to the structure (the first address of the structure), you can just transfer the specific structure name (see the summary, I used red font to highlight this transfer method).
Since the structure transfers a pointer, the function will directly read and write the structure. This feature is very suitable for loading the results of function execution into structures.
Summary[return]
The following procedure is given to summarize what has been learned in this lesson. Start VB, create a new project, add a command button, copy the following code into the code segment, and run it.
PrivateDeclareFunctionGetCursorPosLib"user32"(lpPointAsPOINTAPI)AsLong
PrivateTypePOINTAPI'define point structure
XAsLong' coordinate value of point on X coordinate (abscissa)
YAsLong'The coordinate value of the point on the Y coordinate (ordinate)
EndType
SubPrintCursorPos()
DimdlASLong
DimMyPointAsPOINTAPI
dl&=GetCursorPos(MyPoint)'Call the function to get the screen mouse coordinates
Debug.Print"X="&Str(MyPoint.X)&"and"&"Y="&Str(MyPoint.Y)
EndSub
PrivateSubCommand1_Click()
PrintCursorPos
EndSub
The output result is (each run may get different results, which is determined by the position of the mouse pointer on the screen when the function is called):
X=240andY=151
In the program, the GetCursorPos function is used to obtain the position of the mouse pointer on the screen.
In the above example, you can find that the contents of the MyPpint structure passed as parameters have undergone substantial changes after the function call. This is due to the fact that the structure is passed by ByRef.
Some API function sets [return]
WindowsAPI
1. Controls and message functions
AdjustWindowRect Given a window style, calculate the window size required to obtain the target client area rectangle
AnyPopup determines whether there are any pop-ups on the screen
ArrangeIconicWindows arranges minimized child windows of a parent window
AttachThreadInput connection thread input function
BeginDeferWindowPos starts the process of building a series of new window positions
BringWindowToTop brings the specified window to the top of the window list
CascadeWindows arranges windows in a cascading manner
ChildWindowFromPoint returns the handle of the first child window in the parent window that contains the specified point.
ClientToScreen determines the screen coordinates of a point in the window represented by client area coordinates
CloseWindow minimizes the specified window
CopyRect rectangle content copy
DeferWindowPos This function specifies a new window position for a specific window
DestroyWindow clears the specified window and all its child windows
DrawAnimatedRects depicts a series of dynamic rectangles
EnableWindow allows or disables all mouse and keyboard input in the specified window.
EndDeferWindowPos simultaneously updates the positions and status of all windows specified when DeferWindowPos is called.
EnumChildWindows enumerates child windows for the specified parent window
EnumThreadWindows enumerates the windows related to the specified task
EnumWindows enumerates all parent windows in the window list
EqualRect determines whether two rectangular structures are the same
FindWindow finds the first top-level window in the window list that meets the specified criteria
FindWindowEx searches for the first subwindow in the window list that matches the specified conditions
FlashWindow flashes the specified window
GetActiveWindow gets the handle of the active window
GetCapture gets the handle of a window that is located on the current input thread and has mouse capture (mouse activity is received by it)
GetClassInfo obtains a copy of the WNDCLASS structure (or WNDCLASSEX structure), which contains information related to the specified class.
GetClassLong obtains a Long variable entry of the window class
GetClassName gets the class name for the specified window
GetClassWord gets an integer variable for the window class
GetClientRect returns the size of the rectangle in the client area of the specified window
GetDesktopWindow gets a window (desktop window) handle representing the entire screen
GetFocus gets the handle of the window with input focus
GetForegroundWindow gets the handle of the front window
GetLastActivePopup Gets the handle to the most recently activated pop-up window in a given parent window
GetLastError targets the previously called api function. Use this function to obtain extended error information.
GetParent determines the parent window of the specified window
GetTopWindow searches the internal window list for the handle of the first window belonging to the specified window
GetUpdateRect obtains a rectangle that describes the portion of the specified window that needs to be updated
GetWindow obtains the handle of a window that has a specific relationship with a source window
GetWindowContextHelpId gets the help scene ID associated with the window
GetWindowLong obtains information from the structure of the specified window
GetWindowPlacement obtains the status and location information of the specified window
GetWindowRect obtains the range rectangle of the entire window. The window's border, title bar, scroll bar, menu, etc. are all within this rectangle.
GetWindowText gets the title text of a form or the content of a control
GetWindowTextLength investigates the length of the window title text or control content
GetWindowWord obtains information about the specified window structure
InflateRect increases or decreases the size of a rectangle
The IntersectRect function loads a rectangle into lpDestRect, which is the intersection of two rectangles, lpSrc1Rect and lpSrc2Rect.
InvalidateRect blocks all or part of a window's client area
IsChild determines whether a window is a child or subordinate window of another window
IsIconic determines whether the window has been minimized
IsRectEmpty determines whether a rectangle is empty
IsWindow determines whether a window handle is valid
IsWindowEnabled determines whether the window is active
IsWindowUnicode determines whether a window is a Unicode window. This means that the window receives Unicode literals for all text-based messages
IsWindowVisible determines whether the window is visible
IsZoomed determines whether the window is maximized
LockWindowUpdate locks the specified window and prevents it from updating
MapWindowPoints converts points in the client area coordinates of one window to the client area coordinate system of another window
MoveWindow changes the position and size of the specified window
OffsetRect makes the rectangle move by applying a specified offset
OpenIcon restores a minimized program and activates it
PtInRect determines whether the specified point is inside the rectangle
RedrawWindow redraws all or part of the window
ReleaseCapture releases mouse capture for the current application
ScreenToClient determines the client area coordinates of a specified point on the screen
ScrollWindow all or part of the client area of the scroll window
ScrollWindowEx scrolls all or part of the client area of the window, depending on additional options.
SetActiveWindow activates the specified window
SetCapture sets mouse capture to the specified window
SetClassLong sets a Long variable entry for the window class
SetClassWord sets an entry for the window class
SetFocusAPI sets the input focus to the specified window. If necessary, the window is activated
SetForegroundWindow sets the window as the system's front window
SetParent specifies the new parent of a window
SetRect sets the contents of the specified rectangle
SetRectEmpty sets the rectangle to an empty rectangle
SetWindowContextHelpId sets the help scene (context) ID for the specified window
SetWindowLong sets information for the specified window in the window structure
SetWindowPlacement sets window status and position information
SetWindowPos specifies a new position and state for the window
SetWindowText sets the title text of the window or the content of the control
SetWindowWord sets information for the specified window in the window structure
ShowOwnedPopups Shows or hides all pop-up windows owned by the specified window
ShowWindow controls the visibility of a window
ShowWindowAsync is similar to ShowWindow
SubtractRect loads the rectangle lprcDst, which is the result of subtracting lprcSrc2 from the rectangle lprcSrc1
TileWindows arranges windows in tile order
UnionRect loads an lpDestRect target rectangle, which is the result of the union of lpSrc1Rect and lpSrc2Rect
UpdateWindow forces an immediate window update
ValidateRect validates all or part of the client area of the window
WindowFromPoint returns the handle to the window that contains the specified point. Ignore masked, hidden, and transparent windows
2.Hardware and system functions
ActivateKeyboardLayout activates a new keyboard layout. Keyboard layout defines the location and meaning of keys on a physical keyboard
Beep is used to generate simple sounds
CharToOem converts a string from the ANSI character set to the OEM character set
ClipCursor limits the pointer to the specified area
ConvertDefaultLocale converts a special local identifier into a real local ID
CreateCaret creates a caret (cursor) based on the specified information and selects it as the default caret for the specified window
DestroyCaret clears (destroys) a caret
EnumCalendarInfo enumerates the calendar information available in the specified "local" environment
EnumDateFormats enumerates the long and short date formats available in the specified "local" setting
EnumSystemCodePages enumerates the installed or supported code pages on the system
EnumSystemLocales enumerates the "local" settings that the system has installed or provides support for
EnumTimeFormats enumerates the time formats applicable to a specified location
ExitWindowsEx exits windows and restarts with specific options
ExpandEnvironmentStrings expands the environment string
FreeEnvironmentStrings translates the specified environment string block
GetACP determines the ANSI code page currently in effect
GetAsyncKeyState determines the state of the specified virtual key when the function is called
GetCaretBlinkTime determines the blinking frequency of the caret cursor
GetCaretPos determines the current position of the caret
GetClipCursor Gets a rectangle describing the clipping area currently specified for the mouse pointer
GetCommandLine gets a pointer to the current command line buffer
GetComputerName gets the name of this computer
GetCPInfo obtains information related to the specified code page
GetCurrencyFormat formats a number according to the currency format for the specified "local" setting
GetCursor Gets the handle of the currently selected mouse pointer
GetCursorPos gets the current position of the mouse pointer
GetDateFormat formats a system date in a specified "local" format
GetDoubleClickTime determines the time interval between two consecutive mouse clicks that will be processed as a double-click event.
GetEnvironmentStrings allocates and returns a handle to a memory block containing the current environment string settings.
GetEnvironmentVariable gets the value of an environment variable
GetInputState determines whether there are any pending (waiting to be processed) mouse or keyboard events
GetKBCodePage is replaced by GetOEMCP, both functions are exactly the same
GetKeyboardLayout obtains a handle describing the keyboard layout of the specified application
GetKeyboardLayoutList gets a list of all keyboard layouts applicable to the system
GetKeyboardLayoutName gets the name of the currently active keyboard layout
GetKeyboardState gets the current state of each virtual key on the keyboard
GetKeyboardType gets information about the keyboard being used
GetKeyNameText determines the key name given the scan code.
GetKeyState determines the status of the specified virtual key for the keys that have been processed when the information was last input.
GetLastError targets the previously called api function. Use this function to obtain extended error information.
GetLocaleInfo obtains information related to the specified "place"
GetLocalTime gets the local date and time
GetNumberFormat formats a number in a specific format for the specified "place"
GetOEMCP determines the windows code page to convert between OEM and ANSI character sets
GetQueueStatus determines the message type pending (waiting to be processed) in the application message queue
GetSysColor determines the color of the specified windows display object
GetSystemDefaultLangID gets the system's default language ID
GetSystemDefaultLCID gets the current default system "place"
GetSystemInfo obtains information related to the underlying hardware platform
GetSystemMetrics returns information related to the windows environment
GetSystemPowerStatus obtains information related to the current system power status
GetSystemTime obtains the current system time. This time uses the "Coordinated World Time" (i.e. UTC, also called GMT) format.
GetSystemTimeAdjustment synchronizes the internal system clock with an external clock source
GetThreadLocale gets the local ID of the current thread
GetTickCount is used to get the length of time (milliseconds) that has elapsed since Windows started
GetTimeFormat formats a system time in a specific format for the currently specified "place"
GetTimeZoneInformation obtains information related to system time zone settings
GetUserDefaultLangID gets the default language ID for the current user
GetUserDefaultLCID Gets the current user's default "local" settings
GetUserName gets the name of the current user
GetVersion determines the currently running Windows and DOS versions
GetVersionEx obtains version information related to the platform and operating system
HideCaret hides the caret (cursor) in the specified window
IsValidCodePage determines whether a code page is valid
IsValidLocale determines whether the local identifier is valid
The keybd_event function simulates keyboard actions
LoadKeyboardLayout loads a keyboard layout
MapVirtualKey performs different scan code and character conversions based on the specified mapping type.
MapVirtualKeyEx performs different scan code and character conversions based on the specified mapping type.
MessageBeep plays a system sound. The system sound distribution plan is determined in the control panel
mouse_event simulates a mouse event
OemKeyScan determines the scan code and Shift key status of an ASCII character in the OEM character set
OemToChar converts a string from the OEM character set to the ANSI character set
SetCaretBlinkTime specifies the blinking frequency of the caret (cursor)
SetCaretPos specifies the position of the caret
SetComputerName sets a new computer name
SetCursor sets the specified mouse pointer to the current pointer
SetCursorPos sets the position of the pointer
SetDoubleClickTime sets the time interval between two consecutive mouse clicks that the system considers a double-click event.
SetEnvironmentVariable sets an environment variable to a specified value
SetKeyboardState sets the current state of each virtual key on the keyboard
SetLocaleInfo changes user "local" setting information
SetLocalTime sets the current local time
SetSysColors sets the color of the object displayed in the specified window
SetSystemCursor changes any standard system pointer
SetSystemTime sets the current system time
SetSystemTimeAdjustment periodically adds a calibration value to synchronize the internal system clock with an external clock signal source.
SetThreadLocale sets the locale for the current thread
SetTimeZoneInformation sets system time zone information
ShowCaret displays the caret (cursor) in the specified window
ShowCursor controls the visibility of the mouse pointer
SwapMouseButton determines whether to swap the functions of the left and right mouse buttons
SystemParametersInfo gets and sets a large number of windows system parameters
SystemTimeToTzSpecificLocalTime converts system time to local time
ToAscii converts a virtual key into an ASCII character based on the current scan code and keyboard information.
ToUnicode converts a virtual key into a Unicode character based on the current scan code and keyboard information
UnloadKeyboardLayout unloads the specified keyboard layout
VkKeyScan determines the virtual key code and the status of the Shift key based on an ASCII character in the Windows character set
over
3.Menu function
AppendMenu adds a menu item to the specified menu
CheckMenuItem checks or unchecks the specified menu item
CheckMenuRadioItem specifies that a menu item is checked as a "radio" item
CreateMenu creates a new menu
CreatePopupMenu creates an empty popup menu
DeleteMenu deletes the specified menu entry
DestroyMenu deletes the specified menu
DrawMenuBar redraws the menu for the specified window
EnableMenuItem allows or disables specified menu items
GetMenu gets the handle of a menu in the window
GetMenuCheckMarkDimensions returns the size of a menu check mark
GetMenuContextHelpId Gets the help scene ID of a menu
GetMenuDefaultItem determines which item in the menu is the default item
GetMenuItemCount returns the number of items (menu items) in the menu
GetMenuItemID returns the menu ID of the item located at the specified position in the menu
GetMenuItemInfo gets (receives) specific information related to a menu item
GetMenuItemRect loads the screen coordinate information of the specified menu item in a rectangle
GetMenuState obtains information related to the state of the specified menu item
GetMenuString gets the string of the specified menu item
GetSubMenu gets the handle of a pop-up menu, which is located at the specified position in the menu
GetSystemMenu gets the handle of the system menu of the specified window
HiliteMenuItem controls the highlighting state of top-level menu items
InsertMenu inserts a menu entry at the specified position in the menu, moving other entries down as needed
InsertMenuItem inserts a new menu item
IsMenu determines whether the specified handle is a menu handle
LoadMenu loads a menu from the specified module or application instance
LoadMenuIndirect loads a menu
MenuItemFromPoint determines which menu item contains a specified point on the screen
ModifyMenu changes menu entries
RemoveMenu removes the specified menu entry
SetMenu sets the window menu
SetMenuContextHelpId sets the help scene ID of a menu
SetMenuDefaultItem sets a menu item as the default item
SetMenuItemBitmaps sets a specific bitmap to be used in the specified menu item instead of the standard check symbol (√)
SetMenuItemInfo sets the specified information for a menu item
TrackPopupMenu displays a popup menu anywhere on the screen
TrackPopupMenuEx is similar to TrackPopupMenu except that it provides additional functionality
over
The following are several type definitions about menu functions
MENUITEMINFO This structure contains information about menu items
TPMPARAMS This structure is used by the TrackPopupMenuEx function to support additional functionality
4. Drawing function
AbortPath discards all paths selected into the specified device scene. Also cancels any path creation currently in progress
AngleArc draws a line with a connecting arc
ArcDraw an arc
BeginPath starts a path branch
CancelDC cancels a long drawing operation in another thread
Chord draw a chord
CloseEnhMetaFile closes the specified enhanced metafile device scene and returns a handle to the newly created metafile
CloseFigure When drawing a path, close the currently open figure.
CloseMetaFile closes the specified metafile device scene and returns a handle to the newly created metafile
CopyEnhMetaFile makes a copy (copy) of the specified enhanced metafile
CopyMetaFile makes a copy of the specified (standard) metafile
CreateBrushIndirect creates a brush based on a LOGBRUSH data structure
CreateDIBPatternBrush creates a brush using a device-independent bitmap to specify the brush style (pattern)
CreateEnhMetaFile creates an enhanced metafile device scene
CreateHatchBrush creates a brush with a shadow pattern
CreateMetaFile creates a metafile device scene
CreatePatternBrush creates a brush using a bitmap that specifies a brush pattern
CreatePenCreates a brush with the specified style, width and color
CreatePenIndirect creates a pen based on the specified LOGPEN structure
CreateSolidBrush creates a brush with a solid color
DeleteEnhMetaFile deletes the specified enhanced metafile
DeleteMetaFile deletes the specified metafile
DeleteObject deletes the GDI object and all system resources used by the object will be released.
DrawEdge draws a rectangular border using the specified style
The DrawEscape escape function sends data directly to the display device driver
DrawFocusRect draws a focus rectangle
DrawFrameControl draws a standard control
DrawState applies a variety of effects to an image or drawing operation
Ellipse draws an ellipse surrounded by a specified rectangle
EndPath stops defining a path
EnumEnhMetaFile lists individual metafile records for an enhanced metafile.
EnumMetaFile enumerates individual metafile records for a standard windows metafile
EnumObjects enumerates the brushes and brushes that can be used with the specified device scene
ExtCreatePen creates an extended brush (ornamental or geometric)
ExtFloodFill fills an area with the currently selected brush in the specified device scene.
FillPath closes any open shapes in the path and fills them with the current brush
FillRect fills a rectangle with the specified brush
FlattenPath converts all curves in a path into line segments
FloodFill fills an area in the specified device scene with the currently selected brush
FrameRect draws a border around a rectangle using the specified brush
GdiComment adds a comment message to the specified enhanced metafile device scene
GdiFlush performs any pending drawing operations
GdiGetBatchLimit determines how many GDI drawing commands are in the queue
GdiSetBatchLimit specifies how many GDI drawing commands can be queued
GetArcDirection determines the current drawing direction when drawing an arc.
GetBkColor gets the current background color of the specified device scene
GetBkMode obtains the current background fill mode for the specified device scene.
Getbrushorgex judge the current selected brush starting point in the specified equipment scenario
Getcurrentobject obtained the current selection object of the specified type
Getcurrentpositionex obtains the current brush position in the specified device scenario
Getenhmetafile obtained a graphic file handle contained in the disk file
GetenhmetaFileBits copy the specified enhanced graphic file into a memory buffer area in a memory buffer area
Getenhmetafiledescript returns a description of an enhanced graphic file
Getenhmetafileheader obtained the graph file header of the enhanced graphic file
GetenhmetafilepaletteEntries obtained all or partial palettes of enhanced graphic files
Getmetafile obtained the graphic file handle of the graphic file containing a disk file
GetmetafileBitsex copy the specified graphic file to a memory buffer area
Getmiterlimit to obtain the slope limit (Miter) settings of the equipment scenario
GetNearestcolor According to the display ability of the device, GetNearestcolor obtains a solid color closest to the specified color
GetObjectapi obtains a structure that explains the specified object
GetObjectType determines the type of GDI object referenced by the specified handle
Getpath obtains a series of data that defines the current path
Getpixel gets a pixel RGB value in the specified device scenario
Getpolyfillmode obtains polygon fill mode for the designated equipment scenario
Getrop2 obtains the current drawing mode for the designated device scenario
GetstockObject obtained an inherent object (Stock)
Getsyscolorbrush Get a brush for any standard system color
GetWinmetafileBits converts a enhanced graphic file into a standard Windows Graphic File by filling the data used in a buffer
INVERTRECT reverse the value of each pixel, thereby reverse the rectangle specified in a device scenario
Linedda enumeration all points in the specified line segment
Lineto uses the current brush to draw a line, from the current position to a specified point