Home page HwGUI 2.23 reference manual  
prev Alexander S.Kresin, November 2025 next


5. Functions

5.1. Common dialogs

hwg_SelectFont( [ oFont ] )
This function calls the standard dialog for font selecting.
Usually it isn't needed to call this function directly, use HFont():Select( oFont ) instead.

Attention !
All file and directory selection dialogs
execute an internal change directory
(this is, where the selected file is locacted).
After opening the selected file or database
(FCREATE(),FOPEN(),USE xxx )
you must return to the previous directory,
also in case of a cancelled selection.
Here the sample code snippet:

LOCAL fname, colddir, ctemp
* Get current directory as previous directory
colddir := hwg_CurDir()
#ifdef __GTK__
   fname := hwg_SelectFileEx(,,{{ "xBase databases( *.dbf )","*.dbf" },{ "All files" ,"*"}} )
#else
   fname := hwg_Selectfile("xBase databases( *.dbf )" , "*.dbf", cstartvz )
#endif
* Check for cancel
IF EMPTY( fname )
   * Return to previous directory
   hwg_ChDir(hwg_CleanPathname(colddir))
   RETURN NIL
ENDIF
* Open the selected DBF
ctemp := hwg_BaseName(hwg_ProcFileExt(cdbfmod,""))
SELECT 1
USE &ctemp
* Return to previous directory
hwg_ChDir(hwg_CleanPathname(colddir))

Find this code also in "utils\devtools\dbfcompare.prg".


hwg_SelectFile( cDescript,cMask,[ cInitDir ], [ cTitle ] )
This function calls the standard dialog for file selecting. The user can select an existing file or input a new file name, if application will
create an new file.
On GTK:
hwg_Selectfile() ignores the mask and shows all files.
Use hwg_SelectfileEx() instead.
File extensions are not handled by this function.
Please use Harbour function RAT() to detect, if no file extension is entered and add it in this case after returning of this function.

See sample program "samples/demodlgbox.prg" for usage of all file selection dialogs.
For Multi Platform purposes use the compiler switch "#ifdef __GTK__".

An example:
   cFileName := hwg_Selectfile( {"dbf files( *.dbf )","All files(*.*)"}, ;
      {"*.dbf","*.*"}, cPath )

hwg_SelectFileEx( [cTitle] [,cInitDir] [,aDescript] ) (GTK only)
Another standard dialog for file selection. Use this function instead of hwg_SelectFile() or hwg_SaveFile() with GTK.
Only for selecting an existing file, for creating a new file use hwg_SelectFile().
See sample program "samples/demodlgbox.prg" for usage of all file selection dialogs.
For Multi Platform purposes use the compiler switch "#ifdef __GTK__".

An example:
   cFileName := hwg_SelectFileEx( ,, { { "Dbf files", "*.dbf" }, { "All files", "*" } } )

hwg_SelectFolder( cTitle )
The standard dialog for folder selection. See sample program "samples/demodlgbox.prg" for usage of all file selection dialogs.


hwg_SaveFile( cPrompt,cDescript,cMask,cInitDir,cTitle ) (Windows only)
This function calls the standard dialog for file saving.
This function is a suitable solution, if an application needs to overwrite an existing
file or create a new one, so that the user can input a file name of a non exiting file.
See sample program "samples/demodlgbox.prg" for usage of all file selection dialogs.
On GTK, use hwg_Selectfile() instead.
For Multi Platform purposes use the compiler switch "#ifdef __GTK__".

An example:
   fname := hwg_Savefile( "*.htm","( *.htm )","*.htm", cPath )

hwg_PrintSetup( @cPrinterName ) (Windows only)
This function calls the standard dialog for printer selecting.
hwg_ChooseColor( nColorCurrent )
This function calls the standard dialog for color selecting.
5.2. MessageBoxes and HwGUI dialogs

hwg_MsgInfo( cMessage,cTitle )
hwg_MsgStop( cMessage,cTitle )
hwg_MsgOkCancel( cMessage,cTitle )
hwg_MsgYesNo( cMessage,cTitle )
hwg_MsgYesNoCancel( cMessage,cTitle )
hwg_MsgNoYes( cMessage,cTitle ) (Windows only)
hwg_MsgRetryCancel( cMessage,cTitle ) (Windows only)
hwg_MsgExclamation( cMessage,cTitle )

These all are standard message boxes with a different buttons set.


Special return values:
hwg_MsgYesNoCancel() : cancel = 0 , yes = 1 , no = 2
WinAPI: hwg_MsgOkCancel() : OK = 1 , Cancel = 2 , GTK: .T., .F.


hwg_MsgBeep( nSound ) (Windows only)


hwg_ShellAbout( cText1, cText2 [,hIcon] ) (Windows only)


hwg_MsgGet( cTitle, cText, nStyle, nLeft, nTop, nDlgStyle, cInitStr )
Creates a dialog box to input a string.
hwg_WChoice( arr, cTitle, nLeft, nTop, oFont, clrT, clrB, clrTSel, clrBSel, cOk, cCancel,nwline)
Creates a dialog box to select from a list. Important !
Workaround for bug in GTK (GetTextMetric does not work correct):
The new parameter "nwline" is ignored on WinAPI,
because the functions works correct on Windows,
it is the height for every line in the array to browse.
The default value is 21, this seems to be suitable for default font
"Times", 0, 14 .
Please make experiments with this parameter if
other fonts are used.
For details and symptom description see
test program test/tickets/Ticket90.prg.


5.3. Drawing functions.


hwg_DefinePaintStru() It is called during the painting (usually it is a Paint() method), together with two next functions, hwg_BeginPaint( handle, pps ) and hwg_EndPaint( handle, pps ).


hwg_BeginPaint( handle, pps )
This function starts painting.
hwg_EndPaint( handle, pps )
This function ends painting.
hwg_Getdrawiteminfo( lpDis ) (Windows only)
If a control has SS_OWNERDRAW style and messages for him aren't handled by HwGUI (look at 3.9. Inside HwGUI), the handler of ON PAINT gets as a second parameter a pointer to DRAWITEMSTRUCT WinAPI structure, which contains an information, needed to draw this control. A function hwg_GetDrawItemInfo( lpDis ) extracts this info and returns to a programmer as an array.
While drawing these controls functions hwg_DefinePaintStru(), hwg_BeginPaint(), hwg_EndPaint() shouldn't be used.
hwg_GetClientRect( handle )
hwg_SelectObject( hDC, handle )
This function selects an object of HFont, HPen or HBrush class as current for drawing area, i.e., all subsequent drawing operations will use it. For example:
    // Create HPen object: a line thickness - 2px, a color - red
    oPen := HPen():Add( BS_SOLID, 2, 255 )
    // Select this object as current for hDC
    hwg_Selectobject( hDC, oPen:handle )
    // Draw a 2px red line
    hwg_Drawline( hDC, 5, 1, 100, 1 )

hwg_DeleteObject( handle )
Deletes a font, a pen, a brush, a bitmap or an icon. Pay attention that this function works on WinAPI/GTK level, it deletes not a HwGUI object, but WinaPI/GTK's. Ususlly it isn't needed to call it directly from your application, the Release() method of an appropriate HwGUI class does all necessary operations.
hwg_MoveTo( hDC, x1, y1 )
Changes current position of a pen on a drawing area.
hwg_LineTo( hDC, x1, y1 [, lClose] )
Draws a line from a current position to a point with given coordinates. Uses a pen, selected with the help of hwg_SelectObject().
hwg_Rectangle( hDC, x1, y1, x2, y2 [, hPen] )
Draws a rectangle with given coordinates. Uses a pen, selected with the help of hwg_SelectObject(), if hPen parameter is not passed.
hwg_Rectangle_Filled( hDC, x1, y1, x2, y2 [, hPen | lPen] [, hBrush] )
Draws a rectangle with given coordinates and fills it. Uses a pen, selected with the help of hwg_SelectObject(), if hPen parameter is not passed. If logical .F. passed instead, the rectangle border will be absent.
hwg_Triangle( hDC, x1, y1, x2, y2, x3, y3 [, hPen] )
Draws a triangle with given coordinates. Uses a pen, selected with the help of hwg_SelectObject(), if hPen parameter is not passed. If logical .F. passed instead, the triangle border will be absent.
hwg_Triangle_Filled( hDC, x1, y1, x2, y2, x3, y3 [, hPen | lPen] [, hBrush] )
Draws a triangle with given coordinates. Uses a pen, selected with the help of hwg_SelectObject(), if hPen parameter is not passed. If logical .F. passed instead, the triangle border will be absent.
hwg_RoundRect( hDC, x1, y1, x2, y2, iRadius [, hPen] )
Draws a rectangle with rounded corners. Uses a pen, selected with the help of hwg_SelectObject(), if hPen parameter is not passed.
hwg_RoundRect_Filled( hDC, x1, y1, x2, y2, iRadius [, hPen | lPen] [, hBrush] )
Draws a rectangle with rounded corners. Uses a pen, selected with the help of hwg_SelectObject(), if hPen parameter is not passed. If logical .F. passed instead, the rectangle border will be absent.
hwg_Ellipse( hDC, x1, y1, x2, y2 [, hPen] )
Draws an ellipse in a rectangle with given coordinates. Uses a pen and a brush, selected with the help of hwg_SelectObject(), if hPen is not passed.
hwg_Ellipse_Filled( hDC, x1, y1, x2, y2 [, hPen | lPen] [, hBrush] )
Draws an ellipse in a rectangle with given coordinates and fills area inside. Uses a pen and a brush, selected with the help of hwg_SelectObject(), if hPen or hBrush parameter are not passed. If logical .F. passed instead of hPen, the border will be absent.
hwg_DrawLine( hDC, x1, y1, x2, y2 )
Draws a line from one point to another. Uses a pen, selected with the help of hwg_SelectObject().
hwg_Pie( hDC, x1, y1, x2, y2, xr1, yr1, xr2, yr2 ) (Windows only)
Draws a pie-shaped wedge bounded by the intersection of an ellipse and two radials and fills area inside. Uses a pen and a brush, selected with the help of hwg_SelectObject().
hwg_FillRect( hDC, x1, y1, x2, y2, hBrush )
Fills a rectangle with given coordinates, using a passed brush.
hwg_Drawbutton( hDC, x1, y1, x2, y2, nFlag )
Draws a button.
hwg_DrawEdge( hDC, x1, y1, x2, y2, nFlag, nBorder ) (Windows only)
Draws one or more edges of rectangle.
hwg_gtk_DrawEdge( hDC, x1, y1, x2, y2, nFlag ) (GTK only)
Draws one or more edges of rectangle.
hwg_Arc( hDC, xc, yc, radius, iAngleStart, iAngleEnd )
Draws an arc with a center in xc, yc, with a radius from an angle iAngleStart to iAngleEnd.
hwg_drawGradient( hDC, x1, y1, x2, y2, int type, array colors, array stops, array radiuses )
This function draws rectangle with rounded corners and fill it with gradient pattern.
hwg_OpenImage( cName | cBody [, lMem] )
Create a bitmap from the data stored in an image file or in a passed data. In most cases you don't need to call this function directly, use HBitmap():AddFile(cName) instead.
hwg_OpenBitmap( cName [, hDC] )
Creates a bitmap from the data stored in the bmp file. In most cases you don't need to call this function directly, use HBitmap():AddFile(cName) instead.
hwg_SaveBitmap( cName, hBitmap )


Function only for internal usage.
To save a bitmap object into a file,
use FUNCTION hwg_oBitmap2file().


hwg_StockBitmap( cName [,nSizeType] ) (GTK only)
GTK has a number of predefined stock icons, which can be used in application. It is very convenient because it saves the programmer from having to store the image files included with the executable. This function creates a bitmap from a stock object. In most cases you don't need to call this function directly, use HBitmap():AddStandard(cName) instead.
hwg_DrawBitmap( hDC, hBitmap, style, x, y [, width, height] )
Draws a bitmap.
hwg_DrawTransparentBitmap( hDC, hBitmap, x, y [,trColor] [, width, height] )
Draws a transparent bitmap.
hwg_Drawgraybitmap( hDC, hBitmap, x, y ) (Windows only)
Draws a bitmap in grayscale mode.
hwg_SpreadBitmap( hDC, hBitmap [, nLeft, nTop, nRight, nBottom] )
This funtion spreads a bitmap over all the drawing area or within rectangle with passed coordinates by multiplying.
hwg_Drawicon( hDC, hIcon, x1, y1 ) (Windows only)
Draws an icon.
hwg_CenterBitmap( hDC, hWnd, hBitmap, style, brush ) (Windows only)


hwg_GetBitmapSize( hBitmap )
Returns an array with the size (width and height) of a bitmap.
hwg_GetBitmapHeight( hBitmap )

hBitmap : Handle of a bitmap object, for example "oBitmap:handle".
Returns the height of a bitmap.


hwg_GetBitmapWidth( hBitmap )

hBitmap : Handle of a bitmap object, for example "oBitmap:handle".
Returns the width of a bitmap.


hwg_GetIconSize( hIcon ) (Windows only)
Returns an array with the size (width and height) of an icon.
hwg_Getsyscolor( nCode )
Retrieves the current color of the specified display element. Display elements are the parts of a window and the display that appear on the system display screen. In GTK version always return a background color of a main window.
hwg_GetsyscolorBrush( nCode ) (Windows only)
Retrieves a brush handle, corresponding to a current color of the specified display element. Display elements are the parts of a window and the display that appear on the system display screen.
hwg_Createpen( nStyle, nWidth, nColor )
Creates a pen with given parameters. Usually it isn't needed to call this function directly, use HPen():Add() instead.
hwg_Createsolidbrush( nColor )
Creates a brush that has the specified color. Usually it isn't needed to call this function directly, use HBrush():Add() instead.
hwg_Createhatchbrush( nHatch, nColor ) (Windows only)
Creates a brush that has the specified hatch pattern and color. Usually it isn't needed to call this function directly, use HBrush():Add() instead.
hwg_GetDC( hWnd )
Returns handle of device context of GUI element. After using this handle must be released with a help of hwg_ReleaseDC( hWnd, hDC ).
hwg_ReleaseDC( hWnd, hDC )
Releases handle of device context, which was created using hwg_GetDC( hWnd ).
hwg_SaveDC( hDC ) (Windows only)


hwg_DeleteDC( hDC ) (Windows only)


hwg_Restoredc( hDC, nSavedDC ) (Windows only)


hwg_CreateCompatibleDC( hDC )


hwg_CreateCompatibleBitmap( hDC, nWidth, nHeight ) (Windows only)


hwg_Patblt( hDc, a, s, d, f, g ) (Windows only)


hwg_Bitblt( hDc, x, y, nWidth, nHeight, pSrcDC, xSrc, ySrc, nFlag )


hwg_Setmapmode( hDC, nMapMode ) (Windows only)


hwg_Setwindoworgex( hDC, x, y, @point ) (Windows only)


hwg_Setwindowextex( hDC, x, y, @point ) (Windows only)


hwg_Setviewportorgex( hDC, x, y, @point ) (Windows only)


hwg_Setviewportextex( hDC, x, y, @point ) (Windows only)


hwg_Setarcdirection( hDC, nArcDirection ) (Windows only)


hwg_Setrop2( hDC, nDrawMode ) (Windows only)


hwg_DrawFrameControl( hDC, nType, nState ) (Windows only)


hwg_TextOut( hDC, x, y, cText )
Draws a text. Uses a font, selected with the help of hwg_SelectObject().
hwg_DrawText( hDC, cText, x1 | aRect [, y1, x2, y2, nStyle [,aRect]] )
Draws a text in a given rectangle, aligned accorgingly to a passed parameter. Uses a font, selected with the help of hwg_SelectObject().
hwg_GetTextMetric( hDC )
Returns an array with geometric text parameters for a given device contect, for a font, selected with the help of hwg_SelectObject().
hwg_GetTextSize( hDC, cText )
Returns an array with geometric text size for a given device contect, for a font, selected with the help of hwg_SelectObject().
hwg_GetClientRect( handle )


hwg_GetWindowRect( handle )


hwg_SetTextColor( hDC, nColor )
Sets text color for a drawing.
hwg_GetTextColor( hDC )
Returns current text color setting for a drawing area.
hwg_SetBkColor( hDC, nColor )
Sets background color for a drawing.
hwg_GetBkColor( hDC )
Returns current background color setting for a drawing area.
hwg_SetTransparentMode( hDC, lTransparent )
Sets or unsets a transparent mode for a writing text on a drawing area.
hwg_Exttextout( hDC, x, y, x1, y1, x2, y2, cText ) (Windows only)


hwg_WindowFromDC( hDC ) (Windows only)
Retrieves a handle of GUI element by it hDC.
hwg_Loadimage( hInstance, cName, nType, nWidth, nHeight, nFlags ) (Windows only)


hwg_Loadbitmap( nId | cName [,l] ) (Windows only)


hwg_Window2bitmap( hWnd, x1, y1, width, height )
Creates a bitmap from a given region of a window or control. If coordinates aren't passed, the whole window is used.
hwg_RedrawWindow( handle, nFlags, x1, y1, nWidth, nHeight )


hwg_Invalidaterect( handle, lEraseBack, x1, y1, x2, y2 )


hwg_GetPpsRect( pps ) (Windows only)


hwg_GetPpsErase( pps ) (Windows only)


hwg_GetUpdateRect( hWnd ) (Windows only)


5.4. Windows handling functions.


hwg_GetModalDlg()
hwg_EndDialog( [handle] )
Closes a dialog with a handle; if handle isn't passed, the current modal dialog is closed.
hwg_EndWindow()
Closes the main window.


hwg_isWindow( hWnd ) (Windows only)
Determines whether the specified window handle identifies an existing window.
hwg_FlashWindow( hWnd ) (Windows only)
Flashes the specified window one time - change the appearance of its caption bar as if the window were changing from inactive to active status, or vice versa.
hwg_GetActiveWindow()
hwg_GetInstance (Windows only)


hwg_SetWindowStyle( handle, nStyle ) (Windows only)
This function sets a WinAPI style to GUI element.
hwg_GetWindowStyle( handle ) (Windows only)
This function returns a WinAPI style of GUI element.
hwg_SetWindowExStyle( handle, nStyle ) (Windows only)
This function sets an extended WinAPI style to GUI element.
hwg_GetWindowExStyle( handle ) (Windows only)
This function returns an extended WinAPI style of GUI element.
hwg_FindWindow( cClassName, cWindowName) (Windows only)


hwg_SetForegroundWindow( handle ) (Windows only)


hwg_BringToTop( handle ) (Windows only)
Sets the window over all other windows.
hwg_ResetWindowPos( handle ) (Windows only)


hwg_UpdateWindow( handle ) (Windows only)


hwg_CenterWindow( handle )
Centers a window on a screen.
hwg_RestoreWindow( handle )
Restores the default window size.
hwg_EnableWindow( handle, lEnable )
Enables or disables GUI element (window or control).
hwg_isWindowEnabled( handle )
Checks, if the GUI element (window or control) is enabled.
hwg_HideWindow( handle )
Hide GUI element (window or control).
hwg_ShowWindow( handle )
Show GUI element (window or control).
hwg_ProcessMessage( [lMdi] [, nSleep] )


hwg_PeekMessage( hWnd ) (Windows only)


hwg_DoEvents() (Windows only)


hwg_SendMessage( handle, nMessage, wParam, lParam ) (Windows only)


hwg_PostMessage( handle, nMessage, wParam, lParam ) (Windows only)


hwg_SetWindowObject( handle, object )


hwg_GetWindowObject( handle )


hwg_SetWindowText( handle, cTitle )
Changes the text of the specified window's title bar or the text of a control.
hwg_GetWindowText( handle )
Returns the text of the specified window's title bar or the text of a control.
hwg_SetWindowFont( handle, hFont, l ) (Windows only)


hwg_GetLastError() (Windows only)


hwg_isIconic( hWnd )


hwg_isWindowVisible( hWnd )


hwg_ExitProcess() (Windows only)


hwg_WindowSetResize( hWnd, lResizeable )
Sets the window resizeable or no resizeable.
hwg_SetTopmost( hWnd )


hwg_RemoveTopmost( hWnd )


hwg_ChildWindowFromPoint( hWnd, x, y ) (Windows only)


hwg_WindowFromPoint( hWnd, x, y ) (Windows only)


hwg_GetFontDialogUnits( hWnd ) (Windows only)


hwg_GetWindowPlacement( handle ) (Windows only)


hwg_ClearKeyboard() (Windows only)


5.5. Controls handling functions.


hwg_SetFocus( handle )
Sets the keyboard focus to the specified GUI element (window or control).
hwg_GetFocus()
Retrieves the handle to the GUI element (window or control) that has the keyboard focus.
hwg_WriteStatus( oWnd, nPart, cText, lRedraw )
Writes a text string to a fragment of a status pane. This function works for a standard Status and or a Status Panel.
hwg_FindParent( hCtrl )
Returns an object of a parent GUI element for a widget by it handle.
hwg_FindSelf( hCtrl )
Returns an object of a widget by it handle.
hwg_getParentForm( oCtrl )
Returns an object of a window, which includes a given widget. The distinction from hwg_FindParent() is the following: hwg_FindParent() looks for a direct parent, it may be another widget, such as Tab, Panel or Toolbar. hwg_getParentForm() always returns a window, which includes the given widget.
hwg_MoveWindow( handle, nLeft, nTop, nWidth, nHeight, lRepaint )


hwg_DestroyWindow( handle )


hwg_Createarlist( oBrw, arr )

For BROWSE of arrays:
Copies the array to browse into the
browse object.
Usage see sample program "demobrowsearr.prg".
arr: an array with 2 dimensions, for example
al_DOKs := { {"1"} , {"2"} , {"3"} , {"4"} }
...

Sample for read out the edited array:

@ 360,410 BUTTON oBtn4 CAPTION "OK " SIZE 80,26 ;
ON CLICK { | | bCancel := .F. , ;
al_DOKs := oBrwArr:aArray , ;
hwg_EndDialog() }


hwg_CreateList( oBrw, lEditable )


hwg_VScrollPos( oBrw, nType, lEof, nPos )


hwg_HScrollPos( oBrw, nType, lEof, nPos )


hwg_ColumnArBlock()


hwg_ShowProgress( nStep, maxPos, nRange, cTitle, oWnd, x1, y1, width, height ) (Windows only)


hwg_UpdateProgressBar( handle )


hwg_SetProgressBar( handle, nPos )


hwg_SetRangeProgressBar( handle, nValue )


hwg_trackbarsetrange( handle, nLow, nHigh ) (Windows only)


hwg_SetMonthCalendarDate( handle , dValue )


hwg_GetMonthCalendarDate( handle )


hwg_Setctrlfont( parentHandle, nId, hFont ) (Windows only)


hwg_Setctrlfont( handle, hFont ) (GTK only)


hwg_DefaultFont()

Returns an object with a suitable default font
for Windows and LINUX, OS dependent.


hwg_AddTooltip( handle, cTooltip )
Add a tooltip to the control.
hwg_DelTooltip( handle )
Delete a tooltip of the control.
hwg_SetTooltipTitle( handle, cTooltip )
Update the text of a tooltip.
hwg_SetUpdown( handle, nValue )


hwg_SetRangeUpdown( handle, n1, n2 )


hwg_SetDatePicker( handle, dValue ) (Windows only)


hwg_SetDatePickerNull( handle ) (Windows only)


hwg_GetDatePicker( handle ) (Windows only)


hwg_GetTimePicker( handle ) (Windows only)


hwg_GetTimePicker( handle ) (Windows only)


hwg_pCalendar(dstartdate, cTitle , cOK, cCancel , nx , ny , wid, hei )

This function calls the calendar for date selection
in design like the WinAPI datepicker.
Based on the MONTHCALENDAR command.

 dstartdate : Date of start, if NIL, the default is "today" from system date.
 cTitle : Title for this dialog, default is "Calendar"
 cOK : Caption for OK button, default is "OK"
 cCancel : Caption for cancel button, default is "Cancel"
 nx , ny : Position in calling Window (default 0, 0)
 wid, hei : Width and height of the calendar window, add 23 pixels
    to height for size of dialog (space for buttons needed).
    Default is 200, 160.

 Returns the selected date (type "D").

For details see inline comments of sample program
"samples/testget1.prg".
Here you find instructions to create a multiplatform substitute for the Windows only DATEPICKER.

Some Screenshots:

Datepicker Windows:
(Heute = today)
Datepicker Windows

Datepicker substitute Windows all screens:
Datepicker substitute Windows all screens

Datepicker LINUX (Sample program demoget1.prg):
Datepicker LINUX

Windows MONTHCALENDAR command:
(Fertig = Ready, Abbruch = Cancel)
Windows MONTHCALENDAR command

LINUX MONTHCALENDAR command:
LINUX MONTHCALENDAR command



hwg_AddTab( handle, cName )


hwg_DeleteTab( handle, nPage )


hwg_GetCurrentTab( handle )


hwg_SetCurrentTab( handle, nPage ) (GTK only)


hwg_SetTabSize( handle, nWidth, nHeight ) (Windows only)


hwg_GetTabHeight( handle ) (Windows only)


hwg_SetTabName( handle, nPage, cName )


hwg_CreateImageList( aImages, nWidth, nHeight, nGrow, nFlags ) (Windows only)


hwg_DestroyImageList( handle ) (Windows only)


hwg_Imagelist_Add( handle, hBitmap ) (Windows only)


hwg_Imagelist_AddMasked( handle, hBitmap, nMask ) (Windows only)


hwg_ImageList_GetImageCount( handle ) (Windows only)


hwg_getParent( handle )
Returns handle of a parent GUI element, using a system call WinAPI/GTK - so, it is faster, than with the help of oParent variable of appropriate object.
hwg_getAncestor( handle ) (Windows only)


hwg_LoadCursor( cursor )

Loads a cursor from stock and returns its handle.

GTK: Parameter "cursor" is a numeric value for identifying
the standard cursor from stock.
Allowed values are defined in HWGUI include file "gtk.ch" as
GDK_* definitions, for example:
GDK_ARROW Standard arrow
GDK_SB_V_DOUBLE_ARROW Double pointed arrow pointing north and south
GDK_SB_H_DOUBLE_ARROW Double pointed arrow pointing west and east
Attention !
Invalid value may cause crash or freeze of program.

WinAPI: Parameter "cursor" is a numerical value. It is evaluated from a string for the second parameter of WinAPI function
"LoadCursor(hInstance,lpCursorName)"
by macro
MAKEINTRESOURCE(n) (used in HWGUI source file "control.c").
The allowed values are defined in include "winuser.h"
as IDC_* definitions, for example:
 IDC_ARROW Standard arrow
 IDC_SIZENS Double pointed arrow pointing north and south
 IDC_SIZEWE Double pointed arrow pointing west and east
(not the same cursors as described for GTK above)

For setting of parameter for hwg_LoadCursor()
look into the WinAPI include file "winuser.h"
to get the numerical value, for example:
 IDC_ARROW : 32512
 IDC_SIZENS : 32645
 IDC_SIZEWE : 32644
Invalid value loads the IDC_ARROW, it is the default cursor.

To display the cursor, call functions
hwg_SetCursor() and hwg_ShowCursor().

Use the compiler switch "#ifdef __GTK__" for
use in multi platform applications.
See sample program "demosplit.prg".


hwg_LoadCursorFromFile(ccurFname) (Windows only)

Loads a cursor from a "*.cur" type file and returns its handle.
ccurFname : Filename (and path) of cursor file name.
In case of errors the handle for default cursor "Arrow" is
returned.
Cursor files are created and edited with special cursor editor programs.
So it is possible to use customized cursor's in an HWGUI application.

To display the cursor, call functions
hwg_SetCursor() and hwg_ShowCursor().

Use the compiler switch "#ifdef __GTK__" for
use in multi platform applications.


hwg_LoadCursorFromFile(ccurFname,x,y) (GTK only)

Loads a cursor from a "*.cur" type file and returns its handle.
This is the special version for GTK and has the additional parameters x and y.
All other descriptions see WinAPI version of this function.

Uses the following GTK function for creating the cursor:
GdkCursor* gdk_cursor_new_from_pixbuf(GdkDisplay *display,GdkPixbuf *pixbuf, gint x, gint y)

The parameters x and y are mandatory.

x: the horizontal offset of the 'hotspot' of the cursor
y: the vertical offset of the 'hotspot' of the cursor

We suggest, to try for x and y the half size value of pixels.
The value of the resulting pixbuf (not the file size of the *.cur file)
may not exceed 4095 bytes.

For details read the GTK 2 reference.

Use the compiler switch "#ifdef __GTK__" for
use in multi platform applications.


hwg_LoadCursorFromString(cVal, nx , ny)

Loads a cursor from a binary variable and returns its handle.
It is an equivalent to functions "hwg_LoadCursorFromFile()" for WinAPI and GTK.
For details look to the descriptions of this functions.
Parameters nx and ny are ignored on WinAPI, but set them for multi platform applications.

Strategy:

1) Create the *.cur file with an suitable cursor editor.
2) Create an hex value from this file with utility "file2hex.prg"
in directory "utils\bincnt".
3) In your program, convert the hex values into binary with function "hwg_cHex2Bin()".
Create the handle of cursor by calling function "hwg_LoadCursorFromString()".
4) To display the cursor, call functions hwg_SetCursor() and hwg_ShowCursor().

See sample program "demosplit.prg" for details.


hwg_SetCursor( cursor, hCtrl )


hwg_GetCursor() (Windows only)


hwg_SetTooltipBalloon( lBalloon ) (Windows only)

 The tooltip balloon is a nice gimmick of Windows and is not available in GTK,
 so this function is an "empty function".
 For compatible purposes you can set
  hwg_Settooltipballoon(.T.)
 as you like in your app, but the function call has no effect in GTK.
 In GTK, the tooltip is always displayed in an rectangle.


hwg_GetTooltipBalloon() (Windows only)


hwg_SetDlgItemText( parentHandle, nId, cText ) (Windows only)
Sets the title or text of a control.
hwg_GetDlgItemText( parentHandle, nId ) (Windows only)
Retrieves the title or text associated with a control.
hwg_GetEditText( parentHandle, nId ) (Windows only)
Retrieves the text associated with an edit control.
hwg_edit_Getpos( handle )
Returns the cursor position in an edit control.
hwg_edit_Setpos( handle, nPos )
Sets the cursor position in an edit control.
hwg_CheckDlgButton( parentHandle, nId, lValue ) (Windows only)


hwg_isDlgButtonChecked( parentHandle, nId ) (Windows only)


hwg_ComboAddString( handle, cText ) (Windows only)


hwg_ComboInsertString( handle, nPos, cText ) (Windows only)


hwg_ComboSetString( handle, nPos ) (Windows only)


hwg_ListboxAddString( handle, cValue ) (Windows only)


hwg_ModifyStyle( hWnd, nStyleDel, nStyleAdd ) (Windows only)


hwg_re_SetCharFormat( hCtrl, n1, n2, nColor, cName, nHeight, lBold, lItalic, lUnderline, nCharset, lSuperScript/lSubscript, lProtected ) (Windows only)


hwg_re_SetDefault( hCtrl, nColor, cName, nHeight, lBold, lItalic, lUnderline, nCharset ) (Windows only)


hwg_re_CharFromPos( hEdit, xPos, yPos ) (Windows only)


hwg_re_GetTextRange( hEdit, n1, n2 ) (Windows only)


hwg_re_GetLine( hEdit, nLine ) (Windows only)


hwg_re_InsertText( hEdit, cText ) (Windows only)


hwg_re_FindText( hEdit, cFind, nStart, bCase, bWholeWord, bSearchUp ) (Windows only)


hwg_re_SetZoom( hEdit, nNum, nDen ) (Windows only)


hwg_re_ZoomOff( hEdit ) (Windows only)


hwg_re_GetZoom( hEdit, @nNum, @nDen ) (Windows only)


hwg_PrintRtf( hEdit, hDC ) (Windows only)


hwg_SaveRichedit( hEdit, cFileName ) (Windows only)


hwg_LoadRichedit( hEdit, cFileName ) (Windows only)


5.6. Menu functions.


Hwg_AddMenuItem( aMenu, cItem, nMenuId, lSubMenu, bItem, nPos )


Hwg_DefineMenuItem( cItem, nId, bItem, lDisabled, accFlag, accKey, lBitmap, lResource, lCheck )


Hwg_DefineAccelItem( nId, bItem, accFlag, accKey )


Hwg_InsertBitmapMenu( aMenu, nId, lBitmap, oResource ) (Windows only)


Hwg_SetMenuItemBitmaps( aMenu, nId, abmp1, abmp2 ) (Windows only)


hwg_DeleteMenuItem( oWnd, nId )


Hwg_FindMenuItem( aMenu, nId, nPos )

Searches menu item with id "nId" in an menu array "aMenu" inclusive
all submenus (recursive search).
Returns the array with match of nId, if no match NIL.
nPos returns via call by reference the position in the menu found:
For example:
   LOCAL nPos
   nPos := 1
   Hwg_FindMenuItem( aMenu[ 1,nPos ] , nId, @nPos1 )


hwg_CheckMenuItem( xWnd, nId, lValue )
Checks or unchecks a menu item
hwg_IsCheckedMenuItem( xWnd, nId )
Return the state of a window (checked or unchecked)
hwg_EnableMenuItem( xWnd, nId, lValue )
Enables or disables a menu item
hwg_IsEnabledMenuItem( xWnd, nId )
Return the state of a window (enabled or disabled)
hwg_SetMenuCaption( xWnd, nId, cText )


hwg_GetMenuCaption( xWnd, nId )

<not available>
Returns the caption (string) of a menu item defined by the id of a menu item


hwg_DrawMenuBar( hWnd )



5.7. Windows registry.


Comment for multi platform programs:
It is not a good idea, to store program settings in the registry.
Use configuration files instead, following formats are possible:
-  XML files (best choice, strictly recommended for new applications),
-  Ini files (*.ini), see comment for function Hwg_WriteIni(),
-  Clipper MEM files, are supported by Harbour of course,
-  Pure text files.

The registry functions can be useful for writing a multi platform setup program
with HWGUI.
Use the compiler switch "#ifndef __GTK__" to hide the registry functions on non Windows systems.


hwg_RegCreateKey( handle, cKeyName ) (Windows only)


hwg_RegOpenKey( handle, cKeyName ) (Windows only)


hwg_RegCloseKey( handle ) (Windows only)


hwg_RegSetString( handle, cKeyName, cKeyValue ) (Windows only)


hwg_RegSetBinary( handle, cKeyName, cBinValue ) (Windows only)


hwg_RegGetValue( handle, cKeyName [,nType] ) (Windows only)


5.8. Miscellaneous functions.


ft_origin()

Get origin path and name (this were the exe file is located).
ft_origin() is only available in Harbour 3.4 and up, but
here the solution for multi platform usage
and Harbour 3.2 and up !
(for both HWGUI and Harbour terminal/console applications)

argv[0]: The argv[0] argument passed to the main()
function contains the path and name of the executable file.

int main(int argc, char *argv[]) {
printf("Executable path: %s", argv[0]);
return 0;
}
but this is reachable from Harbour and HWGUI by following sequence:

LOCAL coriginp, coriginchdir

* Get the origin path and name
coriginp := hb_argV( 0 )

* Change to origin directory
IF .NOT. EMPTY(coriginp)
coriginchdir := hwg_Dirname(coriginp)
//ft_ChDir( coriginp )
hwg_CHDIR(coriginchdir)
ENDIF
==> find this sequence in sample program "demofunc.prg"
and test program "test/test_origin_cons".

Purpose:
Go to the origin directory before opening files and databases in this directory,
now you can call the programm by using an absolute path !

This is checked on LINUX and MacOS with GCC,
Windows with MinGW and BCC.
Ignore warning with BCC:
Call to function 'chdir' with no prototype in function HB_FUN_HWG_CHDIR
Not checked on other Compilers (Pelles C, ...)
We will add the test results as soon as possible)


hwg_GetDirSep()
Returns the directory seperator character OS dependant.


hwg_CurDrive()
Windows:
   Returns the current drive letter with suffix ":\",
   so that complete path values can be easy concatenated.
   This function works also on GTK cross development environment.
UNIX/LINUX:
   Returns for multi platform usage an empty String "".
   Use this function like the Windows version.


hwg_CurDir()
Returns full path of current directory.
The Harbour function CurDir() does not return the
leading "\" or "/" Character.
To assemble a full path and filename, follow this example:
 href="hwgdoc.html#_Functions81">cp := hwg_CurDir() + hwg_GetDirSep() + "sample.txt"

This function returns the complete path with drive letter on Windows.
This function works also on GTK cross development environment.


hwg_EOLStyle()
Returns the "End Of Line" (EOL) character(s) OS dependent.
Windows: 0D0A (CRLF)
LINUX/UNIX: 0A (LF)
This function works also on GTK cross development environment.
MacOS not supported yet.
Must then return 0D (CR).


hwg_strrev()
Reverse strings with UTF-8

Reverses a string.
This is the equivalent strrev() function from the standard C library,
but extended to understand UTF-8.
cstring may not exceed 511 bytes, inclusive length of all
used UTF-8 characters.


hwg_GetEpoch()
Returns the recent value of
SET EPOCH TO ...
as integer value.
This is helpful to recover a
previous setting of the epoch
processing code with alternative setting.

Sample:
 LOCAL nsetepoch, csetepoch
 nsetepoch := hwg_GetEpoch()
  * Default value is 1900
  SET EPOCH TO 2000   * ... && processing with new EPOCH setting
  * Now restore old setting:
  csetepoch := ALLTRIM(STR(nsetepoch) )
  SET EPOCH TO &csetepoch

Important advice for HWGUI programmers:
Found this function in
source/common/procmisc/cfuncs.c:
The function hb_setGetEpoch() is existing in Harbour 3.2,
but not apearing in a *.h file of Harbour as prototype,
so need to include "hb_missing.h" in HWGUI.


hwg_GetItemByName( arr, cName )
Returns an object from an array by its name, which is kept as :objname.


hwg_Version( n )
Returns an information about current HwGUI version. The optional parameter defines the kind of information:

Instructions for programmer, who publishes a new HWGUI release:
Set release and build number in this include file before a new release is created:
include\guilib.ch
Reset the values of HWG_VERSION to "Code Snapshot" and
HWG_BUILD to 0 after publification of a new HWGUI release.


hwg_Trace()
The function is intended for debugging purposes. It returns a current procedures stack.

hwg_WriteLog( cText [, fname] )
Adds a text to a file, the function is intended for debugging purposes.
void hwg_writelog( const char * sFile, const char * sTraceMsg, ... )( cText [, fname] )
C function simular to hwg_WriteLog, for use in C modules of your application.
Adds a text to a file, the functions is intended for debugging purposes.

A sample code snippet to log numeric values:
   char debug[100];
   int num = 1000;
   itoa(num,&debug,10);
   hwg_writelog(NULL,&debug);


hwg_SetDlgKey( [oDlg], nCtrl, nKey, block [, lGlobal] )
Sets a "hot key" for a window/dialog or globally - for all the application. There is appropriate command, which is preprocessed into this function: SET KEY.
hwg_ColorC2N( cColor )
Converts color representation from string to numeric format.
hwg_ColorN2C( nColor )
Converts color representation from numeric to string format.
hwg_ColorN2RGB( nColor [, @nRed, @nGreen, @nBlue] )
Converts color representation from one numeric value to three, which corresponds to red, green and blue. You may get the result by passing parameters by reference or using the return value.
hwg_ColorRgb2N( nRed, nGreen, nBlue )
Converts three color components (red, green and blue) to a numeric value.
~~~~~~~~~~~~~~~~~~~~~~~~~~
Binary Container functions
~~~~~~~~~~~~~~~~~~~~~~~~~~


The usage of the Binary Container is demonstrated in sample program
"samples/bincnts.prg".



hwg_BmpFromRes( cBmp )
Creates a bitmap from the data stored in the resources or in the binary container (if it is previously opened with hwg_SetResContainer() function). In most cases you don't need to call this function directly, use HBitmap():AddResource(cBmp) instead.
hwg_SetResContainer( cName )
Opens a file of a binary container and sets is as a current for resources retrieving. Corresponding command: SET RESOURCES CONTAINER TO.

hwg_GetResContainerOpen()
Returns .T., if a binary container is open.


hwg_GetResContainer()
Returns the object of opened container, otherwise NIL.
(because the object variable is static).


hwg_ExtractResContItem2file(cfilename,cname)
Extracts an item with name "cname" of an opened container to file "cfilename"
(get file extension with function hwg_ExtractResContItemType() before)
Returns .T., if success, otherwise .F.
(for example if no match or container not open).


hwg_ExtractResContItemType(cname)
Extracts the type of item with name "cname" of an open container.
Returns the type (bmp,png,ico,jpg) as a string.
Empty string "", if container not open or no match


hwg_ResContItemPosition(cname)
Extracts the position number of item with name cname of an open container.
Returns the position name of item in the container (numeric),
0 , if no match or container not open.


hwg_Bitmap2tmpfile(objBitmap , cname , cfextn)
Creates a temporary file from a bitmap object
Avoids trouble with imcompatibility of image displays.
Almost needed for binary container.

Parameters:

Returns:

 The temporary file name,
 empty string, if error occured.
 Don't forget to delete the temporary file after usage.

 Example:

  LOCAL ctmpbmpf
  ctmpbmpf := hwg_Bitmap2tmpfile(obitmap , "sample" , "bmp")
  hwg_MsgInfo(ctmpbmpf,"Temporary image file") && display temporary filename for test
  IF .NOT. EMPTY(ctmpbmpf)
  ...
  ENDIF
  ERASE &ctmpbmpf


Reference:
 Read more about the usage of this functions in the documentation
 of the Binary Container Manager in the utils/bincnt directory and
 in the inline comments of sample program "samples/bincnts.prg".



~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
End of Binary Container functions
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~


hwg_SetCtrlName( oCtrl, cName )


hwg_MemoEdit(mpmemo , cTextTitME , cTextSave , cTextClose , cTTSave , cTTClose , oHCfont )

Standard dialog for editing memo fields.
Usage see sample program demodlgbox.prg.
(Simple file editor).
Can be also used for editing memo fields in a database by the usage of an UDF (user defined function).
Could substitute the internal memo edit dialog of the
HBROWSE class, if necessary by UDF usage.

Parameters (Default values in brackets):
mpmemo : The memo field to edit

For National Language Support (NLS),
for title, button's caption and tooltips (cTT..) :

cTextTitME : Title of Dialog ("Memo Edit")
cTextSave : ("Save")
cTextClose : ("Close")
cTTSave : ("Save modifications and close")
cTTClose : ("Close without saving modifications")

oHCfont : Font object for HCEDIT in dialog(<NONE>)

Returns the edited memo. If cancelled, the previous memo value
is returned.


hwg_RefreshAllGets( oDlg )
Refresh the state of all GET-elements in a window.
hwg_IsCtrlShift( lCtrl, lShift ) (Windows only)


hwg_GetSkip( oParent, hCtrl, nSkip, lClipper )


hwg_SetGetUpdated( o )


hwg_SetColorinFocus( lDef, tColor, bColor )


hwg_Chr( nCode )
hwg_Substr( cString, nPos, nLen )
hwg_Left( cString, nLen )
hwg_Len( cString )


hwg_Array_Len(ato_check)

Returns the number of elements of an array.
Fixes the following problem:
LEN(array) crashes with
"Argument error", if array initialized
with empty value: array := {}
In this case, this function
returns correctly 0.
Also returns 0, if array is NIL.
Example:
To create and fill an array the following
example sequence is most suitable:
 LOCAL anewarray
 anewarray := {}
 * --- let array empty for test
 * AADD(anewarray,"One")
 * AADD(anewarray,"Two")
Now get the length:
 ? LEN(anewarray)         && crashes here
 ? HWG_ARRAY_LEN(anewarray)    && 0


hwg__isUnicode()

Returns .T., if program is running with UTF-8 support.
This function works also on GTK cross development environment.
Windows operating system does not support Unicode.
Result may decide the setting of the local codepage for correct display.


hwg_GetPrinters()


hwg_Createfont( fontName, nWidth, nHeight, fnWeight, fdwCharSet, fdwItalic, fdwUnderline, fdwStrikeOut )


hwg_GetFontsList()

Windows 10: Always returns an empty list.
GTK: Do not use yet, crashes with core dump. Need to fix.


hwg_HdSerial( cDrive ) (Windows only)

Returns the drive serial number as hex value.
cDrive must be a path to the device, for
example "C:\".
cDrive may be empty for recent drive.
For compatibility purposes on GTK this function
exists and returns forever an empty string "".


hwg_HdGetSerial( cDrive ) (Windows only)

Returns the drive serial number as numeric value. cDrive must be a path to the device, for example "C:\". cDrive may be empty for recent drive. This is the same as Harbour function VolSerial() on contrib/hbct. In case of errors, the funtion return -1. For compatibility purposes on GTK this function exists and returns forever -1.


Hwg_GetIni( cSection, cEntry, cDefault, cFile ) (Windows only)

Reads a value from an ini file.
See additional instructions at description of Hwg_WriteIni().


Hwg_WriteIni( cSection, cEntry, cValue, cFile ) (Windows only)

Stores and modifies an ini file. The storage location of the file
depends on the the Windows version.
Example for Windows 10:
C:\Users\<user>\AppData\Local\VirtualStore\Windows\HwGui.ini
This is the directory, where the sample program
"samples\demoini.prg" creates the ini file.

For multi platform use:
Look into the Source code of Harbour:
The following files contains classes and functions for
handling Windows style ini files:
- src\rtl\hbini.prg
- tests\inifiles.prg : Class library from Matthew Hamilton (CLASS TIniFile).
For an extented version with additional functions look at project CLLOG:
https://sourceforge.net/projects/cllog/
File: src\libini.prg
The main section is in file "logw.prg".
Use this as sample for creating your own system
handling ini files. The program code contains
many inline comment with instructions for use
in english and german language.


hwg_TxtRect( cTxt, oWin, oFont )


hwg_ErrMsg( oError )


hwg_ShellNotifyIcon( lAdd, hWnd, hIcon, cTooltip ) (Windows only)


hwg_ShellModifyIcon( hWnd, hIcon, cTooltip ) (Windows only)


hwg_ShellExecute( cFile, cOperation, cParams, cDir, nFlag )


hwg_GetLocaleInfo()
Returns the recent language setting (National Language Support,
for setting the language of your application).
Windows: Returns the value of function call GetLocaleInfo(LOCAL_USER_DEFAULT,...).
This is forever ";". LINUX: Returns the value of setlocale(LC_CTYPE,NULL)
To get all possible values on your system, look to the output of the command "locale -a".
The type of return value is a string.


Hwg_SetDlgResult( handle, nValue ) (Windows only)


hwg_SetCapture( hWnd ) (Windows only)


hwg_ReleaseCapture() (Windows only)


hwg_CopyStringToClipboard( cString )


hwg_GetClipboardText( hWnd )


hwg_GetStockObject( nId ) (Windows only)


hwg_LoWord( n )
Retrieves the low-order word from the specified 32-bit value.
hwg_HiWord( n )
Retrieves the high-order word from the specified 32-bit value.
hwg_BitOr( n1, n2 )
hwg_BitOr_Int( n1, n2 )
hwg_BitAnd( n1, n2 )
hwg_BitAndInverse( n1, n2 )
hwg_SetBit( n, nBit )
hwg_CheckBit( n, nBit )
Bit functions as in Harbour ( hb_bitand(),... ).


hwg_SetBitByte(nbyte,npos,nvalue)
Sets a bit in one byte
nbyte : The input byte as numeric value, transform from C with Harbour function ASC(), 0 ... 255
npos : The position of byte to set, 1 ... 8
nvalue : Set to 0 or 1, all other bytes returns the input value

Returns the new byte of the modified byte as numeric
value, convert it with CHR() to C.


hwg_Sin( n )
hwg_Cos( n )
hwg_PI()
Three mathematical functions.


hwg_ClientToScreen( handle, x1, y1 ) (Windows only)


hwg_ScreenToClient( handle, x1, y1 ) (Windows only)


hwg_GetCursorPos() (Windows only)


hwg_SetCursorPos( x, y ) (Windows only)


hwg_WinExec( cCommand, nFlag ) (Windows only)


hwg_GetKeyboardState( nState )


hwg_Getkeystate( nKey ) (Windows only)


hwg_GetKeyNameText( nCode ) (Windows only)


hwg_Pts2Pix( nPoints [,hDC] ) (Windows only)


hwg_ShowCursor(lcursor , hwindow , ndefaultcsrtype)

Hides or recovers (displays) the mouse cursor.
No return value.

This feature is also helpful for computers with touchscreen.
The behavior on GTK and Windows differs.
First parameter: .F. hides the cursor, .T. recovers it.
Do not forget, that the mouse action is forever active, only you
cannot see the cursor.
Use compiler switch "#ifdef __GTK__" to activate the individual function call
on WinAPI or GTK for multi platform applications.
For details see inline comments in sample program
"demofunc.prg".

WinAPI:
Use this function only with first parameter, the second and third parameter are ignored.
If used the 2nd and 3rd parameter (as a dummy for multi platform),
be shure that they are not NIL,
because the program crashes with argument error.
The function has effect on all windows of the application
(main window and child windows),
also on internal HWGUI dialogs like hwg_msginfo().
so only one call of this function is needed for the whole application.
Parameter lcursor:
- .T. increases the cursor display counter by 1.
- .F. decrement it by 1.
return value:
Type = int, specifies the new display counter.
The cursor is displayed, if greater or equal 0.
Initial value is 0, if mouse is installed,
otherwise -1.

GTK:
The function has only effect on one window, the handle of the window
desired for hiding the cursor must be delivered in parameter 2.
The parameter 3 is needed for recovery.
Repeat function for every window.
Has no effect on special HWGUI dialogs like hwg_msginfo().
Return values:
0: cursor visible
-1: cursor hidden.
State of development: Only on LINUX the recovery crashes (range overflow).
As a substitute, the cursor is recovered with type GDK_ARROW, which
seems to be standard cursor.
This function works also on GTK cross development environment.


hwg_GetCursorType() (GTK only)

In usage together with hwg_ShowCursor().
Call this function in main section to save the old mouse cursor style
in a numeric variable for later recovery after hiding it.
For details see hwg_ShowCursor() and inline comments in sample program
"demofunc.prg".
Use compiler switch "#ifndef __GTK__" to hide the function call on WinAPI
for multi platform applications.
For recent bug in GTK on LINUX see description of hwg_ShowCursor().

Some standard curser styles are defined in:
include\gtk-2.0\gdk\gdkcursor.h
This function works also on GTK cross development environment.


hwg_SetApplocale(cLocale) (GTK only)

cLocale: The locale string.
Sets the locale for the HWGUI program.
For WinAPI available, but function body is empty
for compatibility purpose.
Before calling this function, the desired locale must
be requested with the REQUEST command.


hwg_BaseName ( pFullpath )

Extracts the filename from a path string.
Returns the extracted path.
Is equivalent to the UNIX command "basename".
A trailing / or \ is deleted.


hwg_Dirname ( pFullpath )

Extracts the filename from a path string.
Returns the extracted file name.
Is equivalent to the UNIX command "dirname".
A trailing \ or / is deleted.
At recent directory it returns "." .

With this rules a path can be combined like this sample:
newname = hwg_Dirname("C:\") + "\" + "hugo.txt"

Special case on Windows for example
(should appear seldom):
Fullpath ="C:hugo.txt"

Handle this case as following:
IF RAT(hwg_GetDirSep(),Fullpath) == 0 .AND. RAT(":",Fullpath) != 0
  newname = hwg_Dirname("Fullpath") + "hugo.txt"
ELSE
  newname = hwg_Dirname("Fullpath") + "\" + "hugo.txt"
ENDIF


hwg_CleanPathname ( pSwithdbl )

Reduce \\ to \ or // to / in pSwithdbl
(depends on operating system).
For handling of file and path names.
Returns the path value with reduced number of slashes or backslashes.
Avoids for example "C:\\".


hwg_GetWindowsDir() (Windows only)

In most cases, the value is "C:\Windows".
This function works also on GTK cross development environment.
Is available on other operating systems for compatibility,
then returns forever an empty string ("").


hwg_GetSystemDir() (Windows only)


hwg_GetTempDir()

Returns the path of the temporary directory.
Value depends on the version of the operating system.
This function works also on GTK cross development environment.
Windows: In most cases, the value is "C:\Users\<userid>\AppData\Local\Temp\".
LINUX/UNIX: In most cases, the value is "/tmp" or "/var/tmp".
First the function reads the environment variable "TMPDIR" and
returns this value. If the TMPDIR variable does not exist, it returns
as default value "/tmp".
This function works also on GTK cross development environment.


hwg_CreateTempfileName(cPrefix , cSuffix)

Generates a unique full path and file name string for a temporary file.
Format is:
<path to temporary directory>+<cPrefix>999999<cSuffix>

- The number is derived from return value of the SECONDS() function,
   so every hundreth second an new name is created.
   The returned number is of type integer.
   Range is from 0 to 8639900 (86399 * 100).
- Parameters cPrefix and cSuffix are optional.
- Default values: cPrefix = "e", cSuffix = ".tmp".
- <path to temporary directory> is returned from hwg_GetTempDir().
   Directory separator is suitable to used operating system.
- If you need more than one temporary file at one time,
   use different prefixes or suffixes.

Sample:
   cTmp := hwg_CreateTempfileName("pre",".ext")

Don't forget to delete the created file(s) after usage by
   FErase( cTmp )

All characters for cPrefix and cSuffix are allowed, if supported by
operating system for file and directory names (without directory separators).
For best multi platform compatibilty we recommend to use only
ASCII letters in lower case (a ... z).
This function works also on GTK cross development environment.


hwg_CompleteFullPath()

Don't matter about a path string returned by several functions,
if they are terminated with a trailing directory separator or not.
This function adds the trailing directory separator,
if it is not existing.
So you can concatenate a normal file name
to get full file name + path.
Example:
   cp := hwg_CompleteFullPath( hwg_GetWindowsDir() ) + "filename.bin"
hwg_GetWindowsDir() returns "C:\Windows", then
cp was completed to:    "C:\Windows\filename.bin".
Other example:
hwg_GetTempDir() returns:
   "C:\Users\alex\AppData\Local\Temp\"
so
   cp := hwg_CompleteFullPath( hwg_GetTempDir() ) + "filename.bin"
was completed to:
   "C:\Users\alex\AppData\Local\Temp\filename.bin".
On UNIX/LINUX the functions handle the separator "/"
in the same way as "\".
This function works also on GTK cross development environment.


hwg_ProcFileExt(pFiname,pFiext,lupper,ctestdirsep)

Process file name extension:
Add file extension, if not available
or replace an existing extension.
pFiname : The filename to be processed
pFiext : The new file extension
lupper : Windows only (parameter ignored on UNIX/LINUX):
         Set to .T. , if extension is set to upper case
         .F. : preserve case (default)
ctestdirsep : Only for test purposes:
Modifies the directory separator, default
is the return value of function hwg_GetDirSep(),
so it is assigned correct by the used operating system.

Sample call: hwg_ProcFileExt("TEST.TXT","PRG")
returns the value "TEST.PRG"
pFiname may contain a full path.
DOS, Windows and UNIX/LINUX filenames
are supported.
Sample usage the sample program "samples\demofunc.prg".


hwg_Postquitmessage( nExitCode ) (Windows only)


hwg_GetDesktopWidth()
Returns a width of a desktop in pixels.


hwg_GetDesktopHeight()
Returns a height of a desktop in pixels.


Additional information for functions hwg_GetDesktopWidth() and hwg_GetDesktopWidth():
As reported with bug ticket #112, on newer GCC and Windows versions the
main window is not opened in full size.

A quick fix is reported like this code snippet:
INIT WINDOW oFormMain MAIN AT -7,0 SIZE hwg_Getdesktopwidth()+14,hwg_Getdesktopheight()+14

Please check by compiling the test program
test\ticket112.prg.
If the main window appears nearly in full size, than this is the
intermediate solution.


hwg_GetWorkArea() (Windows only)
Returns an array with coordinates of a desktop without taskbar


hwg_GetNextDlgTabItem ( parentHandle, ::handle, lNext ) (Windows only)
Returns a handle of a next or previous control in a window.
hwg_Sleep( n )
Delays a process.
n: Sleep time in seconds
On WInAPI, the function Sleep() is used.
On other operating systems
the function usleep()
from standard C library is used
(see also hwg_Sleep_C() ).
An internal multiplication with 1000
passes the value to usleep() in seconds.


hwg_Sleep_C(n)
Delays a process.
n: Sleep time in milli seconds
(see also function hwg_Sleep().
Uses the function usleep()
from standard C library.
(it seems to be for more precise processing)
Additional information:
The n argument must be less than 1 000 000.
If the value of useconds is 0,
then the call has no effect.
The function usleep() is depricated and should be
substituded by the modern timer functions.


hwg_SetScrollInfo( handle, nType, nRedraw, nHScrollPos , nPage, nHscrollMax ) (Windows only)


hwg_GetScrollRange( handle, nType, @minPos, @maxPos ) (Windows only)


hwg_SetScrollRange( handle, nType, minPos, maxPos ) (Windows only)


hwg_GetScrollPos( handle, nType ) (Windows only)


hwg_SetScrollPos( handle, nType, nPos ) (Windows only)


hwg_ShowScrollBar( handle, nType, lShow ) (Windows only)


hwg_ScrollWindow( handle, n1, n2 ) (Windows only)


hwg_isCapslockActive() (Windows only)


hwg_isNumlockActive() (Windows only)


hwg_isScrolllockActive() (Windows only)


hwg_CreateDirectory( cDirName ) (Windows only)


hwg_RemoveDirectory( cDirName ) (Windows only)


hwg_SetCurrentDirectory( cDirName ) (Windows only)


hwg_DeleteFile( cFileName ) (Windows only)


hwg_GetFileAttributes( cFileName ) (Windows only)


hwg_SetFileAttributes( cFileName, nAttr ) (Windows only)


hwg_GetComputerName() (Windows only)


hwg_GetUserName( [@nLength] ) (Windows only)


hwg_PtrToUlong( ptr )
Converts a variable of Pointer type to a long integer. This is necessary in some cases for handling parameters of system messages.
hwg_Isptreq( handle1, handle2 )
Compares two pointers, returns .T., if they are equal.


hwg_OutputDebugString( cText ) (Windows only)


hwg_Getsystemmetrics( nCode ) (Windows only)


hwg_GetBackBrush( handle ) (Windows only)


hwg_LastKey() (Windows only)


hwg_isWindows()
Returns .T., if Windows is the recent operation system.
This function works also on GTK cross development environment.
Windows is detected by the Harbour internal compiler flag "__PLATFORM__WINDOWS".
This function helps to avoid the use of compiler flags in your application.


hwg_isWin7()
Returns .T., if Windows version is 7.
This function works also on GTK cross development environment.
Is available on other operating systems for compatibility,
then returns forever .F. .


hwg_isWin10()
Returns .T., if Windows version is 10.
This function works also on GTK cross development environment.
Is available on other operating systems for compatibility,
then returns forever .F. .


hwg_GetWinMajorVers()
Returns the major version of Windows.
This function works also on GTK cross development environment.
Is available on other operating systems for compatibility,
then returns forever -1.


hwg_GetWinMinorVers()
Returns the minor version of Windows.
This function works also on GTK cross development environment.
Is available on other operating systems for compatibility,
then returns forever -1.


hwg_DefUserLang()
Returns the Windows LCID (Windows Language Code Identifier) for language
setting of the current user in a string.
Sample: de-DE "1031" ==> 0x407
This function works also on GTK cross development environment.
Is available on other operating systems for compatibility,
then returns forever "-1".


hwg_GetLocaleInfoN()
Returns the Windows LCID (Windows Language Code Identifier), type = int.
The value is not so suitable (using another function of the WinAPI).
For better result use the function hwg_GetLocaleInfo() to get the recent language setting (for national language support, setting the language of your application).
Sample: Return 2 for german.
This function works also on GTK cross development environment.
Is available on other operating systems for compatibility,
then returns forever -1.


hwg_ChDir(cdirectory)

Change directory:
Harbour function ft_chdir() only available Harbour 3.4 and up,
so this function is instead OK for all platforms
and Harbour 3.2 and up.

To supply a Harbour Terminal/Console application with this function,
add following code into one of your *.prg file (inline C implementation):

#pragma BEGINDUMP


#if defined(__linux__) || defined(__unix__)
#include <:unistd.h>
#else
#ifdef __APPLE__
#include <unistd.h>
#else
#include <io.h>
#endif
#endif

#include "hbapi.h"
#include "hbapifs.h"

HB_FUNC( HWG_CHDIR )
{
hb_retl( HB_ISCHAR( 1 ) && chdir( hb_parc( 1 ) ) );
}

#pragma ENDDUMP

This is checked on LINUX and MacOS with GCC,
Windows with MinGW and BCC.
Ignore warning with BCC:
Call to function 'chdir' with no prototype in function HB_FUN_HWG_CHDIR
Not checked on other Compilers (Pelles C, ...)
We will add the test results as soon as possible)
==> find this sequence in sample program "demofunc.prg"
and test program "test/test_origin_cons".


hwg_ProcessRun( cCommand ) (Windows only)


hwg_RunConsoleApp( cCommand [, cOutFile] [,lshow] )
Executes a console program in sync mode, waiting for result.


lshow :
(Windows only, this parameter ignored on other operating systems)
Set to .T., to set STARTUPINFO.wShowWindow to SW_SHOW.
Default is .F., set to SW_HIDE.
SW_SHOW is needed for programs, starting in console mode,
but opens child window(s). Otherwise they are running
in background. For example:
Running ZBar (QR decoder reading QR codes from camera)
the sub window does not appear if SW_HIDE,
so cannot use the camera for scanning QR code.
See sample program and information.

Exit codes WinAPI:
1: Cannot create output pipe
2: Failure of: Ensure the read handle to the pipe for STDOUT is not inherited
3: Cannot create process
otherwise:
Return code of GetExitCodeProcess() function call.
Attention !
Do not call internal commands of the command shell "cmd"
(for example cmd -c "dir") direct, otherwise the program freezes, so it must be terminated by.
the Task Manager.

Exit Codes UNIX/LINUX/MacOS:
0: Success
-1: no file to run


hwg_RunConsApp( cCommand ) (GTK LINUX and MacOS only)
Executes a console or GUI program in async mode.

For details read instructions in sample program tststconsapp.prg,
it demonstrates the usage of
- hwg_RunApp() (async mode)
- hwg_RunConsoleApp() (sync mode)
- hwg_RunConsApp() (async mode, GTK)
- hwg_ShellExecute() (under construction, will be added later)
Be pleasant, to try, what is the best for your HWGUI application.


hwg_RunApp( cCommand [, nFlag] [, lAsync] )
Runs an external program (async mode).
On LINUX/GTK and MacOS/GTK the are some restrictions,
for details read instructions in sample program tststconsapp.prg.


Parameter 1: command line (mandatory):

      We suggest to set up a command line including the full path.
      If the called application is in the current directory,
      use the functions hwg_GetDirSep() and Curdir()
      for combinding the recent directory + program file call.

      Calling a program by using a full path, we strictly recommend to use the
      ft_origin() functionality, described in this chapter at the beginnung.
      Change to directory, were the EXE file is located, and than open files and databases in this directory.
      For details read the comment line instructions of sample programs "demofunc.prg" and "tststconsapp.prg".


Curdir() (a Harbour function):

      returns the current directory.
      If you combine full path items, don't
      forget to get the OS dependant
      directory seprator character with
      function hwg_GetDirSep()


Windows:
Parameter 2, nFlag:
      Is uCmdShow : For possible values see description of WinAPI function ShowWindow()
      Default is SW_SHOW (Activates the window and displays it in its current size and position).

Parameter 3, lAsync:
 .F. or NIL: Function WinExec(LPCSTR lpCmdLine, UINT uCmdShow) of WinAPI used,
      Starts program asynchronious.
      Return value is of type N, if function succeeds, the value is greater than 31.
 .T. : Function CreateProcess(..) of WinAPI used,
      returns NIL.

LINUX (GTK2 and GTK3): asynchronious start:
      uses function g_spawn_command_line_async(),
      Parameters 2 and 3 are ignored.

      Return value is of type N, if function succeeds, the value is greater than 0


hwg_RdLn(nhandle,lrembltab)
  Reads a single text line from a textfile,
  very comfortable usage, the line endings
  are autodetected, so independant of used
  operation system.
  ( It is not important, if line ending
  is CRLF or LF or CR.)
    CRLF = 0x0D + 0x0A = CHR(13) + CHR(10) (Windows/DOS)
    CR   = 0x0D = CHR(13) (MacOS)
    LF   = 0x0A = CHR(10) (UNIX/LINUX)
  (function is an equivalent to Pascal's Rdln() function )

  nhandle : The file handle

  rembltab: If set .T. , the blanks and tab characters are removed
   at end of line
   (default is .F.)

  returns:
  an array with 4 elements:

  1. The line read
    EOF or error : "" (empty string)
  2: EOF flag, EOF = .T.
    For usage in a DO WHILE read loop
  3: The number of bytes read at least
    EOF or error : < 1
  4: The type of line ending detected
    ( of type C with one character)
    (only for debugging prurposes)

      W = Windows/DOS
      L = UNIX/LINUX
      M = MacOS
      U = unknown (possible try read from binary file,
       error or EOF reached without line ending)

  All line endings and the EOF marker CHR(26) are removed,
  so the output string contains only the pure text from input line
  Blank lines at end after the last filled line are ignored
  (handled as EOF reached)

  Advice:
  For usage in Harbour console application
  copy the code of 4 functions
  hwg_RdLn(), hwg_RmCr(), hwg_RmBlTabs() and hwg_max()
  into your application.
  Find them in HWGUI source code file:
  source\cross\hmisccross.prg

  Here a code sample snippet to read a text file:
  * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  LOCAL lEOF, arrrea
  lEOF := .F.
  * Open the input text file
  handle := FOPEN("textfile_Win.txt",0)
  * read the input file
  DO WHILE .NOT. lEOF
    arrrea := hwg_RdLn(handle)
    * Detect EOF
    IF arrrea[2]
     lEOF := .T.
    ELSE
     * Process data read delivered in arrrea[1]
     * ...
    ENDIF
  ENDDO
  FCLOSE(handle)
  * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~


hwg_RmCr(xLine)
Remove MacOS line ending (CR)
Only for internal use of hwg_RdLn()


hwg_RmBlTabs(xLine)
Remove not needed blanks or tabs at end of line
Only for internal use of hwg_RdLn()


hwg_Max(a,b)
Returns the maximum value of a or b.
a and b must be numeric values or dates


hwg_Min(a,b)
Returns the minimum value of a or b.
a and b must be numeric values or dates


hwg_FBINREAD(cfilename,nbufsize)( n )
Reads a binary file "cfilename"
and returns its contents to a type C variable.
It is the equivalent to Harbour function
MEMOREAD(), but it can get some trouble with
not allowed characters, so this function is
a safe alternative.
The operation of this function is silent
to avoid crash.
In case of an error, an empty string "" is
returned.
Check bytes read with LEN().


hwg_onAnchor( oWnd, wold, hold, wnew, hnew )


hwg_ChangeCharInString(cinp,nposi,cval)
Exanges one byte in a passed string.
This function is a little bit like the BASIC function INSTR$.
Returns the string with the modified byte.
cinp : The input string
nposi : The position where the byte/character must be changed
cval : The character to be set. It must have the length of 1 byte.
Use the CHR(n) function to set the value.

In case of invalid parameters the function returns the unmodified input string or an empty string "".


hwg_cHex2Bin( chexstr )
Converts a hex string to binary.
Returns empty string, if error
or number of hex characters is odd.
Valid characters for chexstr:
0 ... 9 , A ... F , a ... f
Other characters are ignored.


hwg_HEX_DUMP (cinfield, npmode, cpVarName)
Hex dump from a C field (binary)
into C field (Character type).
In general, every byte value (2 hex digits)
is separated by a blank.

npmode:
Selects the output format.
0 :   All hex values in one line,
      without quotes and trailing EOL.
1 :   16 bytes per line,
      with display of printable
      characters,
      not inserted in quotes,
      but columns with printable
      characters are separated with
      ">> " in every line.
2 :   As variable definition
      for copy and paste into prg source
      code file, 16 bytes per line,
      concatenated by "+ ;"
      (Default)
3 :   16 bytes per line, only hex output,
      no quotes or other characters.
4 :   Like 0, but without blank
      between the hex values.
      Used by Binary Large Objects (BLOBs)
      stored in memo fields of a DBF.
      See program utils\bincnt\bindbf.prg
5 :   As C notation array
      16 bytes per line, 0x..
      written in {}
      Add before generated block (for example):
      const unsigned char sample[] =
      and a ";" at end of block.

cpVarName:
Only used, if npmode = 2.
Preset for variable name,
Default is "cVar".
For other modes, this parameter is ignored.

Sample writing hex dump to text file:
MEMOWRIT("hexdump.txt",hwg_HEX_DUMP(varbuf),1)


hwg_NUMB2HEX ( nascchar )
Converts 0 ... 255 TO HEX 00 ... FF
(2 Bytes String)


int hwg_hexbin(int cha)
converts single hex char to int,
returns -1 , if not in range
returns 0 - 15 (dec) , only a half byte
This function is the equivalent to
hwg_NUMB2HEX(), but you can use it
in the C implementation of your
application
Don't forget to cast int to unsigned char.
For usage sample look into source code file
utils\devtools\memdump.prg


FUNCTION hwg_COUNT_CHAR(stri,such)
Counts the appearance of string "such"
in "stri".
This function has a subset
of parameters of the
Clipper tools function AFTERATNUM()
for better handling.


hwg_KEYESCCLDLG (odlg)
Simple helper function, closes dialog at ESC key
For the cases with usage of INIT DIALOG ... NOEXIT, which blocks the close of dialog by pressing the ESC key.

Sample:
FUNCTION xyz
LOCAL oDlg,lCancel
lCancel := .T.
INIT DIALOG oDlg ...
SET KEY 0,VK_ESCAPE TO hwg_KEYESCCLDLG(oDlg)
....
@ 122,402 BUTTON "Action" SIZE 100,32 ;
ON CLICK {|| lCancel := .F. , oDlg:Close() }
....
@ 322,402 BUTTON "Close" SIZE 100,32 ;
ON CLICK {|| oDlg:Close() }
....
ACTIVATE DIALOG oDlg
SET KEY 0,VK_ESCAPE TO
IF .NOT. lCancel
   * Not ESC pressed or not cancelled
   * ==> ... and action
   ....
ENDIF
RETURN NIL


hwg_hex2binchar(cchar)
Converts a hex string to bin string with "0" or "1".
Allowed characters 0 .. 9, A .. F , a .. f
Every half byte is separated by a space,
every byte by an extra space.
Helpful for debugging.
cchar : The hex string, for example
returned by hwg_HEX_DUMP() only with modes 3,4


hwg_ShowHelp(cHelptxt,cTitle,cClose,opFont,blmodus)
Shows help window
(Useful for static help texts)

cHelptxt: Character variable with multiline help text,
complete every line with CHR(13) + CHR(10).
cTitle : The title of the help window
cClose : Set text for "Close" button in your language, default is "Close".
opFont : Additional font setting
blmodus : .T.: not modal (default is .F.)
Special instruction for non modal mode:
Trouble with NOMODAL on LINUX:
The window with help text freezes, it closes
only, if the calling dialog is closed.
For example:
Pressing the "Close" button or the cross in the header bar has no effect.
So set blmodus to .F. on LINUX,
use compiler switch "#ifdef __PLATFORM__WINDOWS"
to set the paramater.

Sample code:
LOCAL lnmodal
...
#ifdef __PLATFORM__WINDOWS
lnmodal := .T.
#else
lnmodal := .F.
#endif
...
hwg_ShowHelp("Helptext","Title","Close",,lnmodal)


Common sample: (display not modal)
LOCAL lf := CHR(13) + CHR(10)
cHelptxt := "Line 1 of help" + lf + ;
"Line 2 of help" + lf + ;
"Line 3 of help"
hwg_ShowHelp(cHelptxt,"Title of help",,,.T.)

Additional instructions see sample program "helpstatic.prg".


hwg_GET_Helper(cp_get,nlen)
Fixes a special problem
of GET command.
(only for C type fields)
nlen : Set the lenght of the C type field,
otherwise the extension of the edited field
is not possible.

GTK:
The Cursor is located at end of
data, if field is empty (means filled with blanks).
It can be entered characters exceeding
the length of a database field, but they
are lost, if stored to database.
The problem is, that in case of blanks,
the end of field in not visible.
but only, if field is filled with
characters.
Here the strategy with the use of
this function:

1.) Shorten filled fields with RTRIM() or PADR().
2.) Field filled with blanks:
    Test with EMPTY(), then return empty string ""
3.) Use this function before INIT DIALOG on all
    C fields handled with GET in this dialog.
4.) If necessary, remove leading and trailing blanks
    with the function ALLTRIM() after end of dialog.

On WinAPI, the function returns the
original value of the input parameter,
so this function can be used with
multi platform applications.

For type of D or N: forever use the PICTURE clause.

For usage see sample program "samples/demomenuxml.prg".


hwg_StrDebNIL(xParchk)

For debugging purposes:
Returns string "NIL" or "not NIL",
if parameter xParchk is NIL or not.
For usage in combination with hwg_WriteLog() to
write value(s) into a log file.


hwg_StrDebLog(ltoCheck)

For debugging purposes:
Returns string ".T." or ".F.",
if logical parameter ltoCheck is true or false.
For usage in combination with hwg_WriteLog() to
write value(s) into a log file.


hwg_deb_is_object(oObj)

For debugging purposes:
Displays with a messagebox if oObj is an object or not.
("Is object" or "Is not an object")
The condition for "IF" command to check for a valid object is:
IF Valtype(oObj) == "O"
...


hwg_Bin2D(cbin,nlen,ndec)

Converts double (8 bytes) to
Numeric Value.
Parameters:
cbin : Hex value of binary
(double 8 bytes => 16 hex characters)
Size 16 Bytes with or without blanks in one line.
nlen : number of digits
ndec : number of digits after decimal point

Sample call:
hwg_Bin2D(hwg_HEX_DUMP(Buffer,0),10,2)
Buffer is the 8 bytes of double var memory.

For usage sample look into source code file
utils\devtools\memdump.prg


hwg_Bin2DC(cbin,nlen,ndec)

Converts double (8 bytes) to
Numeric Value.
Only for internal usage.
This function is called by
hwg_Bin2D().


hwg_addextens(cfilename,cext,lcs)

Add file extension "cext",
if not passed with "cfilename".
If cext is NIL, original name is returned.
Pass "cext" without previous ".".
It is recommended, to pass cext in lower case.
lcs : Set to .T., if case sensitive.
This is recommended for LINUX/UNIX.
On Windows set to .F. (Default).
For example:
 #ifdef __PLATFORM__WINDOWS
  lblname := hwlabel_addextens(lblname,"lbl")
 #else
  lblname := hwlabel_addextens(lblname,"lbl",.T.)
 #endif

This function is very useful, if you want to query a new file name for storing.
For example for *.prg:
#ifdef __GTK__
fname := hwg_SelectFileEx(,,{{ "XBase source code( *.prg )","*.prg" },{ "All files" ,"*"}} )
#else
fname := hwg_SaveFile( "Enter name of new file","XBase source code( *.prg )","*.prg",,"Save File" )
#endif
After query, add the extension "prg" corresponding the sample above.


hwg_leading0(ce)

Replace all leading blanks with
"0". ce : string
Returns : String


hwg_EuroUTF8()

Returns the Euro currency sign (€) in UTF-8 code.
0xE2 + 0x82 + 0xAC = CHR(226) + CHR(130) + CHR(172)
On Windows 10 the Euro sign is CHR(128) = 0x80


hwg_Has_Win_Euro_Support()

This functions returns .T., if the used Harbour Version
supports the Euro currency sign (€) on Windows.
In this case, the following code page must be requested:
 REQUEST HB_CODEPAGE_DE858
If for example your datebase uses a Euro currency sign, you
can set this codepage at opening time of a database with
the USE command.
The UTF-8 codepage supports forever the Euro currency sign.

Use the compiler switch to REQUEST the
codepage, if available in used Harbour version
like this sample code snippet:
#if ( HB_VER_REVID - 0 ) >= 2002101634
* 858 : same as 850 with Euro Currency sign
 REQUEST HB_CODEPAGE_DE858
#endif

But it is sometimes possible,
to handle the Euro currency sign
without support of Harbour.
For details read instructions in
comment lines of sample program
"samples\demostrrev.prg".


hwg_GUIType()

Returns the linked in GUI type as string,
return values are:
"WinAPI"
"GTK2"
"GTK3"


hwg_ValType(xxxx)

Returns the type of a variable or expression:
"A", "L", "N", "C", "D", "O", "P", "U"
("P" = pointer, "U" = NIL)


hwg_xVal2C(xxx)

Converts the value of xxx to string, dependant of type.
This function may be helpful for debugging.


hwg_xvalMsg(xxx,cttype,cttval,cttitle)

Starts a messagebox to display a value of xxx.
The displayed values are simular to function "hwg_xvalLog()"
This function may be helpful for debugging.
The header texts written to message:
cttype : default is "Type : "
cttval : default is "Value : "
cttitle: default is "Debug"

Additional info for debugging:
On GTK/Linux you can use the function QOUT()
to display values of variables in the terminal,
where the program is started.
On Windows, these outputs are not visible.
So these functions for debugging are helpful on Windows.


hwg_xvalLog(xxx,cttype,cttval,cttitle,cfilename)

Writes a value of xxx into a log file.
This function may be helpful for debugging.
The default file name is "a.log".
If you don't know the type of a variable passed to a function
(for example to STR() ) and you want to investigate the reason for a crash like this sample:

  Error BASE/1099 Argument error: STR
  Called from ->STR(0)
  Called from source\winapi/hprinter.prg->HPRINTER:SAY(416)
  ...
then the argument passed to STR() is not of type N.

Expected values in logfile:
  Type : U Value : NIL
  Type : A Value : <ARRAY>
  Type : L Value : .T.
  Type : N Value : 12345
  Type : C Value : Test
  Type : D Value : 20220627
  Type : O Value : <OBJECT>
(This is the output written to logfile by test program "test/xval.prg")

Parameters cttype,cttval and cttitle same as hwg_xvalMsg(),
but written into logfile.


hwg_xvalLog2(xxx,cttype,cttval,cttitle,cfilename)

Same as hwg_xvalLog(), but
advanced debug logging also for arrays.
Recursive call, if element is a sub array

Example:
atesten := { 1, .T. , {"SubA", "SubB", 1 , .F., {"2"} , {} } , "Top array" }

hwg_xvalLog2(atesten)
Sample output for this function call:

Sub array, depth := 1
Type : N Value : 1
Type : L Value : .T.
Sub array, depth := 2
Type : C Value : SubA
Type : C Value : SubB
Type : N Value : 1
Type : L Value : .F.
Sub array, depth := 3
Type : C Value : 2
Sub array, depth := 2
Sub array, depth := 3
Sub array, depth := 3 Array is empty !
Sub array, depth := 2
Sub array, depth := 1
Type : C Value : Top array
Sub array, depth := 0


Sample call for a single value:
hwg_xvalLog2(.T.)

Type : L Value : .T.


hwg_Toggle_HalfByte( cchar )


hwg_Toggle_HalfByte_C(n)
HB_FUNC C function.


hwg_nothing(xpara)

The compilation of this expression (for example)
IIF(nbChecked==0, oStatus:SetText(""),.t.)
throws the following warning:
Warning W0027 Meaningless use of expression 'Logical'
and the program freezes.
So modify to:
IIF(nbChecked==0,oStatus:SetText(""),hwg_nothing(.t.) )


hwg_Alert (Windows only)


hwg_Alert_DisableCloseButton() (Windows only)

Internal: Needed by HAlert class


hwg_Alert_GetWindow() (Windows only)

Internal: Needed by HAlert class


hwg_redirOn


hwg_redirOff


hwg_Trace


edi_utf8_Upper( cText )


edi_utf8_Lower( cText )


hwg_delEOFMarker(CBinrec)

Removes the EOF marker from a type C string.
EOF marker 0x1a = CHR(26).
Purpose:
After writing a binary or text image into a file with MEMOWRIT(),
an EOF marker is added automatically.
Reading this file with MEMOREAD() or hwg_FBINREAD(),
the EOF marker is also read, this can cause some trouble with processing after it.


hwg_is_object(oObj)
Returns .T., if oObj is a valid object


hwg_IsRaspberry()

This functions returns .T.,
if program is running on Raspberry Pi.
The Raspberry Pi bases on LINUX, but the
Processer type is ARM.


hwg_MEMLLEMPTY(memo)

Adds an empty line at end of memo field.
Do this for full display of the last
line in an HCEDIT window
(if scrolled down).
Call before starting the dialog
running HCEDIT !
(See function hwg_MemoEdit )
Only for internal usage.
Advice:
The STYLE term in INIT DIALOG for HCEDIT
has no effect for show a vertical scoll bar.
Scroll with up/down keys through the memo text)


hwg_UNIX2DOS(cText)

Convert LINUX/UNIX line endings to DOS/Windows.
This is mandatory for memo fields !
(for example by using FUNCTION hwg_ShowHelp() )
If text has LINUX/UNIX line endings,
convert it forever to Windows (also on LINUX).
This function is the equvalent to UNIX command
unix2dos.
Sample call see
samples/demo.ch,
FUNCTION demo_ShowCode()


5.8.1 Unit conversions.


Temperature conversions

Table: Temperatures equation list

Celsius Kelvin FahrenheitRankineRéaumurNOTE
C K F RA R < Abbreviation in function name
-273.15 0 -459.67 0 -218.52 Absolute zero point (0° Kelvin)
-17.78 255.37 0 459.67 -14.22 0° Fahrenheit
-10 263.15 14 473.67 -0 0° Réaumur
0 273.15 32 491.67 0 Water freeze point
20 293.15 59 527.67 16 Comfortable room temperature (20° Celsius)
37 310.15 98.6 558.67 29.6 Human body temperature
37.78 310.93 100 559.67 30.22 100° Fahrenheit
100 373.15 212 671.76 80 Water boiling
125 398.15 257 716.67 100 100° Réaumur

Building rule for function names
for temperature conversion functions:
hwg_TEMP_<k1>2<k2>
k1,k2: Abbreviation see table above

Constants in formulas:
9/5 = 1.8
9/4 = 2.25
10/8 = 1.25

C=Celsius K=Kelvin F=Fahrenheit RA=Rankine R=Réaumur

hwg_TEMP_C2F( T )
hwg_TEMP_C2K( T )
hwg_TEMP_C2RA( T )
hwg_TEMP_C2R( T )
hwg_TEMP_K2C( T )
hwg_TEMP_K2F( T )
hwg_TEMP_K2RA( T )
hwg_TEMP_K2R( T )
hwg_TEMP_F2C( T )
hwg_TEMP_F2K( T )
hwg_TEMP_F2RA( T )
hwg_TEMP_F2R( T )
hwg_TEMP_RA2C( T )
hwg_TEMP_RA2F( T )
hwg_TEMP_RA2K( T )
hwg_TEMP_RA2R( T )
hwg_TEMP_R2C( T )
hwg_TEMP_R2F( T )
hwg_TEMP_R2K( T )
hwg_TEMP_R2RA( T )


Other unit conversions

A collection of important unit conversion functions for real life.
(both directions)

=== in / cm ===
hwg_INCH2CM( I )
hwg_CM2INCH( cm )

=== feet / m ===
hwg_FT2METER( ft )
hwg_METER2FT( m )

=== mile / km ===
hwg_MILES2KM( mi )
hwg_KM2MILES( km )

=== sqin / sq cm ===
hwg_SQIN2SQCM( sqin )
hwg_SQCM2SQIN( sqcm )

=== sqft / sq m ===
hwg_SQFT2SQM( sqft )
hwg_SQM2SQFT( sqm )

=== usoz / c.c. (Cubic cm) ===
hwg_USOZ2CC( usoz )
hwg_CC2USOZ( cc )

=== usgal / litre ===
hwg_USGAL2L( usgal )
hwg_L2USGAL( l )

=== lb / kg ===
hwg_LB2KG( lb )
hwg_KG2LB( kg )

=== oz / g ===
hwg_OZ2GR( oz )
hwg_GR2OZ( gr )

=== Nautical mile / km ===
hwg_NML2KM(nml)
hwg_KM2NML(km)




5.8.2 Date and time functions.


hwg_getCentury()
Returns the value of the recent century setting.


hwg_GetDecimals()
Returns the value of recent setting
of SET DECIMALS TO ...
So get the recent setting,
modify the setting for your
processing and restore is previous
value at end.
The default value of 2 is not enough in most cases.
Example:
LOCAL nldezimale
nldezimale := hwg_GetDecimals()
SET DECIMALS TO 12 && ... to your own needs
&& your processing ...
&& Restore previous Setting
SET DECIMALS TO (nldezimale)
(The & macro operator fires an syntax error,
so set the value to set in brackets as shown)


hwg_GetUTCTimeDate()
Returns a string with date and time in UTC.
This function is platform independant.
Output format is: W,YYYYMMDD-HH:MM:SS
W: Weekday: 0 = Sunday, 1 = Monday ... 6 = Saturday
Use the SUBSTR() function of Harbour to extract the desired
information.
The output format is independent by settings of:
- SET DATE ...
- SET CENTURY ...


hwg_GetDateANSI()
Returns a string with date in ANSI format.
This function is platform independant.
Output format is: YYYYMMDD, based on local time.
The output format is independent by settings of:
- SET DATE ...
- SET CENTURY ...
If ANSI date is part of a file name, the files are listed
in correct order sorted by date.


hwg_GetUTCDateANSI()
Returns a string with date in ANSI format.
This function is platform independant.
Output format is: YYYYMMDD, based on UTC.
The output format is independent by settings of:
- SET DATE ...
- SET CENTURY ...
If ANSI date is part of a file name, the files are listed
in correct order sorted by date.


hwg_GetUTCTime()
Returns a string with UTC time.
This function is platform independant.
Output format is: HH:MM:SS (same as TIME() ).


hwg_IsLeapYear ( nyear )
nyear : a year to check for leap year.
returns: .T. , if nyear is a leap year,
so that the month February has 29 instead of 28 days.

The function concerns to the leap year rules of the Gregorian calendar,
valid for all years above 1582. Before this year, the "Julian calendar"
was used, it had an error about 10 days for the difference against the
solar year. With the invention of the Gregorian calendar, created by Pope Gregory XIII,
this error was fixed. So leap years are 1600 and 2000,
non leap years are 1700, 1800, 1900 and 2100.
For the Julian calendar the leap year rule is very simple:
 IF (nyear % 4) == 0 ) ...
If you have a date variable, use the Harbour function YEAR(d)
to extract the year as a numerical value from a date.


hwg_STOD(cANSIDate)
Extra implementation of STOD(),
it is a Clipper tools function.
For compatibilty purposes.
Parameter 1: Date String
in ANSI-Format YYYYMMDD.
Result value is independant from
SET DATE and SET CENTURY settings.
This is the opposite function to DTOS().
Sample Call:
ddate := hwg_STOD("20201108")


hwg_checkANSIDate(cANSIDate)
Check, if an ANSI Date is valid.
cANSIDate: ANSI date as string
of Format YYYYMMDD.
Returns .T., if the date is valid.


hwg_JulianDay2Date(z)
Converts julian date of mem files into
String , Format YYYYMMDD (ANSI)
z: double (of type N)
Returns string
Valid for dates from 1901 to 2099
The julian is stored in Clipper
and Harbour MEM files as
double value.
Convert a real double value of 8 bytes with
hwg_Bin2D() into type N.

For usage sample look into source code file
utils\devtools\memdump.prg
Additional information:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In Clipper and Harbour there is no function available,
to convert the double value of type N (or D) to
memvar type N.

This the solution of this topic:

The double value is converted to a hex string in one line without blanks:
1---+----1----+-
50455254FB210940 = Pi (for example),
so size = 16 Bytes

The function hwg_BIN2D() converts the hexstring
into double and then into a memvar of type N
For type N : it could be displayed with ? ... or processed afterwards.
For type D : double value represents the julian day
and is converted to a date string by
function hwg_JulianDay2Date(), returned format is YYYYMMDD.
Finally, the function STOD() converts
the date string into D value.
If the function STOD() is not available,
then hwg_STOD() is a substitue.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~


hwg_Date2JulianDay(dDate,nhour,nminutes,nseconds)
Converts date (type D) to julian date
(returned as type N).
This is the opposite function to
hwg_JulianDay2Date().
The paramaters nhour,nminutes,nseconds
are optional (default values are 0).


hwg_FileModTimeU()
Returns the file modification time in UTC as string.
Format: YYYYMMDD-HH:MM:SS
This function works also on open file.
It is a good substutite of Harbour function LUPDATE(),
which has bugs.
For example:
USE logbuch
* Modify a record:
REPLACE FIELD WITH "Value"
hwg_FILEMODTIMEU("logbuch.dbf")
* ==> now the date and time of modification is returned.
In case of errors (for example name of a not existing file)
the value 19700101-00:00:00 is returned.


hwg_FileModTime()
Returns the file modification time (local) as string.
Format: YYYYMMDD-HH:MM:SS
This function works also on open file.
It is the equivalent to HWG_FILEMODTIMEU()


hwg_Get_Time_Shift()
Returns the time shift from UTC as a numeric
value in hours.
So add this shift value to UTC for
getting local time.
This function regards daylight saving
time.


5.8.3 Raw bitmap support and QR code.

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Functions for raw bitmap support
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Helpful for Windows, because PNG support
by the operating system only for LINUX.

For multi platform applications,
it is recommended to handle all images
as bitmaps.
These functions are a subset of full bitmap
specifications to integrate the QR encoding
function for all platforms into HWGUI.

These functions are implemented in source code files
drawwidg.prg, hmisccross.prg and draw.c .
Some more functions for bitmap support
(for example painting and stretching of bitmap images)
are implemented in source code file "cxshade.c".

All functions start with prefix "hwg_BMP".

Some bitmap parameters are set fixed by default:
  compression 0 (No compression)
  planes 1 (Number of color planes)

The handled version of bitmap is W3.x, but is OK for recent Windows versions.

Functions names ending with "C" are for usage in C modules,
otherwise they are HWGUI functions.

The maximum size of a bitmap is 128 KByte.
If you need to increase this value, open
source code file "draw.c" (for WinAPI and GTK)
with a text editor and set the
value in the following define:
#define BMPFILEIMG_MAXSZ 131072 /* Max file size of a bitmap (128 K) */
and recompile HWGUI and your HWGUI application.

With Open Watcom C the maximum size is 65536 (64 k), otherwise the program crashes.
This value is selected with compiler switch
#ifdef __WATCOMC__

For Details see inline comments of sample program "samples\testbmpcr.prg".

Binary string image of a bitmap may contain NULL bytes (0x00),
for Harbour string variables no problem.


hwg_BPMinches_per_meter()
Returns constant value "Inches per meter"


hwg_BPMconv_inch(mtr)
Converts bitmap resolution into DPI


void * BMPImage3x hwg_BMPNewImageC(
int bmp_width,
int bmp_height,
int bmp_bit_depth,
unsigned int colors,
uint32_t xpixelpermeter,
uint32_t ypixelpermeter
)

Creates a bitmap data file image with empty pixel data (for C code implementation)
You need to fill the pixel buffer with HWGUI functions below.


Returns a complete bitmap data file with empty pixel data.
The static pointer "bmp_fileimg" points to the the adress of the
allocated memory.
Other C functions are not mentioned here.


hwg_BMPNewImage(
bmp_width,
bmp_height,
bmp_bit_depth,
colors,
xpixelpermeter,
ypixelpermeter
)

Same as "hwg_BMPNewImageC", returns the bitmap data field in a C type value
for processing with the following HWGUI functions.

Parameters of both functions above:
All parameters are mandatory.

To avoid misfunction in display and program crash
pass all parameters concerning the
bitmap specification described in the Microsoft documents.


Some possible values for xpixelpermeter and ypixelpermeter (in pixels per meter):

Allowed values for bmp_bit_depth (Number of bits per pixel):
1,4,8,24


Sample call:
LOCAL CBMP
CBMP := HWG_BMPNEWIMAGE(48, 48, 1, 2, 2835, 2835 )
HWG_BMPDESTROY()
* ... process image data in C variable "CBMP" with HWGUI functions
* ...
* Write the bitmap to file:
MEMOWRIT("sample.bmp",CBMP)
* (otherwise the bitmap image can be converted to hex values for
* processing in more program steps)


hwg_BMPDestroy()
Free's the image data created by hwg_BMPNewImage().
To avoid memory leaks, call this function after every
call of hwg_BMPNewImage().


hwg_BMPMaxFileSz()
Returns the maximum size of the bitmap file size.


hwg_BMPCalcOffsPixArr(colors)
Calculates the offset to pixel array (image data).
colors : The number of colors.
Pass it like the same parameter "colors" (4th parameter)
of function hwg_BMPNewImage.


hwg_BMPCalcOffsPal
Calculates the offset to palette data,
located after the pixel matrix (jagged array)
Add 1 to the returned value to modify the palette
with function "hwg_ChangeCharInString()".


hwg_ShowBitmap(cbmp,cbmpname,ncolbg,ncolfg)
A standard dialog displays a bitmap up to 1277 x 640 pixel (x,y).
It is useful for debugging.
Parameters:
cbmp : The bitmap file image string
cbmpname : A unique name of the bitmap
ncolbg : Background color (system, if NIL)
ncolfg : Foreground colors (ignored, if no background color is set)
For pass parameters for for both color values
you can use the function hwg_ColorC2N( cColor ):
Converts color representation from string to numeric format.
cColor - a string in #RRGGBB
Modify colors for better visibilty to your own needs.

For parameter cbmp you can pass the string created by HWG_BMPNEWIMAGE()
+ processing the pixel data.
Sample for display the bitmap image file:
  LOCAL CBMP2, cdirsep
  cdirsep := hwg_GetDirSep()
  CBMP2 := MEMOREAD(".." + cdirsep + "image" + cdirsep + "astro.bmp")
  hwg_ShowBitmap(CBMP2,"astro")


Important !
The bitmap name (parameter "cbmpname") must be unique
for every single bitmap (for example above "astro").
It seems, that on Windows systems a cache exists,
containing the first bitmap loaded.
Overwriting it with a new bitmap, the old bitmap
is hold in the bitmap object created in the
function and displayed.
For example:

hwg_ShowBitmap(cbitmap1,"test")
hwg_ShowBitmap(cbitmap2,"test")

So at second function call the old bitmap cbitmap1
is displayed instead of cbitmap2.

So say:
hwg_ShowBitmap(cbitmap1,"bitmap1")
hwg_ShowBitmap(cbitmap2,"bitmap2")

The value for the bitmap name is valid
during a single program run.
We recommend, to write the bitmap names in lower case.
A little helper for generating unique names is function
hwg_BMPuniquename().


hwg_BMPSetMonochromePalette(pcBMP)
Sets the monochrome palette (Bytes per pixel =1, colors=2).


hwg_BMPDrawCircle(nradius,ndeg)
Returns an 2 element array with pixel settings (x,y) for drawing a circle
with a radius of nradius pixels.
Usage see sample program "samples\testbmpcr.prg".


hwg_BMPStr2Obj(pcBMP,cbmpname)
Converts the bitmap string after (optional)
modifications into a bitmap object.
cbmpname : String with an unique bitmap name


hwg_oBitmap2file(oBitmap,cbmpname,[outfilename])


Save a bitmap in an bitmap object into a file.
- oBitmap : The bitmap object
- coutfilename : The file into the bitmap saved,
cbmpname is the unique name of the bitmap written to file,
Is mandatory, otherwise the bitmap is not processed.
Also the cbmpname is case sensitive.
We stricly recommend to use only pure ASCII charset and
lower case (UNIX/LINUX) for the cbmpname.
    pass complete with extension .bmp
    (Default is bitmap.bmp)
Returns forever NIL.


hwg_BMPxyfromBinary(cbpm)

Returns the x and y size of a bitmap
(out of the usage of class HBITMAP)
This is the equivalent to hwg_Getbitmapsize(handle)
cbpm : The binary format of bitmap of Type C
Returns an array with 2 elements of numerical values (N)
[1]: Width
[2]: Height


hwg_BMPuniquename(cprefix)

Returns a unique name following by a number
cprefix : A prefix before the number
 (format is nnn)
 Default is "name"
nnn starts with 1 from program start.
This function may have a little more
performance than a random generating
function.
Use it for creating masses of bitmaps,
like lot's of QR codes.
Some more alternative usages:
- If cprefix is passed with an empty string "",
    you can realize a simple counter, starting
    with 1 at program start.
- For debug purposes, count how often a function is called.
For usage see test program
    test\testunique.prg


hwg_Stretch_BMP_i(cbmp, clocname, nWidth, nHeight )
Stretch a bitmap from binary string image
(independant, without needing a device context)

cbmp : The binary image of a bitmap as string
clocname : The name of the bitmap ( of cbmp )
nWidth, nHeight : The size parameters.
To Respect the size ratio use focus values (nfocus).
for example :
nWidth := nfocus * nWidth
nHeight := nfocus * nHeight

Returns the resized bitmap as string,
If error, empty string "" is returned.
nWidth and nHeight both must be > 0,
otherwise the original bitmap is returned.
This function is important for WinAPI,
but works also with GTK.
For GTK use for better performance the resizing feature
of GTK, for example
METHOD AddString()
(but has no resizing feature on WinAPI,
see HWGUI class documentation of HBITMAP.

long cxdib_Stretch( PCXDIB pdib, HDC pDC, long xoffset, long yoffset, long xsize, long ysize )
of cxshade.c (WinAPI) needs a device context,
so it is not useful for pure resizing of a bitmap.

For lot's of details about resizing (stretching) of bitmaps,
read the comment lines in sample program "stretch.prg".


hwg_bpmObj2String(obmp,cname)
extract the a bitmap string from an
bitmap object.
(for example to display it)
obmp : The bitmap object
cname : The bitmap name
Returns the string image,
in case of error an empty
string (check for success by for example)
EMPTY(cBitmap)


hwg_BMPRename(oBitmap,cnamold,cnamnew)
Renames a bitmap in an bitmap object
oBitmap : The bitmap object
cnamold : The old bitmap name
cnamnew : The new bitmap name
Returns the new bitmap object with
the renamed bitmap.

This function is useful, if
a bitmap is stored in a tempory file
and must be read after resizing,
so it becomes the previous name.
For details see sample program
"stretch.prg"
with lots of comments.

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Some debug helpers for bitmap programming
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~


hwg_bitmapTOC(oBitmap)
Returns a table of contents (TOC) of a bitmap object (name's) in an array


BMPSize2Logfile(oBitmap,name)
Write the bmp size (height and width)in the log file a.log .
oBitmap : The bitmap object
name : The bitmap name


hwg_Debug_logarrayC(acarray)
Only for debug purposes:
Write a single dimension array with c values into logfile.

2.) Add this sample function code into your HWGUI application code:

Write TOC of bitmap to logfile:

FUNCTION BMPTOC2Logfile(oBitmap)
LOCAL atoc
atoc := hwg_bitmapTOC(oBitmap)
hwg_Debug_logarrayC(atoc)
RETURN NIL
IF .NOT. hwg_is_object(oBmp)
hwg_MsgStop("oBmp is not an object!","Error")
ENDIF

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
End of Functions for raw bitmap support
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

QR code functions

Advice:
QR codes are mainly standisized by JIS X 0510 (Japanese Industrial Standard)
and ISO/IEC 18004:2006.
QR codes are operating with UTF-8 charset.
On Windows, which not origin supports UTF-8,
use compiler switch to insert the translation
sequence following this example:

#ifdef __PLATFORM__WINDOWS
   * Convert to UTF-8
   * Set "DEWIN" to your language setting on Windows
   ctext := HB_TRANSLATE(ctext, "DEWIN" , "UTF8")
#endif

Also you need to request the needed codepages
in the MAIN section, corresponding the code sample above:

* Windows codepage
REQUEST HB_CODEPAGE_DEWIN
* Forever needed
REQUEST HB_CODEPAGE_UTF8

REQUEST HB_CODEPAGE_UTF8EX

The reverse translation is needed for the
QR code decoding sequence.


More non standard QR codes are existing. They are not supported.
Also inverted (negative) QR codes are not recognized.


Here an example for a standard QR code with the URL to the HWGUI project site:
Sample QR code


All functions start with prefix "hwg_QR".

QR code encoding

The encode functions need an external library, instructions to
integrate into HWGUI see file contrib\qrencode\Readme.txt.
Please respect the copyright notes of external libraries.

QR code decoding

The encode functions need an external library, instructions to
integrate into HWGUI see file contrib\qredcode\Readme.txt.
Please respect the copyright notes of external libraries.

For decoding QR codes from camera, you need on all platforms the
Open Source package "ZBar".
The version 0.10 is available on the HWGUI project site in the "Files" section
under: contrib/qrdecode/
It works at it's best and can also decode many bar codes.
For Windows, a ready to install setup archive is there available.
On MacOS, an additional shell script and another program "imagesnap" is needed,
so look into the ReadMe.txt file for detailed instructions.
To compile the ZBar package from source, a code patch is needed.

Format description

The encoding function hwg_QRCodeTxtGen() returns a pure text image,
where a blank " " represents a white pixel and the "#" a black pixel.
The lines ends with a UNIX/LINUX line ending.
For example:
Sample QR code
In this state, the image can be processes with the hwg_QR... functions.
Finally, the QR code text image must be converted to a binary bimap image by
calling the function hwg_QRCodetxt2BPM().

HWG_QRENCODE(ctext [, nzoomf] [,nboarder] )
Creates the QR code and convert it to bitmap binary image of type C.
Function to call from main or other functions starting the encode action.
It is the "user interface".
Returns the bitmap binary image of type C.
Not to be used with DLL (for example Borland C).

ctext      :    The text to convert to QR code
nzoomf     :    The zoom factor, default is 3
nboarder   :    The boarder in pixels, default is 10.
                This value is strictly recommended for successfull scans.

This function is not included in the main HWGUI source,
find it in
contrib\qrencode\libqrencode.prg


hwg_CBmp2file(cbitmap,cbitmapfile)
Write the bitmap binary image of type C to file,
for example returned by HWG_QRENCODE().

cbitmapfile : The bitmap file name containing the QR code, with extension ".bmp"

For compatibilty with UNIX/LINUX and MacOS,
use file name always in lower case.


hwg_QRCodeTxtGen(ctext,<border>)
Converts a string ctext into a
QR code text string,
needed character set is UTF-8.
If the operating system does not support
UTF, convert it with function
HB_TRANSLATE().
border: Number of pixel of the
desired (white) border in pixels.
Default value is 4.
For usage see sample program
samples\qrencode.prg.
This function is part of the interface module, all
other functions for QR encoding are part of the HWGUI base libraries.


hwg_QRCodetxt2BPM(cqrcode)
Encode QR code (text format) to bitmap
cqrcode : The text string to encode to
a bitmap.


hwg_QRCodeZoom(cqrcode,nzoom)
Increases the size of a QR code image
cqrcode : The QR code in text format
nzoom : The zoom factor 1 ... n
Returns the new QR code text string.

Important advice:
This function needs some CPU time to finish calculation.
We recommend, not to use a zoom factor
greater than 3 or 4.


hwg_QRCodeZoom_C(cqrcode,nlen,nzoom)

Only experimental status !!

This is the eqivalent function to hwg_QRCodeZoom().
Detected by some tests, the code effeciency is not signficant better than
hwg_QRCodeZoom() (about 10 % faster). This fact shows, that the Harbour compiler creates very
effective code !
cqrcode : The QR code in text format
nlen : Pass LEN(cqrcode)
nzoom : The zoom factor 1 ... n, the default is 1 (no zoom)
There are some limitations caused by the buffer size of the internal string buffer (16 kByte).
A NULL byte at end of every line do not cause trouble creating the bitmap
with hwg_QRCodetxt2BPM().


hwg_QR_SetPixel(cmbp,x,y,xw,yh)
Set a single pixel into QR code bitmap string.
Background color is white, pixel color is black.


hwg_QRCodeAddBorder(cqrcode,nborder)

Add border to QR code image.
cqrcode : The QR code in text format
nborder : The number of border pixels to add 1 ... n
Returns the new QR code text string.
For best performance call this function after hwg_QRCodeZoom()


hwg_QRCodeGetSize(cqrcode)

Get the size of a QR code in text format "cqrcode"
Returns an array with 2 elements: xSize,ySize.




References
   [1] Spence, Rick (Co-Developer of Clipper):
       Clipper Programming Guide, Second Edition Version 5.
       Microtrend Books, Slawson Communication Inc., San Marcos, CA, 1991
       ISBN 0-915391-41-4

   [2] Project CLLOG at Sourceforge:
       https://sourceforge.net/projects/cllog/





prev table of contents next
commands   classes