my HB_FUNC( FINDREPLACEDLG ) ANSI Version compile without Error / Warning and work
- Code: Select all Expand view RUN
- #pragma BEGINDUMP
#include <windows.h>
#include <commctrl.h>
#include <hbapi.h>
#include <shlobj.h>
#include <tchar.h>
#define UNICODE
#ifdef UNICODE
LPWSTR AnsiToWide( LPCSTR );
LPSTR WideToAnsi( LPWSTR );
#endif
//********************************************************************
// by Dr. Claudio Soto ( January 2014 )
//********************************************************************
static TCHAR cFindWhat[ 1024 ];
static TCHAR cReplaceWith[ 1024 ];
static FINDREPLACE FindReplace;
static HWND hDlgFindReplace = NULL;
HB_FUNC( REGISTERFINDMSGSTRING )
{
UINT MessageID = RegisterWindowMessage( FINDMSGSTRING );
hb_retnl( ( LONG ) MessageID );
}
HB_FUNC( FINDREPLACEDLG )
{
// HWND hWnd = HB_ISNIL( 1 ) ? GetActiveWindow() : ( HWND ) HB_PARNL( 1 );
HWND hWnd = GetActiveWindow() ;
BOOL NoUpDown = ( BOOL ) ( HB_ISNIL( 2 ) ? FALSE : hb_parl( 2 ) );
BOOL NoMatchCase = ( BOOL ) ( HB_ISNIL( 3 ) ? FALSE : hb_parl( 3 ) );
BOOL NoWholeWord = ( BOOL ) ( HB_ISNIL( 4 ) ? FALSE : hb_parl( 4 ) );
BOOL CheckDown = ( BOOL ) ( HB_ISNIL( 5 ) ? TRUE : hb_parl( 5 ) );
BOOL CheckMatchCase = ( BOOL ) ( HB_ISNIL( 6 ) ? FALSE : hb_parl( 6 ) );
BOOL CheckWholeWord = ( BOOL ) ( HB_ISNIL( 7 ) ? FALSE : hb_parl( 7 ) );
BOOL lReplace = ( BOOL ) hb_parl( 10 );
#ifndef UNICODE
LPSTR FindWhat = ( LPSTR ) hb_parc( 8 );
LPSTR ReplaceWith = ( LPSTR ) hb_parc( 9 );
LPSTR cTitle = ( LPSTR ) hb_parc( 11 );
#else
LPWSTR FindWhat = AnsiToWide( ( char * ) hb_parc( 8 ) );
LPWSTR ReplaceWith = AnsiToWide( ( char * ) hb_parc( 9 ) );
LPWSTR cTitle = AnsiToWide( ( char * ) hb_parc( 11 ) );
#endif
if( hDlgFindReplace == NULL )
{
ZeroMemory( &FindReplace, sizeof( FindReplace ) );
// next 2 lines
lstrcpy( cFindWhat, FindWhat );
lstrcpy( cReplaceWith, ReplaceWith );
FindReplace.lStructSize = sizeof( FindReplace );
FindReplace.Flags = ( NoUpDown ? FR_HIDEUPDOWN : 0 ) | ( NoMatchCase ? FR_HIDEMATCHCASE : 0 ) | ( NoWholeWord ? FR_HIDEWHOLEWORD : 0 )
| ( CheckDown ? FR_DOWN : 0 ) | ( CheckMatchCase ? FR_MATCHCASE : 0 ) | ( CheckWholeWord ? FR_WHOLEWORD : 0 );
FindReplace.hwndOwner = hWnd;
FindReplace.lpstrFindWhat = cFindWhat;
FindReplace.wFindWhatLen = sizeof( cFindWhat ) / sizeof( TCHAR );
FindReplace.lpstrReplaceWith = cReplaceWith;
FindReplace.wReplaceWithLen = sizeof( cReplaceWith ) / sizeof( TCHAR );
if( lReplace )
hDlgFindReplace = ReplaceText( &FindReplace );
else
hDlgFindReplace = FindText( &FindReplace );
// and here
if( HB_ISCHAR( 11 ) )
SetWindowText( hDlgFindReplace, cTitle );
ShowWindow( hDlgFindReplace, SW_SHOW );
}
#ifdef UNICODE
hb_xfree( ( TCHAR * ) FindWhat );
hb_xfree( ( TCHAR * ) ReplaceWith );
hb_xfree( ( TCHAR * ) cTitle );
#endif
}
#pragma ENDDUMP
now when
- Code: Select all Expand view RUN
- #define UNICODE
i got these Warning
Warning W8075 HBFUNC.prg 61: Suspicious pointer conversion in function HB_FUN_FINDREPLACEDLG
Warning W8075 HBFUNC.prg 62: Suspicious pointer conversion in function HB_FUN_FINDREPLACEDLG
Warning W8075 HBFUNC.prg 79: Suspicious pointer conversion in function HB_FUN_FINDREPLACEDLG
can somebody help me please