|
I'm making a small program (in MFC) that needs to play several wave-sounds at the same time. I tried to use PlaySound(), but with that it seems you can just play one file at the time (the previous played file stops and the new begins to play, or the second waits till the first have finished).
How do I play several wave-files simultaneous?
|
|
|
|
|
Hi,
I encounterd the same problem, and found no solution.
I think it's the system which locks the "loudspeaker" resource.
Well, actually it's the soundcard device.
The only workaround would be to switch the playing of the sound faster than the user can hear the tones. But this will be heard by cracks, and also the sum of the wav file times will be the total playing time, not the time of the longest wav file.
By considering the difficulties and drawbacks of this method I choose not to follow this way.
Instead now I try to find a tool for mixing two wavefiles outside the application, and later on play this mixed wave file in my application.
G. Steudtel.
|
|
|
|
|
DirectX DirectSound will do this for you.
search google for some helper classes that encapsulate DirectSound and DirectSoundBuffer unless you want to do a lot of low level coding.
|
|
|
|
|
Hi
I have created a very simple ActiveX, but I would like to send parameters from a HTML page to the ActiveX. I have found some information mentioning that I need to implement an "IPropertyBag" but I am new to MFC, (this is my first project), and I dont know where to implement it neither how.
Could anyone help me?
Thanks
"Learn from the mistakes of others.
You can't live long enough to make them all yourself."
"Failure doesn't mean I'm a failure, It does mean I have not yet succeeded;
Failure doesn't mean that I should give up, It does mean that I should try harder;
Failure doesn't mean that I will never make it, It does mean that I need more practice".
Thank you for helping.
|
|
|
|
|
Hi!
I need to serialize some GDI+ stuff and for that it seems I need to use the
IStream COM interface.
For the rest of the serialization I use CFile. I tried this but it throws a
memory exception:
<br />
void CViewCoverPage::Serialize(CArchive& ar)<br />
{<br />
...<br />
<br />
COleStreamFile* pOleStream = (COleStreamFile*)ar.GetFile();<br />
IStream* pIStream = pOleStream->GetStream();<br />
m_pLogo->Save(pIStream,...);
...<br />
}<br />
It seems any operation I try with the IStream object results in an access
violation.
Do I need to initialize it in some way??
What am I missing here??
thanks /Anders
|
|
|
|
|
On the wild assumption that your document class is dervied from COleDocument try COleDocument::EnableCompoundFile(TRUE)
else create a memory stream file and stream m_pLogo into it
then archive the resulting bytes
ar << (DWORD) size of memory stream
ar << contents of memory stream
and reverse the sequence for the restore obviously
using dynamic_cast<colestreamfile*> ar.GetFile() would probably have shown this up etc etc
|
|
|
|
|
I've had some luck with the CArchiveStream class declared in the <afxpriv2.h> header (at least in VC6.0, 7.0 and 7.1; also in eVC 3.0).
This class is what MFC uses for feeding ActiveX controls on dialog boxes. I don't expect it to change, but it might.
Using it is quite simple:
<br />
CFile file( );<br />
CArchive ar( &file, );<br />
CArchiveStream arStm( &ar );<br />
<br />
IStream* pStm = &arStm;<br />
<br />
<br /> Obviously if you need the stream object to have a longer lifetime, you'll need to create all the objects (arStm, ar, file) on the heap instead.
Minor edits - decided to make IStream more obvious
--
Mike Dimmick
|
|
|
|
|
Hi guys! Thanks for your help!
All suggested approaches actually workes.
Trouble though is that Gdiplus::Image::FromStream(IStream* pIstrem)
reads the whole stream to the end. This would have been good if the
stream contained only the image but... Therefore I had to create a new
IStream for the Image::FromStream(.....)
So this is how it came out and thanks aganig for your help:
<br />
Image* SerializeImage(CArchive&, Image*)<br />
{<br />
DWORD sizeOfStream;<br />
CFileException* pMemFileError = NULL;<br />
LPBYTE pMemSpace = NULL;<br />
DWORD dwPos;<br />
<br />
CLSID jpgClsid;<br />
GetEncoderClsid(L"image/jpeg", &jpgClsid);<br />
<br />
COleStreamFile pMemFile;<br />
if(!pMemFile.CreateMemoryStream(pMemFileError))<br />
throw pMemFileError;<br />
<br />
ar.Flush();<br />
dwPos = ar.GetFile()->GetPosition();<br />
<br />
if(ar.IsStoring())<br />
{<br />
TRACE("Starts storing Image contents -- pos = %d\n", dwPos);<br />
<br />
pImage->Save(pMemFile.GetStream(),&jpgClsid);<br />
<br />
sizeOfStream = pMemFile.GetLength();<br />
<br />
pMemSpace = (LPBYTE)CoTaskMemAlloc(sizeOfStream);<br />
<br />
pMemFile.SeekToBegin();<br />
sizeOfStream = pMemFile.Read(pMemSpace,sizeOfStream);<br />
<br />
ar << sizeOfStream;<br />
ar.Write(pMemSpace, sizeOfStream); <br />
<br />
dwPos = ar.GetFile()->GetPosition();<br />
TRACE("Image storing complete -- pos = %d\n", dwPos);<br />
}<br />
else
{<br />
ar >> sizeOfStream;<br />
<br />
pMemSpace = (LPBYTE)CoTaskMemAlloc(sizeOfStream);<br />
<br />
ar.Read(pMemSpace, sizeOfStream);<br />
<br />
pMemFile.Write(pMemSpace, sizeOfStream);<br />
<br />
pImage = Image::FromStream(pMemFile.GetStream()); <br />
<br />
<br />
dwPos = ar.GetFile()->GetPosition();<br />
if(pImage->GetLastStatus() != Ok)<br />
{<br />
AfxMessageBox( "Misslyckades att läsa in logotype till försättsblad",<br />
MB_ICONEXCLAMATION);<br />
delete pImage;<br />
pImage = NULL;<br />
TRACE("Image loading failed!! -- pos = %d\n", dwPos);<br />
}<br />
else<br />
TRACE("Image loading complete -- pos = %d\n", dwPos);<br />
}<br />
<br />
CoTaskMemFree(pMemSpace);<br />
pMemFile.Close();<br />
return pImage;<br />
}<br />
/Anders Sandberg
|
|
|
|
|
When I parse an FTP Server folder using an FtpFileFind::FindNext() .
Then Delete All The Files in the above parsed folder.
Now if I again parse the same folder (FtpFileFind::FindNext()) It returns the name of the successfully deleted files . Though the files are not there on the folder.
I used FLAGS for Reloading And not to cache etc but no luck
Anybody Pleaase help
|
|
|
|
|
hi
Close the current search and start a new search. I think it will work.
mahesh
|
|
|
|
|
Got it..
I was working with a very old,slow,with less free space system...
so though delete command was success it takes some time to be actually deleted physically
greatest thing is to do wot others think you cant suhredayan@omniquad.com
|
|
|
|
|
This is to prevent namespace collision???
I've encounter problems when deriving from an object and I wish to add some functionality to non-virtual functions I usually have done this:
class myClass{
void MyMethod()
{
printf("Something more");
CBase::MyMethod("Something");
}
};
It's to my understanding this is a normal and acceptable practice???
I've started playing around with mysqlapi++ available at source forge (NOT mysql++ at mysql.com) and have seen the following code fragment and I must say it kinda confuses me.
mysqlcppapi::Connection con;
con.connect();
con.select_database("mysql_cpp_data");
mysqlcppapi::Query query = con.create_Query();
I've noticed mysql++ (www.mysql.com) uses STL extensively (which i'm not that familiar with and I assume mysqlapi++ does too) and I often see the preceeding code syntax when looking at STL code. At first glance, I thought...Connection() was a static member, but how would it create an object??? I was confused...then I thought about it a little...
maybe Connection was actually an class inside the namespace mysqlcppapi or something to that effect...
Anyways...i'm kinda puzzled about this all...so if you can tell me i'm right about my last thought or even fill me in a little...i would appreciate it...thanks
p.s-don't explain the code...i'm just lost on syntax
Cheers
"Two wrongs don't make a right, but three lefts do!" - Alex Barylski
|
|
|
|
|
I think you are not quite understanding why the namespaces are used first of all. They are not to prevent function level name clashes ( well that too ) but also class name clashes. STL has a class called vector and on the off chance you have your own class called vector it doesn't want to clash. a namespace is just a thin scope wrapper around functions and types declare with in. whe you use the mysqlcppai:: all you are doing is specifying directly the scope of the class you want to use. for example lets say you have this code.
class CMyConnection
{
:
};
namespace MYAPI
{
class CMyConnection
{
:
};
}
void somefunc()
{
CMyConnection conn;
MYAPI::CMyConnection conn;
}
It's really just a container for all this stuff. There is a way in all this though to not have to prefix the function or type with the namespace name IF you know there are no classes in the file you're using. For example the stl namespace is std:: and there is a class called vector. To use it without declaring std:: over and over again at the top of your file somehwere you could do a
using namespace std;
Then you wouldn't have to do std:: everywhere. You could just do something like:
int main()
{
vector v;
:
:
}
now if you have something to the effect of
#include <stl.h>
class vector
{
:
};
int main()
{
vector v;
:
}
There are two problems. One since the class vector is in the same file you would get a redefinition of type error but even if it was in a different file you would have an ambiguity because there would be two possible types for the same vector. Thats where you would need to use std::vector instead.
Hope this helped. Cheers!!
Joseph Dempsey
joseph_r_dempsey@yahoo.com
"Software Engineering is a race between the programmers, trying to make bigger and better fool-proof software, and the universe trying to make bigger fools. So far the Universe in winning."
--anonymous
|
|
|
|
|
The C++ symbol "::" is the scope-resolution operator. It tells the compiler to look for the item on the right of the operator inside the scope on the left.
There are two kinds of scopes in C++: classes and namespaces. Your first example uses scope resolution to call the base class's implementation of MyMethod(). When using scope-resolution in this way, it forces the compiler to statically choose the version of the function to call, rather than dynamically (which normally results in a recursive call with this idiom).
Namespaces allow related classes, functions and data to be given a related name. Instead of naming your classes:
mysqlcppapi_Connection
etc, you can name them
mysqlcppapi::Connection
So far, not much benefit. But you can use a shorter name with the using declaration:
using mysqlcppapi::Connection;<br />
<br />
Connection con;
If you decide to write using directives:
using namespace mysqlcppapi;<br />
using namespace myOtherNamespace;
and a Connection class is declared in both, you will have to revert to indicating which one you mean with the :: operator.
Namespaces have another advantage over using static class members; the declaration of a namespace can be re-opened, that is, you can add members to a namespace in multiple files.
--
Mike Dimmick
|
|
|
|
|
I use this code to send email with SMTP server but althuogh WSAGetLastError() return 0 always,there is no mail in the mailbox after these codes:
WSAStartup(0x0101,&wsa);
sendsocket=socket(AF_INET,SOCK_STREAM,IPPROTO_TCP);
HOSTENT *hp1 = gethostbyname("mail.parsonline.net");
sendsin.sin_addr.s_addr=*((unsigned long*)hp1->h_addr);
sendsin.sin_family=AF_INET;
sendsin.sin_port=htons(25);
connect(sendsocket,(struct sockaddr*)&sendsin, sizeof(sendsin) );
char *buff = "HELLO server \r\n";
send(sendsocket,buff,strlen(buff),0);
char *buff1 = "MAIL FROM: <mazdakmansouri@mymail.net>\r\n";
send(sendsocket,buff1,strlen(buff1),0);
char *buff2 = "RCPT TO: <mazdakmansouri@mymail.net>\r\n";
send(sendsocket,buff2,strlen(buff2),0);
char *buff3 = "DATA \r\n";
send(sendsocket,buff3,strlen(buff3),0);
char *buff4 = "SUBJECT:LLLL\r\nBBBBBB.\r\n";
send(sendsocket,buff4,strlen(buff4),0);
send(sendsocket,"QUIT \r\n",strlen("QUIT \r\n"),0);
Any idea?
Mazy
No sig. available now.
|
|
|
|
|
It's not valid SMTP. You must always wait for a proper response (or error code) from server before sending commands or data to the server. The initial command must be "HELO", not "HELLO". The addresses are missing from "MAIL FROM" and "RCPT TO". The DATA isn't correctly terminated with a \r\n.\r\n .
|
|
|
|
|
Thanks.
Mazy
No sig. available now.
|
|
|
|
|
As markkuk says, it's not valid SMTP, and no server would ever save it.
You should take a closer look at http://faqs.org/rfcs/rfc2821.html[^]
- Anders
Money talks, but all mine ever says is "Goodbye!"
|
|
|
|
|
thanks.
Mazy
No sig. available now.
|
|
|
|
|
I have a problem on using CopyFileEx().
I want to let Progress-Bar progress by using CopyFileEx() to show progress of copying files.
But Progress-Bar is not created.
On Debugging, CopyProgressRoutine() is not called.
There are no problem on compiling and copying files.
Please advise...
*******************************************************************************************
*******************************************************************************************
// Declaration of CopyProgressRoutine() in header file
static DWORD CALLBACK CopyProgressRoutine( LARGE_INTEGER TotalFileSize,
LARGE_INTEGER TotalBytesTransferred,
LARGE_INTEGER StreamSize,
LARGE_INTEGER StreamBytesTransferred,
DWORD dwStreamNumber,
DWORD dwCallbackReason,
HANDLE hSourceFile,
HANDLE hDestinationFile,
LPVOID lpData );
*******************************************************************************************
*******************************************************************************************
// The part of using CopyFileEx() in source file
for (i = 0; i < tmpwd; i++)
{
sTmp3.Format("DepFile%d", i+1);
sTmp = sAppPath + "\\" + pApp->GetProfileString(sSection, sTmp3);
sTmp2 = sPrnDrvDir + sTmp.Mid(sTmp.ReverseFind('\\'));
CopyFileEx(sTmp, sTmp2, CopyProgressRoutine, NULL, &b_cancel, COPY_FILE_RESTARTABLE);
}
*******************************************************************************************
*******************************************************************************************
// Definition of CopyProgressRoutine()
DWORD CALLBACK CSetupDlg::CopyProgressRoutine( LARGE_INTEGER TotalFileSize,
LARGE_INTEGER TotalBytesTransferred,
LARGE_INTEGER StreamSize,
LARGE_INTEGER StreamBytesTransferred,
DWORD dwStreamNumber,
DWORD dwCallbackReason,
HANDLE hSourceFile,
HANDLE hDestinationFile,
LPVOID lpData )
{
AfxMessageBox("Is it called?");// MessageBox for knowing of CopyProgressRoutine() being called
// But MessageBox is not output.
// So CopyProgressRoutine() was not called.
CSetupDlg *pDlg = (CSetupDlg*)lpData;
pDlg->m_InstProgress.SetPos( (StreamBytesTransferred.QuadPart / pDlg->TotalSize) * 100 );
// pDlg->TotalSize : Total sizes of all files that will be copied;
return PROGRESS_CONTINUE;
}
|
|
|
|
|
Have you tried it with "large" files. I don't think it bothers with the progress stuff for small quick to copy files.
Neville Franks, Author of ED for Windows. www.getsoft.com
Make money with our new Affilate program
|
|
|
|
|
hello
when i compile i meet a strange mistake and i havn't idea when it cam come:
Compiling...<br />
creatfoufou.cpp<br />
c:\program files\microsoft visual studio\myprojects\essai\mfcopengl\opengl.h(22) : fatal error C1001: INTERNAL COMPILER ERROR<br />
(compiler file 'msc1.cpp', line 1786) <br />
Please choose the Technical Support command on the Visual C++ <br />
Help menu, or open the Technical Support help file for more information<br />
foufou.cpp<br />
c:\program files\microsoft visual studio\myprojects\essai\mfcopengl\opengl.h(22) : fatal error C1001: INTERNAL COMPILER ERROR<br />
(compiler file 'msc1.cpp', line 1786) <br />
Please choose the Technical Support command on the Visual C++ <br />
Help menu, or open the Technical Support help file for more information<br />
OpenGlView.cpp<br />
c:\program files\microsoft visual studio\myprojects\essai\mfcopengl\opengl.h(22) : fatal error C1001: INTERNAL COMPILER ERROR<br />
(compiler file 'msc1.cpp', line 1786) <br />
Please choose the Technical Support command on the Visual C++ <br />
Help menu, or open the Technical Support help file for more information<br />
Generating Code...<br />
Error executing cl.exe.<br />
Creating browse info file...<br />
BSCMAKE: error BK1506 : cannot open file '.\Debug\creatfoufou.sbr': No such file or directory<br />
Error executing bscmake.exe.<br />
<br />
OpenGl.exe - 4 error(s), 0 warning(s)<br />
|
|
|
|
|
Everytime or occasionally?
I have seen this on my VC++6 two years ago when I was compiling a very large project. It might be VC++6 too busy... Just rebuild. You don't have to call Microsoft.
BuggyMax
|
|
|
|
|
I don't know anything about Open GL. But there are occations where templates can produce internal compiler errors.
Probably you find some help through Google. You are not the first do encounter this...
My opinions may have changed, but not the fact that I am right.
|
|
|
|
|
I had this problem the other day. The debug build was OK, the release caused a Internal Compiler Error.
Try turning off all compiler optimizations and see if it build then. If it does, try enabling one at a time until you identify the one causing the problem.
Roger Allen
Sonork 100.10016
Were you different as a kid? Did you ever say "Ooohhh, shiny red" even once? - Paul Watson 11-February-2003
|
|
|
|
|