Documentation for Win32lib v0.60.6
Table of Contents

Low Level Routines

These routines give you access to low-level internals.


Such as C data structures, the device context, and other Win32 API goodies.

  • func getDC( id )   Get the DC (device context) of the control.
  • func getIdFromDC(atom DC)   Finds the control Id associated with the supplied Device Context.
  • proc killTimer( window, timer )   Stop a timer.
  • func registerw32Function( dll, name, args, result )   Associates an internal id number with the function name.
  • func registerw32Library(sequence name)   Associates an internal id number with the library name.
  • func registerw32Procedure( dll, name, args )   Associates an internal id number with the procedure name.
  • proc releaseDC( control )   Release the device context of the control.
  • func sendMessage( object id, atom command, object wParam, object lParam )   Send a Win32 message to the requested control.
  • proc setTimer( window, timer, ticks )    Start a timer ticking in window.
  • func w32Func(atom funcid, sequence parms)   Invoke a Windows function.
  • proc w32Proc(atom procid, sequence parms)   Invoke a Windows procedure.

    Documentation for Win32lib v0.60.6
    Table of Contents

    [func]
    getDC
    ( id )

    Get the DC (device context) of the control.

    Returns: ATOM: Device Context (DC) of the control.

    Category: Low Level Routines

    If the DC is already grabbed, the value is simply returned without grabbing it again.

    There are some special cases that are handled:

  • Normal controls: This includes any control that is normally visible on the screen. This performs a normal GetDC.
  • Screen: Passing the parameter of Screen returns the DC of the monitor.
  • Printer: Passing the parameter of Printer returns the printer's DC, assuming that one has been selected with getPrinter.
  • Pixmaps: This causes a DC compatible with the screen resolution to be created with the pixmap selected into it.
  • Other: If the value passed is not identifiable as a valid Win32Lib control, it is assumed to be a DIB. A compatible DC is created, and the DIB is selected into it.

    When you are done with the DC, it should be released with releaseDC unless the DC was obtained during an onPaint event, since the DC will be released automatically.

    See Also: getIdFromDC, killTimer, registerw32Function, registerw32Library, registerw32Procedure, releaseDC, sendMessage, setTimer, w32Func, w32Proc


    Documentation for Win32lib v0.60.6
    Table of Contents

    [func]
    getIdFromDC
    (atom DC)

    Finds the control Id associated with the supplied Device Context.

    Returns: INTEGER: Control ID or 0 if the DC is not associated with a win32lib control.

    Category: Low Level Routines

    DC is the device context returned by getDC

    This is primarily used by add-on libraries as a way to use Win32lib routines that need a control ID rather than a device context.

    Example:

          integer id
          id = getIdFromDC ( theDC )
    

    See Also: getDC, killTimer, registerw32Function, registerw32Library, registerw32Procedure, releaseDC, sendMessage, setTimer, w32Func, w32Proc


    Documentation for Win32lib v0.60.6
    Table of Contents

    [proc]
    killTimer
    ( window, timer )

    Stop a timer.

    Category: Low Level Routines

    This deactivates timer that was set with setTimer.

    Example:

              -- deactivate timer #12
               killTimer( MyWindow, 12 )
    

    See Also: getDC, getIdFromDC, registerw32Function, registerw32Library, registerw32Procedure, releaseDC, sendMessage, setTimer, w32Func, w32Proc


    Documentation for Win32lib v0.60.6
    Table of Contents

    [func]
    registerw32Function
    ( dll, name, args, result )

    Associates an internal id number with the function name.

    Returns: (INTEGER) An identifier for the function, to be used in w32Func

    Category: Low Level Routines

    The library function is not actually linked until its first usage.

    Example:

          xLoadIcon = registerw32Function(user32, "LoadIconA", {C_POINTER, C_POINTER}, C_POINTER)
    

    See Also: getDC, getIdFromDC, killTimer, registerw32Library, registerw32Procedure, releaseDC, sendMessage, setTimer, w32Func, w32Proc


    Documentation for Win32lib v0.60.6
    Table of Contents

    [func]
    registerw32Library
    (sequence name)

    Associates an internal id number with the library name.

    Category: Low Level Routines

    ret (INTEGER) An identifier for the library, to be used in registerw32Function or registerw32Procedure. name is either a DLL name or a list of DLL names. If a list, then they are tried from left to right until one is linked.

    The library is not actually opened until it's first usage.

    Example

         atom libRichEdit, libUser
         -- Use riched20 if possible else use riched32
         libRichEdit = registerw32Library({"riched20.dll", "riched32.dll"} )
    

    libUser = registerw32Library("user32.dll")

    See Also: getDC, getIdFromDC, killTimer, registerw32Function, registerw32Procedure, releaseDC, sendMessage, setTimer, w32Func, w32Proc


    Documentation for Win32lib v0.60.6
    Table of Contents

    [func]
    registerw32Procedure
    ( dll, name, args )

    Associates an internal id number with the procedure name.

    Returns: (INTEGER) An identifier for the procedure, to be used in w32Proc

    Category: Low Level Routines

    The library procedure is not actually linked until its first usage.

    Example:

          constant xKillTimer = registerw32Procedure(user32, "KillTimer", {C_POINTER, C_UINT})
    

    See Also: getDC, getIdFromDC, killTimer, registerw32Function, registerw32Library, releaseDC, sendMessage, setTimer, w32Func, w32Proc


    Documentation for Win32lib v0.60.6
    Table of Contents

    [proc]
    releaseDC
    ( control )

    Release the device context of the control.

    Category: Low Level Routines

    The DC should have been obtained with getDC.

    If the control is not a Pixmap or DIB, and the DC was obtained during an onPaint event, there is no need to release the DC. Win32Lib will automatically release all DCs obtained during an onPaint there is no need to release the DC, since Win32Lib will release all the DCs at the end of supposed to have the DC, there is no need to release it.

    If the control is the Printer, there is no need to release the DC using releaseDC. Instead, use releasePrinter

    See Also: getDC, getIdFromDC, killTimer, registerw32Function, registerw32Library, registerw32Procedure, sendMessage, setTimer, w32Func, w32Proc


    Documentation for Win32lib v0.60.6
    Table of Contents

    [func]
    sendMessage
    ( object id, atom command, object wParam, object lParam )

    Send a Win32 message to the requested control.

    Returns: ATOM: Win32 result code.

    Category: Low Level Routines

    id is either a control ID, or a control Name.
    command is the Windows Message code to send.
    wParam and lParam are the appropriate data items for the specific command you are sending. These can be either atom values or text strings.

    There are hundreds of Windows message codes. Each type of control responds to commands that are specific to it. There are too many to document here but they can be found in many publications - the easiest might be the Microsoft SDK documentation found at http://msdn.microsoft.com

    Example:

          res = sendMessage(myToolbar, TB_ADDSTRING, 0, "Test String" )
    

    See Also: getDC, getIdFromDC, killTimer, registerw32Function, registerw32Library, registerw32Procedure, releaseDC, setTimer, w32Func, w32Proc


    Documentation for Win32lib v0.60.6
    Table of Contents

    [proc]
    setTimer
    ( window, timer, ticks )

    Start a timer ticking in window.

    Category: Low Level Routines

    Timers are clocks that are maintained by Windows, and trigger events at a user-specified interval, measured in milliseconds.

    The arguments are:

  • window: Window the timer belongs to.
  • timer: Unique ID assigned to the timer.
  • milliseconds: How much time, in milliseconds, that must pass before triggering an onTimer event.

    To respond to timer events, use onTime. You can have more than one timer per window. If your window is too busy to receive the timer messages, they will be discarded.

    Example:

              -- start a timer with id #12 in MyWindow
              -- it will trigger every 3 seconds.
               setTimer( MyWindow, 12, 3000 )
    

    See Also: getDC, getIdFromDC, killTimer, registerw32Function, registerw32Library, registerw32Procedure, releaseDC, sendMessage, w32Func, w32Proc


    Documentation for Win32lib v0.60.6
    Table of Contents

    [func]
    w32Func
    (atom funcid, sequence parms)

    Invoke a Windows function.

    Returns: (ATOM) The value from the windows function is returned.

    Category: Low Level Routines

    The function to invoke is supplied in funcid. This can either be an identifier returned by registerw32Function() or one returned by define_c_func().

    The parameters for the function are contained in the sequence parms.

    Example:

        -- Get the width of the screen.
        screenCX = w32Func(xGetSystemMetrics, {SM_CXSCREEN})
    

    See Also: getDC, getIdFromDC, killTimer, registerw32Function, registerw32Library, registerw32Procedure, releaseDC, sendMessage, setTimer, w32Proc


    Documentation for Win32lib v0.60.6
    Table of Contents

    [proc]
    w32Proc
    (atom procid, sequence parms)

    Invoke a Windows procedure.

    Category: Low Level Routines

    The procedure to invoke is supplied in procid. This can either be an identifier returned by registerw32Procedure() or one returned by define_c_proc().

    The parameters for the procedure are contained in the sequence parms.

    Example:

        -- Force the window to be updated now.
        w32Func(xUpdateWindow, {getHandle(myWin)})
    

    See Also: getDC, getIdFromDC, killTimer, registerw32Function, registerw32Library, registerw32Procedure, releaseDC, sendMessage, setTimer, w32Func