Version

www.capesoft.com
Updated
Thursday 15 November 2007
     

Contents

Introduction
Copyright
Support
Installation

Distribution

How to read this manual
Example Program

Enabling WinEvent Functions
WinAlert Functions
Comm's Functions  
Taskbar Functions  
Window Behavior Functions
Windows System Functions
RAM & Disk Functions
Time & Date Functions
File Functions
Process & Thread Functions
DLL Functions
SMS Functions
Debugging & Error Reporting Functions
Auto-Shutdown Functions
Other Functions
Reference Section
Frequently Asked Questions (FAQ's)
Version History

Introduction

Welcome to WinEvent. This small library package allows you to leverage the power of the Windows API. In addition to the WinAlert functions (which allow you access to the native Windows messages) there are also now Comm's (RS232) functions, Taskbar functions and Windows Behaviour & System functions.

All the functionality provided in WinEvent is built into Windows itself in one way or another. The main advantage of WinEvent is two fold.

Main Advantages

  It provides the functions in a simple easy-to-use manner, avoiding the complexities of the Windows API.  
The functions are (mostly) cross-compatible between 16 and 32 bit implementations of your program. The Taskbar functions and some advanced Comm's functions are only available in 32 bit programs, but all the other functions are the same in 16 and 32 bit programs.
     


WinEvent functionality is divided into 5 areas:

Functionality

  Windows message capturing functions (WinAlert)

WinAlert allows your CW programs more access to the native Window messages. This is in itself nothing new. Using the sub-classing technique access to the Windows messages has been available since almost the first days of CW.

WinAlert provides a simple wrapper to subclassing, which removes the complexities and makes the code both simple to follow, easy to implement, and consistent with the rest of the Clarion language. In essence one new major function, and a couple of support functions allow the flexibility and ease of use that we've come to expect from Clarion.

In addition it comes with a template that makes adding this wrapper to your applications even easier. You can use the template to alert messages on individual windows. In addition a utility template makes it possible to enable Auto Shut Down across your entire application.

 
RS 232 Port functions

Very often developers need simple access to a Comm's port. This simple functionality is built into the Windows API, but is quite complex and difficult to code. In addition to this the APIs for 16 bit and 32 bit Windows are very different. The Comm's section of the WinEvent package provides some simple easy-to-use functions that allow you to read and write to Comm's ports. In addition almost all the functions are the same in 16 and 32 bit ( the library takes care of the API differences ) so it's easier to move from one platform to another. The library also corrects a bug in the Windows functions that affect Comm's at speeds of greater than 19200. Some advanced functions to test specific hardware handshaking lines for their current status are only supported in 32 bit as no 16 bit equivalent exists.

Taskbar functions

Users of Windows 95, and Windows NT 4.0, will be familiar with the Taskbar that usually sits at the bottom of the screen. The taskbar functions allow you to add / change and delete an icon from the "Tray" ( the area at the right hand side of the taskbar ) as well as detect when the mouse has been clicked on an icon in the tray. This is very useful for apps which are running in the background on a full time basis. In addition, you can make use of a function that prevents your program from appearing on the main area of the Taskbar itself.

Window behaviour functions

A small group of functions that allow you to change the behaviour of a window. This includes the ability to make a window permanently "on top", and also the ability to bring the window to the front.

System functions

These functions return system information to your application. The Windows, and Dos (if applicable) version numbers are available to your application. Also you are able to get the current free disk space in 16 and 32 bit. This is useful for detecting low disk space conditions before they occur. A function for playing a wav file is also included.
     

Copyright

WinEvent is copyrighted © 2004 by CapeSoft Software (Pty) Ltd. CapeSoft Software (Pty) Ltd assumes no responsibility for applications created which incorporate WinEvent. WinEvent is used entirely at your own risk. You may not distribute any of the WinEvent files.

Each developer needs his own license to use WinEvent. (Need to buy more licenses?)




Support

We welcome your comments, suggestions, and criticisms. Please do not hesitate to contact us if you have a problem, or a suggestion.

You can contact CapeSoft in one of the following ways:

CapeSoft Support

  Email  
Telephone +27 21 715 4000
Fax +27 21 715 2535
Post PO Box 511, Plumstead, 7801, Cape Town, South Africa
     


Purchase WinEvent at $149.00 from:

CapeSoft Sales

  Web www.capesoft.com  
Email sales@capesoft.com

Telephone +27 21 715 4000
Fax +27 21 715 2535
Post PO Box 511, Plumstead, 7801, Cape Town, South Africa
     


Buy Online

  Web
Buy now at ClarionShop
www.clarionshop.com 
 
 
 
 
 
     

Installation

To install WinEvent, run the supplied installation file and follow the prompts.



Distribution

You are free to distribute the WinEvent DLLs with any of your Applications without extra charge.

The DLLs your program require will depend on your version of Clarion. Note that programs compiled in Local Mode do not use DLLs and therefore there is nothing extra for you to distribute.

DLLs required (Standalone mode only)

 
Clarion Version
DLL required  
Clarion 6 WE60X.DLL
Clarion 5.5 WE55X.DLL
Clarion 5 EVENT532.DLL
     
 


How To Read this Manual

This manual is split into two sections. This first section contains a general overview of the WinEvent features. Each of the WinEvent function areas is dealt with and the templates provided are discussed here.

The second section is the Technical Reference. In this section the individual functions are described, along with their syntax. This is particularly useful as most of these functions are designed to be used in simple embed points etc.

Example Program

Included in the WinEvent package is a simple example program that demonstrates all of WinEvent's features. This example is in the \Clarion\3rdParty\Examples\Winevent\Windemo directory and is called WinDemo.

There is also an example of a barcode collector program. This is stored in \Clarion\3rdParty\Examples\Winevent\Barcode
 

Enabling WinEvent Functions

To use the WinEvent functions in your application you must first enable them. This is done by selecting the Global Properties option from the Application dropdown menu, selecting the Extensions button then the Insert button, scrolling down the extension options and then selecting EnableWinEvent - Enable the WinEvent functions in your app.

On the Settings tab of the WinEvent global extension template:

The Auto-Shutdown on tick box to apply the automatic shutdown function to your application. This will then be globally applied to the application. By default, this feature is on, but you can disable it here if you'd like to. You can also disable it at a local level as well.

The Make windows visible on Desktop will ensure that when your windows open, they are visible on the desktop area. You can disable this locally if there are specific windows that don't require this feature (otherwise by default it will be on for all windows in your application).


WinAlert Functions

The Concept

First some terminology. An Event is the Clarion word for a message that is provided to you via the ACCEPT loop. A Message is the Windows equivalent. Part of the job of the Accept command is to filter out many of these Messages, and pass on only those Events that are usually required.

The idea is to use a new function, called WinAlert in the same way you would use the Alert function for keystrokes. This allows you to get at the messages before the Accept command does, taking further action where it is required. In addition to simply spotting the message, you can also specify its action at the same time. Some messages require an immediate reply (usually True or False) to the procedure that sent the message. However most messages would be required simply so that you can gain more control over the things that are happening. In this case a user event, is posted to the Accept loop, after storing the value of the Message.

To further complicate the issue Messages can also have additional data tagged on with them. This data is stored in 2 variables, often going by the somewhat cryptic names of wParam and lParam. The w and l represent the data type (w for Word - ie a Short (16bit programs) or Long (32 bit programs) and l for Long). On receiving the User event, WinMessageEvent you can use 2 new support functions, WinParam1() and WinParam2() to get the values of these parameters when the message arrived, as well as the Winevent() function to see which windows message triggered the event.

The Classic Example

One of the most frequently asked questions on the Internet's cw-talk mailing list, is "How do I get my application to terminate automatically when the user shuts down Windows ?" Using WinEvent the answer is both simple and elegant. you simply add the WinEvent global extension template and leave the defaults checked and away you go.

Using the Local WinEvent: Alert Windows Messages Template

You can override some of the global defaults set in the Global WinEvent Extension template in the WinEvent: Alert Windows Messages local extension template that is populated onto each window:

Using WinAlert in Applications

The WinEvent extension template, which is included, assist's you in using the WinAlert functions. It organizes in one place the three items that are required, namely Alerting the message, handling any action that may be required, and unAlerting the message before closing the window. The template leads you through the options that you have, and provides you with the required embed point for processing the WinMessageEvent. You may alert as many Windows messages as you like.

You can view a list of the Windows Messages to equate in the eventequ.clw file (which is found in your Clarion6\3rdparty\libsrc directory).

Action (group 1):

WinAccept is a event handler that will accept the windows event before it arrives at your window. Action (group 1) determines what reply WinAccept must do (for the Windows Kernel) when this event is received. If Return 1 or Return 0 is selected, then those values are returned to the Windows kernel, otherwise the event is passed on to Clarion for Clarion to return a value to the Windows kernel.

Action (group 2):

These options are telling WinAccept what to do with the event - in terms of forwarding it on to your Clarion procedure. There are 3 possible options you can select:

case Event() - WinMessageEvent
of 0 ! WinMessageEvent
  !Put your code in here to process when this event is received. 

Windows Message Clarion Event posted
WE::WM_CLOSE Event:CloseWindow
WE::WM_MOUSEMOVE Event:MouseMove
WE::WM_NCMOUSEMOVE
WE::WM_TIMER Event:Timer
WE::WM_LBUTTONDOWN Event:MouseDown
WE::WM_RBUTTONDOWN
WE::WM_NCRBUTTONDOWN
WE::WM_NCLBUTTONDOWN
WE::WM_NCMBUTTONDOWN
WE::WM_MBUTTONDOWN
WE::WM_LBUTTONUP Event:MouseUp
WE::WM_RBUTTONUP
WE::WM_NCRBUTTONUP
WE::WM_NCLBUTTONUP
WE::WM_NCMBUTTONUP
WE::WM_MBUTTONUP

Please Note: If using the WE::WM_MouseWheel on a window with a listbox, then only the mouse wheel events occurring when the mouse wheel button is depressed will be passed to the WinAccept. Windows will only pass on the mouse wheel events when a list box is not present.

For those that care

Basically when you ask Windows to shut itself down it polls each running application by sending it the WM_QueryEndSession message. If all the applications respond by returning True, then they are each, in turn, instructed to close. In the above line of code you are telling the WinEvent library, that when the window receives this message, then it must return True. The utility template automatically adds an instance of the WinEvent extension template to each of your procedures.


Using WinAlert in a Hand Coded Project

This details how to add WinAlert functionality to a hand-coded project. For a detailed description of each of the functions, see the Reference section of this document.

Adding WinAlert to a function

  Use the WinAlert function to alert the message. This should be called before the Accept command, but after the window is opened.  
Use the WinAlert function, with no parameters, before Closing the window.
Use the WinEvent's WinControl, WinParam1 and WinParam2 functions to examine the message.
     


Enabling WinAlert in the root module

  Include the (supplied in \clarion\libsrc ) map file, EventMap.Clw, in your Global Map.  
Include the (supplied in \clarion\libsrc ) equates file, EventEqu.Clw in your main module's data section.
Clarion 5: Add the Event532.Lib file to your project for Stand-Alone compile mode or EvLib532.Lib for Local compiles. All these library files are in your \clarion5\3rdparty\lib directory.

Clarion 5.5
: Add the we55x.Lib file to your project for Stand-Alone compile mode or we55xL.Lib for Local compiles. All these library files are in your \clarion 55\3rdparty\lib directory.

Clarion 6: Add the we60x.Lib file to your project for Stand-Alone compile mode or we60xL.Lib for Local compiles. All these library files are in your \clarion 60\3rdparty\lib directory.
     
 

Note:  A WinEvent Demo has been included with WinEvent (\Clarion X\3rdParty\examples\WinEvent\Demo\windemo.app) and can be used to view how these features can be used.


Comm's Functions

The Comm's section of the WinEvent package provides some simple easy-to-use functions that allow you to read and write to Comm's ports (RS232).

Using Comm's functions in an Application

Add the Enable WinEvent Functions extension template to your Global extensions.

Using Comms functions in a hand-coded project

  Include the (supplied in \clarion\libsrc ) map file, EventMap.Clw, in your Global Map.  
Include the (supplied in \clarion\libsrc ) equates file, EventEqu.Clw in your main module's data section.
Clarion 5: Add the Event532.Lib file to your project for Stand-Alone compile mode or EvLib532.Lib for Local compiles. All these library files are in your \clarion5\3rdparty\lib directory.

Clarion 5.5
: Add the we55x.Lib file to your project for Stand-Alone compile mode or we55xL.Lib for Local compiles. All these library files are in your \clarion55\3rdparty\lib directory.

Clarion 6: Add the we60x.Lib file to your project for Stand-Alone compile mode or we60xL.Lib for Local compiles. All these library files are in your \clarion6\3rdparty\lib directory.
     

Functions supplied

Newport
ReadPort
WritePort
ResetPort
ClosePort
KillAllPorts
SetHandShake
CtsHigh
DsrHigh
RingHigh
CdHigh
SetRts
SetDtr

For a detailed description of each of the functions, see the reference section. You will need to handcode the functions into your application where you need them. 


Taskbar Functions

There are a number of Taskbar functions which allow your application to interact with the Windows Taskbar. These functions allow you to add icons to the Taskbar's tray, add balloon text, menu option and also allow you to prevent your application (icon) from appearing on the taskbar.

                    

Template Supplied

An Extension template has been provided to add an icon to the tray. This icon will automatically be put in the tray when the window is opened, and automatically removed when the window is closed. You can also use the functions in hand code to add, change and remove icons at will.

If you place an Icon in the tray, then you will also probably want to capture mouse events when the user interacts with this icon. We've included some generic default behaviour, but you may like to add some more options. In WinEvent this is done automatically for you. The template also takes care of all the details - there are embed points so you can add your code for the event, and there are buttons on the AddIcon template to easily get to those embed points.

Tip: Use the Mouse Right Up embed point for opening a Pop-up menu.


WE::CloseAllNow = 1
post(event:closewindow)


Note : The message is ultimately processed by the Accept command. If your program spends a long time processing between calls to the Accept loop then you may notice a delay between clicking on the Icon, and the execution of your embedded code. For better responses make sure your program frequently returns to the Accept command.

Note: If you have hand-coded handling these events then you should be aware that the method has changed and your old code will no longer work. In the past the event came through as WinMessageEvent. This has been changed - the mouse events are now separated and come through as WinMessageEvent+500+x where x is 512 (mouse move) or 513(mouse left down) or 514(mouse left up) or 515(double left click) or 516(mouse right down) or 517(mouse right up).

Functions supplied

WinTaskbarAddIcon
WinTaskbarChangeIcon
WinTaskbarRemoveIcon
WinNotOnTaskbar
ds_WinTaskbarBalloon
 

For a detailed description of each of the functions, see the reference section.

Window Behavior Functions

Functions Supplied

WinOnTop
WinNotOnTop
WinBringToFront
ds_WinTransparent
ds_VisibleOnDesktop
ds_ShowWindow
ds_HideWindow
 

For a detailed description of each of the functions, see the reference section. 


Windows System Functions

Functions Supplied

ds_GetWinVersion
WindowsVersion
WindowsRelease
DosVersion
DosRelease
Sound
GetWindowsDir
GetSystemWindowsDir
ScreenWidth
ScreenHeight
ScreenDepth
ds_GetScreenDPI

For a detailed description of each of the functions, see the reference section.

 

RAM & Disk Functions

Functions Supplied

GetFreeDiskSpace
GetDiskSpace
ds_GetDiskMegs
ds_Memory  
 

For a detailed description of each of the functions, see the reference section.

 

Time & Date Functions

Functions Supplied

ds_FastClock
ds_FormatFastTime
ds_Timer
ds_Sleep
ds_WeekDay
ds_ReadCPUTimeStamp
 

For a detailed description of each of the functions, see the reference section.
 

File Functions

Functions Supplied

ds_DeleteFile
ds_GetFileDirEntry
ds_SetFileAttributes
ds_CreateDirectory
ds_RemoveDirectory
ds_SetFileDateTime
ds_MoveFile
ds_GetFolderPath
ds_GetTempPath
ds_String2File
ds_File2String
ds_GetHModule
ds_GetHIcon
ds_CreateShortcutEx
ds_GetFileVersionInfo

 

For a detailed description of each of the functions, see the reference section.
 

Process & Thread Functions

Functions Supplied

ds_GetCurrentProcess
ds_GetCurrentThread
ds_GetProcessTime
ds_GetThreadTime
ds_SetRealTimePriority

 

For a detailed description of each of the functions, see the reference section.
 

DLL Functions

Functions Supplied

        ds_LoadDLLProc
        ds_UnloadDLLProc
        ds_GetDLLVersion

For a detailed description of each of the functions, see the reference section.
 

SMS Functions

Functions Supplied

        ds_GSMSendSMS
        ds_GSMEnterPin
        ds_GSMEchoOFF
        ds_GSMSetSMSTextmode
        ds_GetGSMReply
        ds_EmptyPort
        ds_GSMReadSMSInit
        ds_GSMReadSMS
        ds_GSMDeleteSMS
        ds_GSMSetSMSReporting
        ds_GSMSelectSR
        ds_GSMReadSMSReportInit
        ds_GSMReadSMSReport
        ds_GSMDeleteSMSReport
        ds_GSMReadEvents
        ds_GSMSetEvents
        ds_GSMReset
       
       
        For a detailed description of each of the functions, see the reference section.

Note: Using a GSM modem is really the only way to send and receive SMSes using WinEvent. Phones themselves vary widely in the ability to handle GSM and every manufacturer's GSM protocol (Commands, etc) are so widely varied, that they will be impossible to support (although you may be lucky - but to avoid the frustration, get a modem).

Note: Only the standard Charset is supported at this stage. We will include the ability to change charsets as soon as possible.

Modems tested with WinEvent: Siemens TC35i, SonyEricson GT47 and Wavecom Wismo (serial only). Please let us know if you have tested with other models of Modems, and we'll add those to this list.

Debugging & Error Reporting Functions

Functions Supplied

        ds_Debug
        ds_WineventDebug
        ds_ViewDebug
        ds_ViewDebugClose
        ds_Error
        ds_ErrorCode
        ds_ErrorReset
        ds_SaveStack
        ds_TestStack
       

For a detailed description of each of the functions, see the reference section.
 

Auto Shut-down Functions

When you select Auto-Shutdown on your Global WinEvent Extension two callback functions MyOKToEndSessionHandler &  MyEndSessionHandler are added to your app.  These appear in your Global Embeds list as :
Winevent MyOKToEndSessionHandler
Winevent MyEndSessionHandler

Use MyOKToEndSessionHandler to tell windows whether it is OK to shut down now.  Set the return value variable OKToEndSession to FALSE if you do not what to allow shutdown now.

If you have given the go ahead to shutdown and no other program has refused then MyEndSessionHandler will be called before windows ends this application.  This is for you to save any settings etc.  Please note that windows ends all your app threads without allowing then to execute the closing window code you may have written.  This is your only chance to execute code. 

If either your MyEndSessionHandler or MyOKToEndSessionHandler code takes longer than 3 seconds to execute then windows (XP 2K etc) pops up a "Ending Application" window which gives you about 15 seconds.

 

Functions Supplied

        ds_SetOKToEndSessionHandler
        ds_SetEndSessionHandler
        ds_SetNoEndSession
         

For a detailed description of each of the functions, see the reference section.
 

Other Functions

Functions Supplied

        ds_FormatHex
        ds_SetClipboard
        ds_ShutDown
        ds_WineventVersion
        ds_Ulong64ToReal
             

For a detailed description of each of the functions, see the reference section.
 

Reference Guide

WinAlert functions

WinAlert
Winevent
WinControl
WinParam1
WinParam2

WinChangeUserEvent
WinSysEvent
WinSysParam1
WinSysParam2
WinWtsEvent
WinWtsID

 

Comms Functions

NewPort
ResetPort
ClosePort
KillAllPorts
WritePort
ReadPort
SetHandShake
CtsHigh
DsrHigh
RingHigh
CdHigh
SetRts  
SetDtr  

 

Taskbar Functions

WinTaskBarAddIcon
WinTaskBarRemoveIcon
WinTaskBarChangeIcon
WinNotOnTaskBar
ds_WinTaskbarBalloon


Window Behaviour Functions

WinOnTop
WinNotOnTop
WinBringToFront
ds_WinTransparent
ds_VisibleOnDesktop

ds_ShowWindow

ds_HideWindow
 

Windows System Functions

ds_GetWinVersion
WindowsVersion
WindowsRelease
DosVersion
DosRelease
GetFreeDiskSpace
GetDiskSpace  
Sound
GetWindowsDir
GetSystemWindowsDir
ScreenWidth
ScreenHeight
ScreenDepth
ds_GetScreenDPI

Time & Date Functions

          ds_FastClock
          ds_FormatFastTime
          ds_Timer
          ds_Sleep
          ds_WeekDay

File Functions

        ds_DeleteFile
        ds_GetFileDirEntry
        ds_SetFileAttributes
        ds_CreateDirectory
        ds_RemoveDirectory
        ds_SetFileDateTime
        ds_MoveFile
        ds_GetFolderPath
        ds_GetTempPath
        ds_String2File
        ds_File2String
        ds_GetHModule
        ds_GetHIcon
        ds_CreateShortcut
        ds_GetFileVersionInfo

 

DLL Functions

        ds_LoadDLLProc
        ds_UnloadDLLProc

SMS Functions

        ds_GSMSendSMS
        ds_GSMEnterPin
        ds_GSMEchoOFF
        ds_GSMSetSMSTextmode
        ds_GetGSMReply
        ds_EmptyPort
        ds_GSMReadSMSInit
        ds_GSMReadSMS
        ds_GSMDeleteSMS
        ds_GSMSetSMSReporting
        ds_GSMSelectSR
        ds_GSMReadSMSReportInit
        ds_GSMReadSMSReport
        ds_GSMDeleteSMSReport
        ds_GSMReadEvents
        ds_GSMSetEvents
        ds_GSMReset
       
       
 

Debugging & Error Reporting Functions

        ds_Debug
        ds_WineventDebug
        ds_ViewDebug
        ds_ViewDebugClose
        ds_Error
        ds_ErrorCode
        ds_ErrorReset
        ds_SaveStack
        ds_TestStack
       


WinAlert(<FromMessage>, <ToMessage>, <Action> )

Parameters

FromMessage short
The [first] Windows message to alert.

ToMessage short
The last Windows message to alert. If this parameter is omitted then only the FromMessage is alerted.

Action short
This defines the action required when the alerted message(s) are received. If this parameter is omitted then it defaults to PostUser + PassOn.

Purpose

This function works in a very similar way to the normal Clarion ALERT function. Where the ALERT function traps keystrokes, the WINALERT function traps Windows Messages.
However in addition to merely spotting the messages you can also specify the action required when the message comes along. The messages are automatically trapped for the current window. In other words you must open the Window before alerting the Windows messages for that window.

NOTE :: If all three parameters are omitted then the WinAlerts for that window are removed. This must be done before closing a window if any messages were alerted for that window.

The actions are split into two groups, and a single action from each group (i.e. up to 2 actions) are allowed. The actions are as follows:

Group 1
Equate                Meaning
Return0               : Return 0 to the function that sent the message.
Return1               : Return 1 to the function that sent the message.
PassOn              : Pass the message on to the Clarion window for processing.

Group 2
Equate               Meaning
PostUser            : Post a User Event to the Accept loop.
PostClarion         : Post an equivalent Clarion Event (if the is one) to the Accept loop. This action is only available in the registered version of the library.

NOTE : The PostClarion action is only available in the registered version of WinEvent.

Depending on the message, and the effect you require, the above options should cater for all eventualities. The only case where additional coding would be necessary would be when the action includes PostUser. This posts a user event (usually 500h, but can be changed) to the Accept loop. On receiving this event you can then call the function Winevent() to determine the actual event. WinEvent is described more fully below, but behaves essentially the same as the regular Clarion EVENT() function.

Complication

If more than one Windows message is alerted, and both alerted messages are received in close succession, then Winevent() returns only the last received of the messages. It should be noted here, that this applies only to alerted messages. Unalerted messages (and there are plenty of those) have no effect whatsoever.

Returns

Nothing

Example

  code
  open(window)
  WinAlert(WM_QueryEndSession,Return0)
  !!! All the normal processing goes here
  WinAlert() ! DON'T FORGET THIS !!!!!
  Close(Window)

See Also

WinChangeUserEvent () : To change the User event posted back to your App.




Winevent(), WinControl(), WinParam1(), WinParam2()

Parameters

None

Purpose

The WinEvent function is used when a User Event is received to determine which Windows message caused the event. It is not cleared after use and remains available until the next Alerted Windows message is received. The WinParam1 and WinParam2 functions return the windows parameters for that message. The WinControl function returns the handle of the specific window that received the message. You can then use this handle to check which control received the event.

Complication

If more than one Windows message is alerted, and both alerted messages are received in close succession, then Winevent() returns only the last received of the messages.

Returns

The last alerted Windows message received.

Example

  code
  case Event() - WinMessageEvent
  of 0 ! WinMessageEvent
    case Winevent()
    of WM_MouseMove
      ! something goes here - can also use WinParam1() and WinParam2() here
    end
  of 5502 ! WM_SYSCOMMAND
  of 5506 ! WM_WTSSESSION_CHANGE 
  end

See Also

WinAlert : For alerting windows messages
WinSysEvent : For handling the wm_SYSCOMMAND windows message.
WinWtsEvent : For handling the wm_WTSSESSION_CHANGE windows message.


WinChangeUserEvent (WinMessageEvent)

Parameters

WinMessageEvent short
The Event to post when an alerted windows message is received.

Purpose

WinMessageEvent is an equate defined in the WM.CLW file. If you want to change it from it's default value of 500h then change it in this file, and call the WinChangeUser function early in your application. Once changed, it remains changed for all alerted windows messages.

Returns

Nothing

Example

  code
  WinChangeUser(WinMessageEvent)

 


WinSysEvent(byte pClearAfterRead=0), WinSysParam1(), WinSysParam2()

Parameters

byte pClearAfterRead : Default FALSE.  If set TRUE the WinSysEvent is reset to zero after reading.

Purpose

An extension of the WinEvent function.  WinSysEvent is used instead of WinEvent when a wm_SYSCOMMAND message is alerted.  WinEvent is still used for other windows messages.  If the pClearAfterRead is not TRUE then WinSysEvent remains available until the next wm_SYSCOMMAND Windows message is received. The WinSysParam1 and WinSysParam2 functions return the windows parameters for that message.

Returns

ulong : wm_SYSCOMMAND

Example

  code
  case Event() - WinMessageEvent
  of 0 ! WinMessageEvent
  of 5502 ! WM_SYSCOMMAND
    if WinSysEvent(TRUE) = WM_SYSCOMMAND
      if WinSysParam1() = 61824 ! SC_CONTEXTHELP
        QuestionMarkPressed = TRUE
      end
    end
  of 5506 ! WM_WTSSESSION_CHANGE 
  end 

See Also

WinAlert : For alerting windows messages
WinEvent : For handling standard windows messages.
WinWtsEvent : For handling the wm_WTSSESSION_CHANGE windows message.
 


WinWtsEvent(byte pClearAfterRead=0), WinWtsID()

Parameters

byte pClearAfterRead : Default FALSE.  If set TRUE the WinWtsEvent is reset to zero after reading.

Purpose

An extension of the WinEvent function.  WinWtsEvent is used instead of WinEvent when a wm_WTSSESSION_CHANGE message is alerted.  WinEvent is still used for other windows messages.  If the pClearAfterRead is not TRUE then WinWtsEvent remains available until the next wm_WTSSESSION_CHANGE Windows message is received. The WinWtsID function returns the session ID linked to the event. 

Returns

WTS session change event.
Value Meaning
WTS_CONSOLE_CONNECT
0x1
A session was connected to the console session.
WTS_CONSOLE_DISCONNECT
0x2
A session was disconnected from the console session.
WTS_REMOTE_CONNECT
0x3
A session was connected to the remote session.
WTS_REMOTE_DISCONNECT
0x4
A session was disconnected from the remote session.
WTS_SESSION_LOGON
0x5
A user has logged on to the session.
WTS_SESSION_LOGOFF
0x6
A user has logged off the session.
WTS_SESSION_LOCK
0x7
A session has been locked.
WTS_SESSION_UNLOCK
0x8
A session has been unlocked.
WTS_SESSION_REMOTE_CONTROL
0x9
A session has changed its remote controlled status. To determine the status, call GetSystemMetrics and check the SM_REMOTECONTROL metric.

Example

  code
  case Event() - WinMessageEvent
  of 0 ! WinMessageEvent
  of 5502 ! WM_SYSCOMMAND
  of 5506 ! WM_WTSSESSION_CHANGE 
    case WinWtsEvent(TRUE)
    of 5 !
WTS_SESSION_LOGON
      NewSessionID = WinWtsID()
    end
  end 

See Also

WinAlert : For alerting windows messages
WinEvent : For handling standard windows messages.
WinSysEvent : For handling the wm_SYSCOMMAND windows message.
 


NewPort (string pmode, <long pInb>, <long pOutb>,byte pUseEvents=0)

Purpose

Opens a port for sending or receiving.

Parameters

mode ( string ) : This is a mode string such as would be accepted by the Dos MODE
command.

in buffer size (long) ( optional parameter - default 512 bytes )
out buffer size (long) ( optional parameter - default 512 bytes )
These are the sizes Windows must use for the In and Out buffers.

pUseEvents (byte) (optional parameter - default = 0)
When set (TRUE) the current window will receive com events.

  Comms transmit buffer empty event = WinEventMessage + 5601

  Comms characters received = WinEventMessage + 5602

  Comms handshaking lines changed = WinEventMessage + 5602


Returns : Long
<0 if an error has occurred. Otherwise a port number used by readport and writeport.

Examples

    PortId = NewPort('Com1:9600,n,8,1')
    PortId = NewPort('Com2:9600,n,8,1',1024)
    PortId = NewPort('Com3:9600,n,8,1',1024,1024)


Tip : The window structure must have the SYSTEM attribute. If it does not then ReadPort will fail.
 



ResetPort (mode string)

Purpose

Resets the parameters for a port while the port is open. Note that this function can only be called for a port that has already been opened using the NewPort command.

Parameters

mode (string) This is a mode string such as would be accepted by the Dos MODE command.

Returns : long

< 0 if an error occurred. Otherwise 0.

Example

  result = ResetPort('Com1:9600,n,8,1')
 



ClosePort (PortId long)

Purpose

Closes a port so it can be used by another program.

Parameters

PortId (long) This is the port number as returned by the NewPort function.

Returns : long

Nothing

Example

  pid = NewPort ('Com1:9600,n,8,1')
  ! some code goes here
  ClosePort(Pid)

 



KillAllPorts ( )

Purpose

Closes all open ports.

Returns

Nothing

Example

  KillAllPorts()
 



WritePort (PortId long, String string, Length long)

Purpose

Writes a string into the transmission buffer.

Parameters

PortId (long) This is the port number as returned by the NewPort function.

String (string) This is the string to send.

Length (long) This is the number of bytes to send. If 0 then the string is clipped and sent.

Returns : long

< 0 if an error. Otherwise number of bytes sent.

Example

    pid = NewPort ('Com1:9600,n,8,1')
    buf = 'abcdefghij'
    bytessent = WritePort(pid,buf,10)

Note: Do not use:

if WritePort(pid,buf,10) >= 0
  !Successful write
end

instead of:

bytessent = WritePort(pid,buf,10)
if bytessent
  !Successful write
end


ReadPort (PortId long, String string, Length long)

Purpose

Read bytes out of the receive buffer.

Parameters

PortId (long) This is the port number as returned by the NewPort function.

String (string) This is the string in which to put the received bytes.

Length (long) This is the maximum number of bytes to receive. If 0 then the receive string will be filled if possible.

Returns : long

< 0 if an error. Otherwise number of bytes received. If 0 then the receive buffer is empty.

Example

    pid = NewPort ('Com1:9600,n,8,1')
    bytesreceived = ReadPort(pid,buf,0)


Tip: The window structure must have the SYSTEM attribute. If it does not then ReadPort will fail. 

Tip: To monitor the port in the background (i.e. without hogging processing time) - you can put the ReadPort in a timer event (Timer set to at least 100 - unless for mission critical timing applications). If the ReadPort returns a 0 then just skip the code for handling the buffer code. In 32bit, windows has an almost unlimited COMPort buffer, so you don't have to worry about comms going missing (if it's not monitored in a tight loop).

SetHandShake (PortId long, HandShake long)

Purpose

To Set or Remove port handshaking

Parameters

PortId (long) This is the port number as returned by the NewPort function.

HandShake (long) This is one of the following : 0 = No Handshaking ; 1 = Xon/Xoff ;  2 = DSR/DTR ; 3 = CTS/RTS

Returns : long

< 0 if an error. 0 if successful.

Example

    pid = NewPort('Com1:9600,n,8,1')
    result = SetHandShake(pid,1)

 



CtsHigh (Pid Long)

Purpose

Returns the current status of the CTS (Clear to Send) line. For advanced programming only.

Parameters

PortId (long) This is the port number as returned by the NewPort function.

Returns

1 if high. 0 if low.

Example

    pid = NewPort('Com1:9600,n,8,1')
    result = CtsHigh(pid)

 



DsrHigh (Pid Long)

Purpose

Returns the current status of the DSR (Data Send Ready) line. For advanced programming only.

Parameters

PortId (long) This is the port number as returned by the NewPort function.

Returns

1 if high. 0 if low.

Example

    pid = NewPort('Com1:9600,n,8,1')
    result = DsrHigh(pid)

 



RingHigh (Pid Long)

Purpose

Returns the current status of the RI (Ring Indicator) line. For advanced programming only.

Parameters

PortId (long) This is the port number as returned by the NewPort function.

Returns

1 if high. 0 if low.

Example

    pid = NewPort('Com1:9600,n,8,1')
    result = RingHigh(pid)

 



CdHigh (Pid Long)

Purpose

Returns the current status of the CD (Carrier Detect) line. For advanced programming only.

Parameters

PortId (long) This is the port number as returned by the NewPort function.

Returns

1 if high. 0 if low.

Example

    pid = NewPort('Com1:9600,n,8,1')
    result = CdHigh(pid)

 



SetRts (Pid Long, Value Long)

Purpose

Sets the current status of the RTS (Ready to Send) line. For advanced programming only.

Parameters

PortId (long) This is the port number as returned by the NewPort function. Value (long) Set to 0 to Clear the RTS line, Set to 1 to Set the RTS line.

Returns

Nothing

Example

    pid = NewPort('Com1:9600,n,8,1')
    SetRts(pid,1)

 



SetDtr (Pid Long, Value Long)

Purpose

Sets the current status of the DTR (Data Terminal Ready) line. For advanced programming only.

Parameters

PortId (long) This is the port number as returned by the NewPort function. Value (long) Set to 0 to Clear the DTR line, Set to 1 to Set the DTR line.

Returns

Nothing

Example

    pid = NewPort('Com1:9600,n,8,1')
    SetDtr(pid,1)

 



WinTaskbarAddIcon(IconName String,< Tips String>),long

Purpose

Adds an Icon to the TaskBar's "Tray" area. This icon belongs to the window that's open when the function is called. At least one window must be open when this function is called. When the user clicks on this icon then an event is generated and sent to the owner window. The event generated is the WinUserEvent ( usually 0500h ). This event is generated whenever a WinAlerted message is received. You can then use the Winevent() function to return the specific message that triggered the event. If the user clicked on an icon in the tray, then the Winevent() function will return the number 25000.

Parameters

IconName (string)
This is the name of the icon to display. At the moment the icon is an ICO file stored on the disk. Later releases may allow you to use icons built into your application.

Tips (string)
This parameter is optional. If you put a string in here, then this will be the tip displayed when the mouse rests on the icon in the tray.

Returns : long

Icon Id. This Id is used by the Remove and Change functions

Example


id long
  code
  open(window)
  id = WinTaskBarAddIcon('happy.ico','click on me....')
  accept
    !! usual window processing goes here
    if event() = 0500h
      if Winevent() = 25000
        ! the user has clicked on the icon in the tray.
        ! do something here, like a popup menu...
      end
    end
  end
  close(window)

 



WinTaskbarRemoveIcon(<Id longt>)

Purpose

Removes an Icon from the Taskbar's tray.

Parameters

Id (long)
This is the Id number as returned by the Add function. If this parameter is omitted then all icons placed by this window will be removed.

Returns

Nothing

Example

id long
  code
  open(window)
  id = WinTaskBarAddIcon('happy.ico','click on me....')
  WinTaskBarRemoveIcon(id) ! or ....
  WinTaskBarRemoveIcon()

 



WinTaskbarChangeIcon(<Id long>, IconName string,<Tips string>)

Purpose

Changes the icon and / or tool tip for a specific icon that is already placed in the tray. Use
this function to update the icon to display your program status.

Parameters

Id (long) : The Icon identifier as returned by the Add function.  If omitted then the first icon added by this window will be changed.

IconName (string) : The name of the icon to use.

Tips ( string ) : The new tool tip for the icon.  If omitted then the tip will be cleared.

Returns

Nothing

Example

id long
  code
  open(window)
  id = WinTaskBarAddIcon('happy.ico','click on me....')
  WinTaskBarChangeIcon(id,'sad.ico','Im sooo sad')

 

Additional notes:

There are 3 events available for event tracking:

  1. Balloon open
  2. Balloon close
  3. Balloon close on timeout.

To track these events, you can place code in the relative embed point to run when one of these events occurs:


ds_WinTaskbarBalloon(<ulong pID>,string pText,<string pTitle>,uLong pFlags=1,ulong pTimeout=1500)

Purpose

This opens a "balloon" linked to the system tray icon.  The balloon will stay open until either the user closes it or the user gives focus to the application.
There is a minimum time that the balloon will be open.  This is used in cases where another balloon (different application) is requested.
Balloons are not supported in win95 or win98 so WinEvent supplies a XP/Vista "look alike".
 

Parameters

pID (ulong) : Optional.  Returned by WinTaskbarAddIcon.  Is used to identify which icon to attach the balloon to.

pText (string) : The balloon text.  If no balloon text is supplied then any open balloon is closed. Embedding '<13,10>' in the text produces multiline text.

pTitle (string) : Optional.  The balloon title. Icons only appear if the title is supplied.

pFlags (uLong) : Optional.  Default = 1 (An information icon).

WE::NIIF_ERROR EQUATE(003h) An error icon.
WE::NIIF_INFO EQUATE(001h) An information icon. (Default)
WE::NIIF_NONE EQUATE(000h) No icon.
WE::NIIF_WARNING EQUATE(002h) A warning icon.
WE::NIIF_NOSOUND EQUATE(010h) XP/Vista only. Do not play the associated sound.

pTimeout (ulong) : Optional.  Default=1500 (15 seconds). Balloon minimum display time in 100ths of a second. (clarion time)

Returns

Nothing

Example

ID        long

  code
  ID = WinTaskbarAddIcon('~MyAppIcon.ico','This is my tip text.<13,10>This is on line 2.')
  ds_WinTaskbarBalloon(ID,'This is the balloon text.<13,10>This is on line 2.','This is the title.')
  ......
 
ds_WinTaskbarBalloon(ID,'') ! This closes the balloon.


WinNotOnTaskbar()

Purpose

Applications using this function do not appear on the Windows 95 Task bar. This is normally
used in conjunction with the WinTaskBarAddIcon when you want a background program to
appear on the Taskbar's tray, and not on the taskbar itself. It must be called before the first
window of the application is opened.

IMPORTANT Note : WinNotOnTaskBar is not compatible with auto-shutdown. 
If you are using WinTaskBarAddIcon then the following code may be used as an alternative.

To hide the window
    window{prop:iconize} = TRUE
    window{prop:hide} = TRUE

To unhide the window
    window{prop:hide} = FALSE
    window{prop:iconize} = FALSE

Note that the order of the hide / iconize commands is important

Parameters

None

Returns

Nothing

Example

  code
  WinNotOnTaskBar()
  open(window)

 


WinOnTop()

Purpose

Makes your window float on top of other windows applications. Note: you can't use this function for MDI applications on MDI-child windows.

Parameters

None

Returns

Nothing

Example 1

  code
  open(window)
  WinOnTop()

 

Example 2


! -------------------------------------
! Hides Window (opposite of WindowShow)
! Useful for use with the TaskBar icon code

WindowHide Routine
  window{prop:iconize} = true
  window{prop:hide} = true
 
! -------------------------------------
! Shows Window (opposite of WindowHide)

! Useful for use with the TaskBar icon code
WindowShow Routine
  if window{prop:iconize} = false
    window{prop:iconize} = true
  end
  window{prop:hide} = false
  window{prop:iconize} = false


! -------------------------------------
! Shows Window (opposite of WindowHide)

! Useful for use with the TaskBar icon code
! No Focus is gained

WindowShow_NoFocus Routine
  window{prop:iconize} = false
  window{prop:hide} = false
  WinOnTop()
  WinNotOnTop()




WinNotOnTop()

Purpose

Reverses the effect of the WinOnTop() function. Note: you can't use this function for MDI applications on MDI-child windows.

Parameters

None

Returns

Nothing

Example 1

  code
  open(window)
  WinOnTop()
  WinNotOnTop()

 



 

 

WinBringToFront()

Purpose

Brings your window to the front of the open windows. This would be used if your program wanted to bring itself to the front because some event has occurred that needs action. Note: you can't use this function for MDI applications on MDI-child windows.

Parameters

None

Returns

Nothing

Example

  code
  open(window)
  WinBringToFront()

 

 


 

ds_ShowWindow(byte pGrabFocus=1)

Purpose

Unhides your window.  This is used in conjunction with ds_HideWindow.

Parameters

pGrabFocus (byte) : Optional.  Defaults to TRUE.  When set you window takes focus and so keyboard input goes to your window.


Returns

Nothing

Example

  code
  open(window)
  ds_ShowWindow()

 


 

ds_HideWindow

Purpose

Hides your window.  This is used in conjunction with ds_ShowWindow.

Parameters

None.


Returns

Nothing

Example

  code
  open(window)
  ds_HideWindow()

 


ds_WinTransparent(long Transparency)

NB: Only available for non-MDI windows.

Purpose

Adjusts the transparency of a window .

Parameters

Transparency (long) : This sets the transparency factor.  0 = Invisible,  255 = Normal.   

Returns

Nothing

Example

  code
  open(window)
    ds_WinTransparent(255) ! normal window display
    ds_WinTransparent(0) ! window will be invisible 
 


ds_VisibleOnDesktop(<*long pWinX>,<*long pWinY>,<*long pWinWidth>,<*long pWinHeight>,long pMode=1)

Purpose

Repositions and resizes the window to be visible on the desktop.

Parameters

pWinX (*long) : Optional.  If omitted then the current target window is used.  If supplied then the variable is updated.

pWinY (*long) : Optional.  If omitted then the current target window is used.  If supplied then the variable is updated.

pWinWidth (*long) : Optional.  If omitted then the current target window is used.  If supplied then the variable is updated.

pWinHeight (*long) : Optional.  If omitted then the current target window is used.  If supplied then the variable is updated.

pMode (long) : Optional.  Default=1  When set this flags that the window must not be obscured by the taskbar.

Returns

Nothing

Example

  code
  open(window)
  Open(Window)
  ds_VisibleOnDesktop()


ds_GetWinVersion()

Purpose

Returns the version of windows that is running.

Parameters

None

Returns

String formatted with Windows version, major version number, minor version number, build number and then service pack description.

Win XXX ...............

Note: At least up to Clarion6.3 9056, the Clarion IDE is run in XP compatibility mode on Windows Vista. This means that when running an application from within the IDE, the ds_GetWinVersion will return Win XP, and not Win Vista. The same application run from a normal shortcut will return the correct windows version (i.e. Win Vista).

Example

  code
  DisplayString = ds_GetWinVersion()
! Win 98 4.10.222 A
    ....
    case sub(ds_GetWinVersion(),1,7)
  of 'Win 3.1'
  of 'Win 95'
  of 'Win 98'
  of 'Win NT'
  of 'Win 2K'
  of 'Win 2K3'
  of 'Win XP'
  of 'WinVista'
  else
  end


WindowsVersion()

Purpose

Returns the version of windows that is running. This may return a different number for 16 and 32 bit programs. For example a 16 bit program, running under Windows 95 will return 3 as the windows version number. The version release number is 95. A 32 bit program running under windows 95 will return 4 as the windows version number. The release number is 0.

Parameters

None

Returns

Long containing Windows version number. This together with the release number (WindowsRelease() ) gives you the version number of windows.

Example

  code
  ver = WindowsVersion()

 



WindowsRelease()

Purpose

Returns the release of windows that is running. This may return a different number for 16 and 32 bit programs. For example a 16 bit program, running under Windows 95 will return 3 as the windows version number. The version release number is 95. A 32 bit program running under windows 95 will return 4 as the windows version number. The release number is 0.

Parameters

None

Returns

Long containing Windows release number. This together with the version number (WindowsVersion() ) gives you the version number of windows.

Example

  code
  ver = WindowsVersion()
  rel = WindowsRelease()

 



DosVersion()

Purpose

Returns the version of Dos that is running. This is only valid for 16 bit programs. For example a 16 bit version of a program running on Windows 95 will return 7 as the version number, and 0 as the release number.

Parameters

None

Returns

Long containing Dos version number. This together with the release number (DosRelease() ) gives you the version number of Dos.

Example

  code
  ver = DosVersion()

 



DosRelease()

Purpose

Returns the release of Dos that is running. This is only valid for 16 bit programs. For example a 16 bit version of a program running on Windows 3.11 and Dos 6.22 will return 6 as the version number, and 22 as the release number.

Parameters

None

Returns

Long containing Dos release number. This together with the version number (DosVersion() ) gives you the version number of dos.

Example

code
ver = DosVersion()
rel = DosRelease()

 



GetFreeDiskSpace (<drive long>)

Purpose

Returns the amount of free disk space, in bytes.

Parameters

Drive : Optional. 0 = current drive. 1 = A, 2 = B etc.

Returns

Real containing number of free bytes on the disk. In version 2.6 and earlier of WinEvent this was a Long. 

Example

free real
  code
  free = GetFreeDiskSpace()

 



GetDiskSpace (<drive long>)

Purpose

Returns the total disk space, in bytes.

Parameters

Drive : Optional. 0 = current drive. 1 = A, 2 = B etc.

Returns

Real containing total number of bytes on the disk. However maximum value is currently 2 gigs.

Example

total real
  code
  total = GetDiskSpace()

 


 


ds_GetDiskMegs (<string pDrive>,<string pSelector>)

Purpose

Returns the specified disk space, in megabytes.

Parameters

pDrive (string) : Optional. Defaults to current directory.

pSelector (string) : Optional.  Defaults to 'USER FREE'  This modifies the returned disk size.

'USER FREE'       Returns the free disk space available to the current user.
'TOTAL'                Returns the total disk size.
'TOTAL FREE'      Returns the free disk space on the drive.

Returns

Ulong.   The disk space in megabytes.

Example

total ulong
  code
  total = ds_GetDiskMegs()

 


ds_Memory(<string pSelector>)

Purpose

Returns the specified RAM space, in kBytes.

Parameters

pSelector (string) : Optional.  Defaults to 'USER'  This specifies which RAM size is returned.

'USER'                    Returns the virtual memory used by this application. 
'SWAP USED'        Returns the page file used kBytes.
'SWAP FREE'        Returns the page file free kBytes.
'SWAP TOTAL'       Returns the page file total kBytes.
'RAM USED'           Returns the physical RAM used kBytes.
'RAM FREE'           Returns the physical RAM free kBytes.
'RAM TOTAL'          Returns the physical RAM total kBytes.
'VMEM USED'        Returns the virtual memory used kBytes.
'VMEM FREE'        Returns the virtual memory free kBytes.
'VMEM TOTAL'       Returns the virtual memory total kBytes.

Returns

Ulong.   The RAM size in kilobytes.

Example

total ulong
  code
  total = ds_Memory()
  ! Returns the virtual memory used by this application
 


Sound (WavFileName String)

Purpose

Plays a Wav file through the speaker.

Parameters

WavFileName (string) : The name of the Wav file on the disk, including path if necessary.

Returns

Nothing

Example

  code
  sound('alarm.wav')

 



GetWindowsDir ()

Purpose

Gets the directory where Windows is installed. For multi-user systems this returns the Windows directory that is personal to the logged in user. 

Parameters

None

Returns

A string containing the path to the Windows directory.

Example

a string(255)
  code
  a = GetWindowsDir()

 



GetSystemDir ()

Purpose

Gets the Windows system directory.  

NOTE : This is usually \windows\system

Parameters

None

Returns

A string containing the path to the Windows system directory.

Example

a string(255)
  code
  a = GetSystemDir()

 



ScreenWidth ()

Purpose

Gets the current width, in pixels, of the windows desktop.

Parameters

None

Returns

A long containing the number of pixels.