#pragma BEGINDUMP
#define _WIN32_IE 0x0500
#ifdef __POCC__
#define _WIN32_WINNT 0x0500
#else
#define _WIN32_WINNT 0x0400
#endif
#include
#include "hbapi.h"
#include
#include
#include
#include
#include "hbapiitm.h"
#define HB_PARSTRDEF( n, h, len ) hwg_wstrnull( hwg_wstrget( hb_param( n, HB_IT_ANY ), h, len ) )
#define HB_RETSTR( str ) hwg_wstrset( hb_param( -1, HB_IT_ANY ), str )
#ifdef __XHARBOUR__
#define HB_PARNL( n, x ) hb_parnl( n, x )
#define HB_STORC( n, x, y ) hb_storc( n, x, y )
#define HB_STORL( n, x, y ) hb_storl( n, x, y )
#define HB_STORNI( n, x, y ) hb_storni( n, x, y )
#define HB_STORNL( n, x, y ) hb_stornl( n, x, y )
#else
#define HB_PARNL( n, x ) hb_parvnl( n, x )
#define HB_STORC( n, x, y ) hb_storvc( n, x, y )
#define HB_STORL( n, x, y ) hb_storvl( n, x, y )
#define HB_STORNI( n, x, y ) hb_storvni( n, x, y )
#define HB_STORNL( n, x, y ) hb_storvnl( n, x, y )
#endif
#ifdef __XHARBOUR__
#define HB_ISNIL( n ) ISNIL( n )
#define HB_ISCHAR( n ) ISCHAR( n )
#define HB_ISNUM( n ) ISNUM( n )
#define HB_ISLOG( n ) ISLOG( n )
#define HB_ISDATE( n ) ISDATE( n )
#define HB_ISBYREF( n ) ISBYREF( n )
#define HB_ISARRAY( n ) ISARRAY( n )
#endif
HB_FUNC( CHOOSEFONT )
{
CHOOSEFONT cf;
LOGFONT lf;
long PointSize;
int bold;
HDC hdc;
HWND hwnd;
strcpy( lf.lfFaceName, hb_parc(1) );
hwnd = GetActiveWindow();
hdc = GetDC( hwnd );
lf.lfHeight = -MulDiv( hb_parnl(2), GetDeviceCaps(hdc, LOGPIXELSY), 72 );
if( hb_parl(3) )
lf.lfWeight = 700;
else
lf.lfWeight = 400;
if( hb_parl(4) )
lf.lfItalic = TRUE;
else
lf.lfItalic = FALSE;
if( hb_parl(6) )
lf.lfUnderline = TRUE;
else
lf.lfUnderline = FALSE;
if( hb_parl(7) )
lf.lfStrikeOut = TRUE;
else
lf.lfStrikeOut = FALSE;
lf.lfCharSet = ( BYTE ) hb_parni( 8 );
cf.lStructSize = sizeof( CHOOSEFONT );
cf.hwndOwner = hwnd;
cf.hDC = ( HDC ) NULL;
cf.lpLogFont = &lf;
cf.Flags = HB_ISNUM( 9 ) ? hb_parni( 9 ) : CF_SCREENFONTS | CF_EFFECTS | CF_INITTOLOGFONTSTRUCT;
cf.rgbColors = hb_parnl( 5 );
cf.lCustData = 0L;
cf.lpfnHook = ( LPCFHOOKPROC ) NULL;
cf.lpTemplateName = ( LPSTR ) NULL;
cf.hInstance = ( HINSTANCE ) NULL;
cf.lpszStyle = ( LPSTR ) NULL;
cf.nFontType = SCREEN_FONTTYPE;
cf.nSizeMin = 0;
cf.nSizeMax = 0;
if( !ChooseFont(&cf) )
{
hb_reta( 8 );
HB_STORC( "", -1, 1 );
HB_STORNL( ( LONG ) 0, -1, 2 );
HB_STORL( 0, -1, 3 );
HB_STORL( 0, -1, 4 );
HB_STORNL( 0, -1, 5 );
HB_STORL( 0, -1, 6 );
HB_STORL( 0, -1, 7 );
HB_STORNI( 0, -1, 8 );
ReleaseDC( hwnd, hdc );
return;
}
PointSize = -MulDiv( lf.lfHeight, 72, GetDeviceCaps(hdc, LOGPIXELSY) );
if( lf.lfWeight == 700 )
bold = 1;
else
bold = 0;
hb_reta( 8 );
HB_STORC( lf.lfFaceName, -1, 1 );
HB_STORNL( ( LONG ) PointSize, -1, 2 );
HB_STORL( bold, -1, 3 );
HB_STORL( lf.lfItalic, -1, 4 );
HB_STORNL( cf.rgbColors, -1, 5 );
HB_STORL( lf.lfUnderline, -1, 6 );
HB_STORL( lf.lfStrikeOut, -1, 7 );
HB_STORNI( lf.lfCharSet, -1, 8 );
ReleaseDC( hwnd, hdc );
}
HB_FUNC( C_GETFILE )
{
OPENFILENAME ofn;
char buffer[ 32768 ];
char cFullName[ 256 ][ 1024 ];
char cCurDir[ 512 ];
char cFileName[ 512 ];
int iPosition = 0;
int iNumSelected = 0;
int n;
DWORD flags = OFN_FILEMUSTEXIST;
buffer[ 0 ] = 0;
if( hb_parl(4) )
flags = flags | OFN_ALLOWMULTISELECT | OFN_EXPLORER;
if( hb_parl(5) )
flags = flags | OFN_NOCHANGEDIR;
memset( ( void * ) &ofn, 0, sizeof( OPENFILENAME ) );
ofn.lStructSize = sizeof( ofn );
ofn.hwndOwner = GetActiveWindow();
ofn.lpstrFilter = hb_parc( 1 );
ofn.nFilterIndex = 1;
ofn.lpstrFile = buffer;
ofn.nMaxFile = sizeof( buffer );
ofn.lpstrInitialDir = hb_parc( 3 );
ofn.lpstrTitle = hb_parc( 2 );
ofn.nMaxFileTitle = 512;
ofn.Flags = flags;
if( GetOpenFileName(&ofn) )
{
if( ofn.nFileExtension != 0 )
hb_retc( ofn.lpstrFile );
else
{
wsprintf( cCurDir, "%s", &buffer[ iPosition ] );
iPosition = iPosition + strlen( cCurDir ) + 1;
do
{
iNumSelected++;
wsprintf( cFileName, "%s", &buffer[ iPosition ] );
iPosition = iPosition + strlen( cFileName ) + 1;
wsprintf( cFullName[ iNumSelected ], "%s\\%s", cCurDir, cFileName );
}
while( ( strlen(cFileName) != 0 ) && ( iNumSelected <= 255 ) );
if( iNumSelected > 1 )
{
hb_reta( iNumSelected - 1 );
for( n = 1; n < iNumSelected; n++ )
HB_STORC( cFullName[ n ], -1, n );
}
else
hb_retc( &buffer[ 0 ] );
}
}
else
hb_retc( "" );
}
// JK JP
// JK HMG 1.0 Experimental Build 8
// --- callback function for C_BROWSEFORFOLDER(). Contributed By Andy Wos
HB_FUNC( SELECTFOLDER2 )
{
BROWSEINFO bi;
TCHAR lpBuffer[ MAX_PATH ];
LPCTSTR lpResult = NULL;
LPITEMIDLIST pidlBrowse; // PIDL selected by user
void * hTitle;
SHGetSpecialFolderLocation( GetActiveWindow(), HB_ISNIL(2) ? CSIDL_DRIVES : hb_parni(2), &pidlBrowse );
bi.hwndOwner = GetActiveWindow();
bi.pidlRoot = pidlBrowse;
bi.pszDisplayName = lpBuffer;
bi.lpszTitle = HB_PARSTRDEF( 1, &hTitle, NULL );
bi.ulFlags = BIF_USENEWUI;
bi.lpfn = NULL;
bi.lParam = 0;
bi.iImage = 0;
// Browse for a folder and return its PIDL.
pidlBrowse = SHBrowseForFolder( &bi );
if( pidlBrowse )
{
SHGetPathFromIDList( pidlBrowse, lpBuffer );
hb_retc( lpBuffer );
}
else
hb_retc( "" );
/*pidlBrowse = SHBrowseForFolder( &bi );
if( pidlBrowse != NULL )
{
if( SHGetPathFromIDList( pidlBrowse, lpBuffer ) )
lpResult = lpBuffer;
CoTaskMemFree( pidlBrowse );
}
HB_RETSTR( lpResult ); */
hb_strfree( hTitle );
}
HB_FUNC( CHOOSECOLOR )
{
CHOOSECOLOR cc;
COLORREF crCustClr[ 16 ];
int i;
for( i = 0; i < 16; i++ )
crCustClr[ i ] = ( HB_ISARRAY(3) ? ( COLORREF ) HB_PARNL(3, i + 1) : GetSysColor(COLOR_BTNFACE) );
cc.lStructSize = sizeof( CHOOSECOLOR );
cc.hwndOwner = HB_ISNIL( 1 ) ? GetActiveWindow() : ( HWND ) hb_parnl( 1 );
cc.rgbResult = ( COLORREF ) HB_ISNIL( 2 ) ? 0 : hb_parnl( 2 );
cc.lpCustColors = crCustClr;
cc.Flags = ( WORD ) ( HB_ISNIL(4) ? CC_ANYCOLOR | CC_FULLOPEN | CC_RGBINIT : hb_parnl(4) );
if( !ChooseColorA(&cc) )
hb_retnl( -1 );
else
hb_retnl( cc.rgbResult );
}
#pragma ENDDUMP