+----------------------------------------------------------------------+
|                      I * C * E * T * I * P * S                       |
|                                                                      |
|                        Nr 3,  March 5th 1995                         |
|                                                                      |
|                         Presented to you by                          |
|                      Arnor Baldvinsson, ICELAND                      |
+----------------------------------------------------------------------+

Ever wanted to know more about Windows?  Or Windows API calls?  I'm going
to present to you 3 functions, which use Windows API calls to gather 
information about the screen resolution, the Windows version number and
how many colors your CW display is supporting.  The color numbers will
depend on how many colors are defined in the CW Palette.  My card supports
16.8 million colors but this function only retrun 4,096 colors  

Here is a code file which contains those three functions.  First you must
add the prototype to your MAP with the following:

MODULE('WINDOWS.LIB')
  GetSystemMetrics(SHORT),RAW,PASCAL,SHORT          ! Gets info on devices
  GetVersion,RAW,PASCAL,USHORT                      ! Gets version info
  GetDeviceCaps(USHORT,SHORT),RAW,PASCAL,SHORT      ! Gets device info
END

MODULE('WIN_FUNC.CLW')
  GetWindowVersion,STRING
  GetScreenResolution,STRING
  GetNumberOfColors,LONG
END

You will also need to include WIN_FUNC.CLW in you project External Source File
section.  


WIN_FUNC.CLW code file:
-----------------------

             MEMBER('YOUR_APP')

!---------------------------------------------GetScreenResolution
GetScreenResolution     FUNCTION

 CODE
 SCREEN:WIDTH  = GetSystemMetrics(0)
 SCREEN:HEIGHT = GetSystemMetrics(1)
 RETURN(CLIP(SCREEN:WIDTH) & ' ' & CLIP(SCREEN:HEIGHT))

!---------------------------------------------GetWindowVersion
GetWindowVersion        FUNCTION
WV        USHORT
HighBytes USHORT
LowBytes  USHORT

  CODE
  WV = GetVersion()
  HighBytes = BSHIFT(WV,-8)
  WV = BSHIFT(WV,8)
  LowBytes = BSHIFT(WV,-8)
  RETURN(CLIP(LowBytes) & '.' & CLIP(HighBytes+1))

!---------------------------------------------GetNumberofColors
GetNumberofColors       FUNCTION
NOC    LONG        ! NumberOfColors
DC     USHORT      ! Device Context number - retrieved with GetDC API call

  CODE
  DC   = GetDc(0)
  NOC  = GetDeviceCaps(DC,24)    ! 24 = Color resolution in bits per pixel

  Return(NOC)
!-------------------
!END OF WIN_FUNC.CLW


You can now call the functions in code:

SCREEN:WIDTH  = GetSystemMetrics(0)   ! Directly get number of pixels
SCREEN:HEIGHT = GetSystemMetrics(1)   ! Directly get number of pixels
WinVer  = GetWindowVersion()          ! Get Windows version number
NColors = GetNumberOfColors()         ! Get Windows number of colors    
ScrRes  = GetScreenResolution() & ' pixels ' & Format(NColors,@N10.`0) & '
colors'


I'm including the constants you can use with GetSystemMetrics and GetDeviceCaps
functions.  This list is compiled from Turbo Pascal's WINTYPES.PAS file.

Constants you can use with GetSystemMetrics:
--------------------------------------------
!  sm_CXScreen      =  0 - Screen width
!  sm_CYScreen      =  1 - Screen height
!  sm_CXVScroll     =  2 - Vertical scroll bar arrow width
!  sm_CYHScroll     =  3 - Horizontal scroll bar arrow width
!  sm_CYCaption     =  4 - Height of caption
!  sm_CXBorder      =  5 - Frame width of non-sizeable window
!  sm_CYBorder      =  6 - Frame height of non-sizeable window
!  sm_CXDlgFrame    =  7 - Dialog window frame width
!  sm_CYDlgFrame    =  8 - Dialog window frame height
!  sm_CYVThumb      =  9 - Thumb width of vertical scroll bar
!  sm_CXHThumb      = 10 - Thumb width of horizontal scroll bar
!  sm_CXIcon        = 11 - Icon width
!  sm_CYIcon        = 12 - Icon height
!  sm_CXCursor      = 13 - Cursor width
!  sm_CYCursor      = 14 - Cursor height
!  sm_CYMenu        = 15 - Menu height - single line menu
!  sm_CXFullScreen  = 16 - Width of a maximized window's client area
!  sm_CYFullScreen  = 17 - Height of a maximized window's client area
!  sm_MousePresent  = 19 - 0 if no mouse present
!  sm_CYVScroll     = 20 - Vertical scroll bar arrow height
!  sm_CXHScroll     = 21 - Horizontal scroll bar arrow height
!  sm_Debug         = 22 - 0 if Windows version is not debugging version
!  sm_SwapButton    = 23 - 0 if mouse buttons are not swapped
!  sm_CXMin         = 28 - Minimum width of a window
!  sm_CYMin         = 29 - Minimum height of a window
!  sm_CXSize        = 30 - Width of title bar bitmap
!  sm_CYSize        = 31 - Height of title bar bitmap
!  sm_CXFrame       = 32 - Width of the frame on a sizable window
!  sm_CYFrame       = 33 - Height of the frame on a sizable window


Constants you can use with GetDeviceCaps:
--------------------------------------------

!  DriverVersion =   0    Device driver version                    
!  Technology    =   2    Device classification                    
!  HorzSize      =   4    Horizontal size in millimeters           
!  VertSize      =   6    Vertical size in millimeters             
!  HorzRes       =   8    Horizontal width in pixels               
!  VertRes       =  10    Vertical width in pixels                 
!  BitsPixel     =  12    Number of bits per pixel                 
!  Planes        =  14    Number of planes                         
!  NumBrushes    =  16    Number of brushes the device has         
!  NumPens       =  18    Number of pens the device has            
!  NumMarkers    =  20    Number of markers the device has         
!  NumFonts      =  22    Number of fonts the device has           
!  NumColors     =  24    Number of colors the device supports     
!  PDeviceSize   =  26    Size required for device descriptor      
!  CurveCaps     =  28    Curve capabilities                       
!  LineCaps      =  30    Line capabilities                        
!  PolygonalCaps =  32    Polygonal capabilities                   
!  TextCaps      =  34    Text capabilities                        
!  ClipCaps      =  36    Clipping capabilities                    
!  RasterCaps    =  38    Bitblt capabilities                      
!  AspectX       =  40    Length of the X leg                      
!  AspectY       =  42    Length of the Y leg                      
!  AspectXY      =  44    Length of the hypotenuse                 
!  LogPixelsX    =  88    Logical pixels/inch in X                 
!  LogPixelsY    =  90    Logical pixels/inch in Y                 
!  SizePalette   = 104    Number of entries in physical palette    
!  NumReserved   = 106    Number of reserved entries in palette    
!  ColorRes      = 108    Actual color resolution                  


***** COMING UP NEXT on ICETIPS:  *****

Allow users to change fonts in your table windows and store it in the
application 
INI file.  More API calls - retrieve the Windows and System directories.




