Files
harbour-core/harbour/contrib/hbwin/wapi_winuser.c
Przemyslaw Czerpak a70ce60954 2009-10-23 09:24 UTC+0200 Przemyslaw Czerpak (druzus/at/priv.onet.pl)
* harbour/src/rdd/dbfnsx/dbfnsx1.c
    ! fixed bug reported by Jaroslav Janik (many thanks) - if index FOR
      expression excluded all records from non empty table then root page
      was not initialized and DBFNSX generated corruption RTE.

  * harbour/utils/hbi18n/hbi18n.prg
    * set default GT to CGI

  * harbour/src/common/hbgete.c
    ! fixed memory leak in non UNICODE Windows hb_getenv_buffer()
    ! add C stack buffers to eliminate memory allocation in UNICODE
      Windows hb_getenv_buffer() - they are used if envvar name and
      passed buffer are not too large. It fixes HB_FM_STATISTICS
      Windows builds.

  * harbour/contrib/hbwin/wapi_winuser.c
    + added WAPI_DESTROYWINDOW function

  * harbour/contrib/xhb/traceprg.prg
  * harbour/contrib/xhb/hbcompat.ch
    ! fixed typo in TraceLog() condition - was always disabled
    + added emulation for xHarbour Set( _SET_TRACE* [, <params,...> ] )
      settings

  * harbour/src/vm/hvmall.c
    ! define _GNU_SOURCE to fix compilation with HB_FM_DL_ALLOC in Linux
      builds

  * harbour/include/hbdefs.h
    * declare HB_FOFFSET as LONG instead of LONGLONG on platforms where
      LONG is 64bit integer to be compatible with C RTL file API

  * harbour/src/vm/maindllh.c
  * harbour/src/vm/maindllp.c
  * harbour/contrib/hbct/ctstr.c
    ! casting in HB_TRACE() massages

  * harbour/include/hbapi.h
  * harbour/include/hbapiitm.h
  * harbour/src/vm/arrays.c
  * harbour/src/vm/hashes.c
  * harbour/src/vm/itemapi.c
    + added hb_arrayCloneTo(), hb_hashCloneTo(), hb_itemCloneTo()

  * harbour/src/vm/arrayshb.c
  * harbour/src/vm/classes.c
  * harbour/src/vm/hashes.c
  * harbour/src/vm/hashfunc.c
  * harbour/src/vm/hvm.c
    % use hb_*CloneTo() instead of hb_*Clone()

  * harbour/include/hbapi.h
  * harbour/src/vm/garbage.c
    - removed hb_gcRegisterSweep() function and support for user defined
      sweep mark functions in GC blocks
    - removed hb_gcAlloc() function
    + added new function hb_gcAllocate() which work in similar way to removed
      hb_gcAlloc() function but it accepts as second parameter HB_GC_FUNCS
      structure instead of HB_GARBAGE_FUNC_PTR and returned GC blocks are
      locked so programmer does not have to worry that they can be removed
      by GC.
    + added new internal function hb_gcAllocRaw() which works like
      hb_gcAllocate() but returned GC blocks are not locked. They can
      be used only in HVM in places well known that cannot activate
      automatic GC scan. It should not be used by 3-rd party code.

  * harbour/include/hbapi.h
  * harbour/include/hbapiitm.h
  * harbour/src/vm/extend.c
  * harbour/src/vm/itemapi.c
    * modified hb_parptrGC(), hb_parvptrGC(), hb_arrayGetPtrGC(),
      hb_itemGetPtrGC() functions to use HB_GC_FUNCS structure instead
      of HB_GARBAGE_FUNC_PTR
    * modified hb_itemPutPtrGC() and indirectly related functions like
      hb_arraySetPtrGC() or hb_stor[v]ptrGC() to automatically unlock
      passed GC block just after attaching to known HVM item.

  * harbour/include/hbregex.h
  * harbour/src/rtl/hbregexc.c
    * declare GC block detractor as static function
    + added hb_regexIs() function
    * updated to work with new GC API
    * removed unnecessary in new GC API hb_gcLock() call - GC blocks
      allocated by hb_gcAllocate() are already locked and they mustn't
      be locked explicitly by programmer (until he does not exactly knows
      what he does ;))

  * harbour/src/rtl/hbregex.c
    * use hb_regexIs() instead of using regex GC destructor
    * removed unnecessary in new GC API hb_gcUnlock() call - GC blocks
      stored in HB_IT_POINTER item are automatically unlocked

  * harbour/src/rtl/hbinet.c
  * harbour/contrib/hbcurl/hbcurl.c
    * updated to work with new GC API
    % unlock items storing callback codeblocks and use GC mark functions
      to mark them as used in GC passes

  * harbour/src/pp/pplib.c
  * harbour/src/vm/runner.c
  * harbour/src/vm/codebloc.c
  * harbour/src/vm/hashes.c
  * harbour/src/vm/hvm.c
  * harbour/src/vm/arrays.c
  * harbour/src/vm/thread.c
  * harbour/src/vm/dynlibhb.c
  * harbour/src/rtl/hbzlibgz.c
  * harbour/src/rtl/hbregex.c
  * harbour/src/rtl/hbregexc.c
  * harbour/src/rtl/hbgtcore.c
  * harbour/src/rtl/hbi18n1.c
  * harbour/src/rdd/wacore.c
  * harbour/contrib/hbsqlit3/hbsqlit3.c
  * harbour/contrib/hbnetio/netiosrv.c
  * harbour/contrib/hbmzip/hbmzip.c
  * harbour/contrib/hbhpdf/harupdf.c
  * harbour/contrib/hbwin/olecore.c
  * harbour/contrib/hbwin/win_prn1.c
  * harbour/contrib/hbwin/win_dll.c
    * updated code which was using hb_gcAlloc() to work with new GC API.

  * harbour/contrib/hbwin/axcore.c
    * updated syntax description

   TODO: update contrib code: hbqt, hbssl, ... to work with new GC API.
         I would like to ask authors of above libraries to do it.
   TODO: defined when and how we should free AX control and user callback
         handler and update AX code to respect new definition
2009-10-23 07:25:36 +00:00

328 lines
10 KiB
C

/*
* $Id$
*/
/*
* Harbour Project source code:
* Windows API functions (winuser)
*
* Copyright 2009 Pritpal Bedi <pritpal@vouchcac.com>
* Copyright 2009 Viktor Szakats (harbour.01 syenar.hu)
* www - http://www.harbour-project.org
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this software; see the file COPYING. If not, write to
* the Free Software Foundation, Inc., 59 Temple Place, Suite 330,
* Boston, MA 02111-1307 USA (or visit the web site http://www.gnu.org/).
*
* As a special exception, the xHarbour Project gives permission for
* additional uses of the text contained in its release of xHarbour.
*
* The exception is that, if you link the xHarbour libraries with other
* files to produce an executable, this does not by itself cause the
* resulting executable to be covered by the GNU General Public License.
* Your use of that executable is in no way restricted on account of
* linking the xHarbour library code into it.
*
* This exception does not however invalidate any other reasons why
* the executable file might be covered by the GNU General Public License.
*
* This exception applies only to the code released by the xHarbour
* Project under the name xHarbour. If you copy code from other
* xHarbour Project or Free Software Foundation releases into a copy of
* xHarbour, as the General Public License permits, the exception does
* not apply to the code that you add in this way. To avoid misleading
* anyone as to the status of such modified files, you must delete
* this exception notice from them.
*
* If you write modifications of your own for xHarbour, it is your choice
* whether to permit this exception to apply to your modifications.
* If you do not wish that, delete this exception notice.
*
*/
/*----------------------------------------------------------------------*/
#define HB_OS_WIN_USED
#include "hbapi.h"
#include "hbwapi.h"
#include <winuser.h>
HB_FUNC( WAPI_GETKEYSTATE )
{
hb_retni( GetKeyState( hb_parni( 1 ) ) );
}
HB_FUNC( WAPI_GETDESKTOPWINDOW )
{
hb_retptr( GetDesktopWindow() );
}
HB_FUNC( WAPI_MESSAGEBOX )
{
LPTSTR lpStr1 = HB_TCHAR_CONVTO( hb_parcx( 2 ) );
LPTSTR lpStr2 = HB_TCHAR_CONVTO( hb_parcx( 3 ) );
hb_retni( MessageBox( ( HWND ) hb_parptr( 1 ), lpStr1, lpStr2, hb_parni( 4 ) ) );
HB_TCHAR_FREE( lpStr1 );
HB_TCHAR_FREE( lpStr2 );
}
HB_FUNC( WAPI_CREATEWINDOWEX )
{
LPTSTR lpStr1 = HB_TCHAR_CONVTO( hb_parcx( 2 ) );
LPTSTR lpStr2 = HB_TCHAR_CONVTO( hb_parcx( 3 ) );
hb_retptr( CreateWindowEx(
( DWORD ) hb_parnl( 1 ) /* dwExStyle */,
( LPCTSTR ) lpStr1 /* lpClassName */,
( LPCTSTR ) lpStr2 /* lpWindowName */,
HB_ISNUM( 4 ) ? ( DWORD ) hb_parnl( 4 ) : WS_OVERLAPPEDWINDOW /* dwStyle */,
HB_ISNUM( 5 ) ? ( int ) hb_parni( 5 ) : ( int ) CW_USEDEFAULT /* x */,
HB_ISNUM( 6 ) ? ( int ) hb_parni( 6 ) : ( int ) CW_USEDEFAULT /* y */,
( int ) hb_parni( 7 ) /* nWidth */,
( int ) hb_parni( 8 ) /* nHeight */,
HB_ISPOINTER( 9 ) ? ( HWND ) hb_parptr( 9 ) : HWND_DESKTOP /* hWndParent */,
( HMENU ) hb_parptr( 10 ) /* hMenu */,
( HINSTANCE ) hb_parptr( 11 ) /* hInstance */,
( LPVOID ) hb_parptr( 12 ) /* lpParam */ ) );
HB_TCHAR_FREE( lpStr1 );
HB_TCHAR_FREE( lpStr2 );
}
HB_FUNC( WAPI_DESTROYWINDOW )
{
hb_retl( DestroyWindow( ( HWND ) hb_parptr( 1 ) ) );
}
/*-----------------------------------------------------------------------/
BEGIN SCROLLBAR MANIPULATION WINAPI FUNCTIONS
/-----------------------------------------------------------------------*/
/*
BOOL EnableScrollBar( HWND hWnd, UINT wSBflags, UINT wArrows );
*/
HB_FUNC( WAPI_ENABLESCROLLBAR )
{
#if ! defined( HB_OS_WIN_CE )
wapi_ret_L( EnableScrollBar( wapi_par_HWND( 1 ),
wapi_par_UINT( 2 ),
wapi_par_UINT( 3 ) ) );
#else
wapi_ret_L( FALSE );
#endif
}
/*----------------------------------------------------------------------*/
/*
BOOL GetScrollBarInfo( HWND hwnd, LONG idObject, PSCROLLBARINFO psbi );
$$
Local strSCROLLBARINFO IS SCROLLBARINFO
Local cSCROLLBARINFO = strSCROLLBARINFO:value
Local nCtrlType = OBJID_CLIENT | OBJID_HSCROLL | OBJID_VSCROLL
lSuccess := WAPI_GetScrollInfo( hWnd, nCtrType, @cSCROLLINFO )
strSCROLLBARINFO:buffer( cSCROLLBARINFO )
? strSCROLLINFO:
$$
*/
#if 0
HB_FUNC( WAPI_GETSCROLLBARINFO )
{
PSCROLLBARINFO sbi = ( PSCROLLBARINFO ) wapi_par_STRUCT( 3 );
BOOL bSuccess;
memset( &sbi, 0, sizeof( SCROLLBARINFO ) );
sbi->cbSize = sizeof( SCROLLBARINFO );
bSuccess = GetScrollBarInfo( wapi_par_HWND( 1 ),
wapi_par_LONG( 2 ),
sbi );
if( bSuccess )
hb_storclen( ( char * ) &sbi, sizeof( SCROLLBARINFO ), 3 );
wapi_ret_L( bSuccess );
}
#endif
/*----------------------------------------------------------------------*/
/*
BOOL GetScrollInfo( HWND hwnd, int fnBar, LPSCROLLINFO lpsi );
*/
HB_FUNC( WAPI_GETSCROLLINFO )
{
LPSCROLLINFO si = ( LPSCROLLINFO ) wapi_par_STRUCT( 3 );
BOOL bSuccess;
bSuccess = GetScrollInfo( wapi_par_HWND( 1 ),
wapi_par_INT( 2 ),
si );
if( bSuccess )
hb_storclen( ( char * ) &si, 3, sizeof( SCROLLINFO ) );
wapi_ret_L( bSuccess );
}
/*----------------------------------------------------------------------*/
/*
int GetScrollPos( HWND hWnd, int nBar );
*/
HB_FUNC( WAPI_GETSCROLLPOS )
{
#if ! defined( HB_OS_WIN_CE )
wapi_ret_NI( GetScrollPos( wapi_par_HWND( 1 ),
wapi_par_INT( 2 ) ) );
#else
wapi_ret_NI( 0 );
#endif
}
/*----------------------------------------------------------------------*/
/*
BOOL GetScrollRange( HWND hWnd, int nBar, LPINT lpMinPos, LPINT lpMaxPos );
*/
HB_FUNC( WAPI_GETSCROLLRANGE )
{
#if ! defined( HB_OS_WIN_CE )
{
int minPos, maxPos;
if( GetScrollRange( wapi_par_HWND( 1 ),
wapi_par_INT( 2 ),
&minPos,
&maxPos ) )
{
hb_storni( minPos, 3 );
hb_storni( maxPos, 4 );
wapi_ret_L( TRUE );
return;
}
}
#endif
wapi_ret_L( FALSE );
}
/*----------------------------------------------------------------------*/
#if 0
/*
BOOL ScrollDC( HDC hDC, int dx, int dy, const RECT *lprcScroll, const RECT *lprcClip,
HRGN hrgnUpdate, LPRECT lprcUpdate );
*/
HB_FUNC( WAPI_SCROLLDC )
{
}
/*----------------------------------------------------------------------*/
/*
BOOL ScrollWindow( HWND hWnd, int XAmount, int YAmount, const RECT *lpRect,
const RECT *lpClipRect );
*/
HB_FUNC( WAPI_SCROLLWINDOW )
{
}
/*----------------------------------------------------------------------*/
/*
int ScrollWindowEx( HWND hWnd, int dx, int dy, const RECT *prcScroll, const RECT *prcClip,
HRGN hrgnUpdate, LPRECT prcUpdate, UINT flags );
*/
HB_FUNC( WAPI_SCROLLWINDOWEX )
{
}
#endif
/*----------------------------------------------------------------------*/
/*
int SetScrollInfo( HWND hwnd, int fnBar, LPCSCROLLINFO lpsi, BOOL fRedraw );
*/
HB_FUNC( WAPI_SETSCROLLINFO )
{
LPSCROLLINFO si = ( LPSCROLLINFO ) wapi_par_STRUCT( 3 );
wapi_ret_NI( SetScrollInfo( wapi_par_HWND( 1 ),
wapi_par_INT( 2 ),
si,
HB_ISLOG( 4 ) ? wapi_par_BOOL( 4 ) : TRUE ) );
}
/*----------------------------------------------------------------------*/
/*
int SetScrollPos( HWND hWnd, int nBar, int nPos, BOOL bRedraw );
*/
HB_FUNC( WAPI_SETSCROLLPOS )
{
wapi_ret_NI( SetScrollPos( wapi_par_HWND( 1 ),
wapi_par_INT( 2 ),
wapi_par_INT( 3 ),
wapi_par_BOOL( 4 ) ) );
}
/*----------------------------------------------------------------------*/
/*
BOOL SetScrollRange( HWND hWnd, int nBar, int nMinPos, int nMaxPos, BOOL bRedraw );
*/
HB_FUNC( WAPI_SETSCROLLRANGE )
{
wapi_ret_L( SetScrollRange( wapi_par_HWND( 1 ),
wapi_par_INT( 2 ),
wapi_par_INT( 3 ),
wapi_par_INT( 4 ),
HB_ISLOG( 5 ) ? wapi_par_BOOL( 5 ) : TRUE ) );
}
/*----------------------------------------------------------------------*/
/*
BOOL ShowScrollBar( HWND hWnd, int wBar, BOOL bShow );
*/
HB_FUNC( WAPI_SHOWSCROLLBAR )
{
#if ! defined( HB_OS_WIN_CE )
wapi_ret_L( ShowScrollBar( wapi_par_HWND( 1 ),
wapi_par_INT( 2 ),
wapi_par_BOOL( 3 ) ) );
#else
wapi_ret_L( FALSE );
#endif
}
/*----------------------------------------------------------------------*/
/*
HWND SetFocus( HWND hWnd );
*/
HB_FUNC( WAPI_SETFOCUS )
{
wapi_ret_HANDLE( SetFocus( wapi_par_HWND( 1 ) ) );
}
/*----------------------------------------------------------------------*/
#if 0
HB_FUNC( WAPI_LOADBITMAP )
{
LPTSTR lpBmp;
if( HB_ISNUM( 2 ) )
lpBmp = ( LPTSTR ) MAKEINTRESOURCE( wapi_par_INT( 2 ) );
else
lpBmp = ( LPTSTR ) HB_TCHAR_CONVTO( hb_parcx( 2 ) );
hb_retptr( LoadBitmap( wapi_par_HINSTANCE( 1 ), lpBmp ) );
if( ! HB_ISNUM( 2 ) )
HB_TCHAR_FREE( lpBmp );
}
#endif
/*----------------------------------------------------------------------*/
HB_FUNC( WAPI_GETACTIVEWINDOW )
{
hb_retptr( GetActiveWindow() );
}
/*----------------------------------------------------------------------*/
HB_FUNC( WAPI_SETACTIVEWINDOW )
{
hb_retptr( SetActiveWindow( wapi_par_HWND( 1 ) ) );
}
/*----------------------------------------------------------------------*/