My Friend View This Source
For Run Sound Wave From Resource And Wave File
Bat Not Compiler With Function hb_parc(1)
Thank For All
// Test Sound Source
#include "FWCE.ch"
//----------------------------------------------------------------------------//
function Main()
local oWnd
DEFINE WINDOW oWnd TITLE "TEST sound "
@1,10 button "Test 1 PLAYWAV()" size 150, 20 action PLAYWAV()
@4,10 button "Test 2 PLAYWAVRES()" size 150, 20 action PLAYWAVRES()
ACTIVATE WINDOW oWnd
return nil
********************************************************
#pragma BEGINDUMP
#include <hbapi.h>
#include <Windows.h>
#include <mmsystem.h>
HMODULE GetResources( void );
extern HINSTANCE GetInstance( void );
void HB_FUN_PLAYWAV()
{
// char cfile * =hb_parc(1);
PlaySound(_T("\\Windows\\Default.wav"), NULL, SND_ASYNC | SND_FILENAME);
// PlaySound( cfile, NULL, SND_ASYNC | SND_FILENAME);
}
void HB_FUN_PLAYWAVRES()
{
// char cfile * =hb_parc(1);
PlaySound (_T("testSound"), GetResources() ? GetResources(): GetInstance(), SND_RESOURCE | SND_ASYNC);
/// PlaySound ( cfile, GetResources() ? GetResources(): GetInstance(), SND_RESOURCE | SND_ASYNC);
// MessageBox( GetActiveWindow(),cfile , _T("VIEW THIS"), 0 );
}
/*
void HB_FUN_PLAYWAVMEM()
{
BYTE buffer[100*1024];
CFile file;
file.Open(_T("\\Windows\\empty.wav"), CFile::modeRead);
file.Read(buffer, 100*1024);
file.Close();
PlaySound((const unsigned short *)buffer, NULL, SND_MEMORY | SND_ASYNC);
}
*/
#pragma ENDDUMP
/*
// FILE TEST_SO.RC //
// SAVE THIS TEXT FOR FILE ( TEST_SO.RC )
// BUT ANY FILE SOUND (SMAIL ONLY) TEST.WAV
// AND Compiler FILE TEST_SO.PRG
testSound WAVE "test.wav"
*/
For Run Sound Wave From Resource And Wave File
- Enrico Maria Giordano
- Posts: 7355
- Joined: Thu Oct 06, 2005 8:17 pm
- Location: Roma - Italia
- Contact:
Re: For Run Sound Wave From Resource And Wave File
This is a working sample:
EMG
Code: Select all
#include "Fwce.ch"
FUNCTION MAIN()
LOCAL oWnd
DEFINE WINDOW oWnd
@ 1, 1 BUTTON "&Play";
SIZE 60, 30;
ACTION SNDPLAYSOUND( CURDIR() + "\SOUND.WAV" )
ACTIVATE WINDOW oWnd
RETURN NIL
#pragma BEGINDUMP
#include "windows.h"
#include "mmsystem.h"
#include "hbapi.h"
LPWSTR AnsiToWide( LPSTR );
HB_FUNC( SNDPLAYSOUND )
{
LPWSTR pW = AnsiToWide( hb_parc( 1 ) );
hb_retnl( sndPlaySound( pW, hb_parni( 2 ) ) );
hb_xfree( pW );
}
#pragma ENDDUMP