Date: 02-16-2022
Return to Index
created by gbSnippets
'There are thousands of API, but the list of those used frequently by
'PowerBASIC programmers is much shorter. Here are the ones I've found
'myself using frequently. These are grouped by the section at MSDN
'where the API are discussed.
'Example usage is found at the bottom of this page, as well as in
'other snippets in this library.
'The "Under" comment refers to the MSDN category under which a discussion
'of the API can be found. The URL of the reference is supplied.
'Under Cursor http://msdn.microsoft.com/en-us/library/ms646970(VS.85).aspx
GetCursorPos - Get cursor (screen coord)
SetCursorPos - Set cursor (screen coord)
'Under GDI http://msdn.microsoft.com/en-us/library/dd145203%28VS.85%29.aspx
ClientToScreen - convert Client to screen coordinates
ScreenToClient - convert screen to Client coordinates
MapWindowPoints - Window-to-Window, screen-to-Window, Window-to-screen
'Under Windows http://msdn.microsoft.com/en-us/library/ms632595(VS.85).aspx
WindowFromPoint - retrieves Handle to Window containing a specified point
ChildWindowFromPoint - returns Child Window which contains the specified point
GetParent - gets Handle to 's parent
FindWindow - Get Handle of Window with matching Class Name AND Window Name (caption)
IsIconic - determine If Window is minimized
IsZoomed - determine If Window is maximized
'Under Dialogs http://msdn.microsoft.com/en-us/library/ms632588(VS.85).aspx
GetDlgItem - gets Control Handle From hDlg/Control ID
GetDlgCtrlID - gets Control ID From Control Handle
'Under Keyboards http://msdn.microsoft.com/en-us/library/ms645530(VS.85).aspx
GetFocus - returns Handle to Window with keyboard Focus
SetFocus - sets the keyboard Focus to the specified Window
'Example Usage:
GetCursorPos -'Retrieves the cursor's position, in screen coordinates.
'code example
Local P as Point
GetCursorPos P 'p.x and p.y are in screen coordinates
SetCursorPos -'set the cursor's position, in screen coordinates.
'code example
Local x as Integer, y as Integer
SetCursorPos x,y 'x and y are in screen coordinates
ScreenToClient - 'converts the screen coordinates of a specified point on the screen to client coordinates.
'code example
Local P as Point
GetCursorPos P 'x and y are in screen coordinates
ScreenToClient hDlg, P 'x and y are now dialog client coordinates
ClientToScreen - 'converts the client coordinates of a specified point to screen coordinates.
'code example
Local P as Point
GetCursorPos P 'p.x and p.y are in screen coordinates
ScreenToClient hDlg, P 'p.x and p.y are now dialog client coordinates
ClientToScreen hDlg, P 'p.x and p.y are back to screen coordinates
MapWindowPoints - 'converts, or maps, a set of points from a coordinate space relative
'to one window to a coordinate space relative to another window.
'code example
Local P(5) as Point
MapWindowPoints hDlgFrom, hDlgTo, P, 5 'window to window
MapWindowPoints %NUL, hDlgTo, P, 5 'screen to window
MapWindowPoints hDlgFrom, %NUL, P, 5 'window to screen
WindowFromPoint - 'retrieves handle to window containing a specified point
'code example
Local P as Point
p.x = 500 : p.y = 500 'screen coordinates
hDlg = WindowFromPoint( p.x, p.y )
ChildWindowFromPoint - 'returns child window which contains the specified point
'code example
Local P as Point
p.x = 500 : p.y = 500 'client coordinates
hChild = ChildWindowFromPoint( hDlg, p.x, p.y )
GetParent - 'gets handle to window's parent
'code example
hParent = GetParent( hChild)
FindWindow - 'get handle of window with matching class name and window name (caption)
'code example
Local cName as AsciiZ*%Max_Path, wName as AsciiZ*%Max_Path
hDlg = FindWindow( cName, wName ) 'wName is Window caption
hDlg = FindWindow( cName, %NUL ) 'any Window caption accepted
IsIconic - 'determine if window is minimized
'code example
iResult& = IsIconic( hDlg )
IsZoomed - 'determine if window is maximized
'code example
iResult& = IsZoomed( hDlg )
GetDlgItem - 'gets control handle from hDlg/control ID
'code example
hControl = GetDlgItem( hDlg, %ID_Control)
GetDlgCtrlID - 'gets control ID from control handle
'code example
CtrlID = GetDlgCtrlID ( hControl )
GetFocus - 'returns handle to window/control with keyboard focus
'code example
iResult& = GetFocus
SetFocus - 'set the keyboard focus to the specified Window/control
'code example
SetFocus hTextBox
'gbs_00004
'Date: 03-10-2012
http://www.garybeene.com/sw/gbsnippets.htm