|
Stuart Dootson wrote: Oh, your code compiles fine with gcc. I tried that pretty much first, as I suspected a VC++-specific issue.
That's good So maybe I should start my next question... How can I REPLACE the VC++ compiler with the gcc counterparts within the VS IDE? I want to fully use the gcc toolchain and not the MS compiler, linker etc.
So is it possible to fully replace the tools and still get errors, warnings etc. in the VS IDE ( the message text is of course then coming from the gcc counterparts)? Also debugging should still be possible in the VS IDE. This would be really great! Any hints? Thanks
|
|
|
|
|
That's not so do-able The VS IDE wouldn't correctly parse errors coming out of gcc, as they're different formats, and also the gcc debug format is completely different than the VC++ one - neither WInDbg nor Visual Studio can debug code produced by gcc. Also, I don't think you can build against MS libraries like MFC and ATL with gcc.
Alternatives? Eclipse CDT[^] and Dev-C++[^] are both IDEs using gcc. Also, I believe the Intel C++ compiler can be used as a drop-in replacement for MSVC, but that costs money
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
The need to compile wav files into a Doc/View plus modeless dialog MFC program led to abandoning a functioning mechanism to play random wav files:
PlaySound("m_sStrConcatenatedStringWithPath",NULL,SND_FILENAME|SND_SYNC);
(where sStrConcatenatedStringWithPath = “/path/201.wav” etc.)
and adopting:
LPTSTR pRandomSound = m_sStrConcatenatedStringResource.GetBuffer(0);
PlaySound(MAKEINTRESOURCE, pRandomSound, GetModuleHandle(NULL), SND_SYNC|SND_RESOURCE);
m_sStrConcatenatedStringResource.ReleaseBuffer(0);
(where m_sStrConcatenatedStringResource = “IDR_WAVE_201” etc.).
...that fails to play the wav files even when...
PlaySound(MAKEINTRESOURCE, IDR_WAVE_201, GetModuleHandle(NULL), SND_SYNC|SND_RESOURCE);
will play the IDR_WAVE_201 resource.
Many attempts experimenting different ways to cast the CString to the LPTSTR and obtaining the handle to the executable led to the code above, which still will not play the random sound resource.
Suggestions?
"For a successful technology, reality must take precedence over public relations, for nature cannot be fooled." Richard Feynman, Minority Report to the Official Report on the Space Shuttle Challenger Crash
|
|
|
|
|
lctrncs wrote: PlaySound(MAKEINTRESOURCE, pRandomSound, GetModuleHandle(NULL), SND_SYNC|SND_RESOURCE);
What PlaySound() are you using that takes four arguments?
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
|
|
|
|
|
Thank you for responding.
BOOL PlaySound(
LPCSTR pszSound,
HMODULE fdwSound,
DWORD fdwSound)
There are two arguments:
LPCSTR (pszSound) and HMODULE (fdwSound)
pRandomSound and GetModuleHandle(NULL)
and two flags:
DWORD fdwSound
SND_SYNC|SND_RESOURCE
Thanks again. I hope this answers your question.
"For a successful technology, reality must take precedence over public relations, for nature cannot be fooled." Richard Feynman, Minority Report to the Official Report on the Space Shuttle Challenger Crash
|
|
|
|
|
lctrncs wrote: BOOL PlaySound(
LPCSTR pszSound,
HMODULE fdwSound,
DWORD fdwSound)
There are two arguments:
LPCSTR (pszSound) and HMODULE (fdwSound)
pRandomSound and GetModuleHandle(NULL)
and two flags:
DWORD fdwSound
SND_SYNC|SND_RESOURCE
You seem to be confused. Look at the code snippet in your original post. You are passing PlaySound() four arguments: 1) MAKEINTRESOURCE , 2) pRandomSound , 3) GetModuleHandle(NULL) , and 4) SND_SYNC|SND_RESOURCE .
So my question still remains: where does this four-argument function come from? The answer to this may end up having no bearing on the actual problem, but if you can't post a working code snippet, it's kind of hard to come up with a useful answer.
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
|
|
|
|
|
The
BOOL PlaySound(
LPCSTR pszSound,
HMODULE fdwSound,
DWORD fdwSound)
comes from the "Multimedia: Platform SDK" section of the Visual C++ 6.0 MSDEV documentation.
This specific use of the MAKEINTRESOURCE macro is documented in the "Technical Articles" section of the Visual C++ 6.0 MSDEV documentation in a file called "Moving Your Game to Windows, Part III.
Does this answer you question?
"For a successful technology, reality must take precedence over public relations, for nature cannot be fooled." Richard Feynman, Minority Report to the Official Report on the Space Shuttle Challenger Crash
|
|
|
|
|
When You add WAV resource by ID there is no way to call PlaySound (and other resource functions) by resource name and vice versa - when you add resource with resource name string - You can not access resource by it' ID.
For this resource script file:
#define SOUND_1
...
SOUND_1 WAV "snd1.wav"
"MOO" WAV "moo.wav"
Valid PlaySound call is:
PlaySound(MAKEINTRESOURCE(SOUND_1), ...);
PlaySound("MOO", ...);
|
|
|
|
|
Thanks to everyone at CodeProject!
It appears that the original post may not be clear.
Therefore, consider the following code snippet which includes much more information about the problem and the (failed) attemtps to resolve it.
Again, for reasons this beginner has yet to understand, PlaySound works fine with a filename constructed from a CString and a random number (/path/filename1.wav), but fails when concatenated CStrings are used to create a resouce identifier (IDR_WAVE_1).
Please consider the code and coments below.
int m_nRandomSound;
m_nRandomSound = getrandom( 500, 509 );
CString m_sStrRandomSound;
m_sStrRandomSound = "";
CString m_sStrRandomResourcePrefix;
m_sStrRandomResourcePrefix = "IDR_WAVE_";
m_sStrRandomSound.Format("%d", m_nRandomSound);
CString m_sStrRandomResourcePrefixWav;
m_sStrRandomResourcePrefixWav = m_sStrRandomResourcePrefix + m_sStrRandomSound;
CString m_sStrRandomResourcePrefixWav2;
m_sStrRandomResourcePrefixWav2="IDR_WAVE_503";
PlaySound(m_sStrRandomSoundPathWav, GetModuleHandle(NULL), SND_FILENAME|SND_SYNC );
PlaySound(MAKEINTRESOURCE(IDR_WAVE_503), GetModuleHandle(NULL), SND_SYNC|SND_RESOURCE );
PlaySound(m_sStrRandomResourcePrefixWav2, GetModuleHandle(NULL), SND_SYNC|SND_RESOURCE );
PlaySound("m_sStrRandomResourcePrefixWav", GetModuleHandle(NULL), SND_SYNC|SND_RESOURCE );
LPCTSTR pRandomSound = m_sStrRandomResourcePrefixWav.GetBuffer(0);
LPCTSTR pRandomSound2 = m_sStrRandomResourcePrefixWav2.GetBuffer(0);
PlaySound(MAKEINTRESOURCE(pRandomSound2), GetModuleHandle(NULL), SND_SYNC|SND_RESOURCE );
PlaySound(MAKEINTRESOURCE(pRandomSound), AfxGetResourceHandle(), SND_SYNC|SND_RESOURCE );
PlayWav(pRandomSound);
m_sStrRandomResourcePrefixWav.ReleaseBuffer();
m_sStrRandomResourcePrefixWav2.ReleaseBuffer();
Thank you again.
Your comments and suggestions are greatly appreciated.
"For a successful technology, reality must take precedence over public relations, for nature cannot be fooled." Richard Feynman, Minority Report to the Official Report on the Space Shuttle Challenger Crash
|
|
|
|
|
Hi All
How to create detailed log.txt file in C programming.
As of now am using
fp=fopen("log.txt","a");
fprintf(fp, "Input string = %s\n", Work);
But i want to write log file with much details which is help me to debug.Please gimme me if any prebuild code or related link.
Thanks,
Mohan.T
Mohan t working for N.I.C
|
|
|
|
|
You can use of WriteFile .
Of one Essence is the human race
thus has Creation put the base
One Limb impacted is sufficient
For all Others to feel the Mace
(Saadi )
|
|
|
|
|
In C (assuming you are really programming in pure C), you will probably not find that much code for that (I tried a few google, and found nothing usefull)
But it should be quite simple to do.
Declare a few global functions that will open the file write to the file, close the file...
What you put in the file is really up to you; no tool will completly do what you want.
If you are looking for C++ code there are some example here, on CP (for example :
Advanced Logging for all kind of applications[^] )
This signature was proudly tested on animals.
|
|
|
|
|
mohant$.net wrote: fprintf(fp, "Input string = %s\n", Work);
But i want to write log file with much details which is help me to debug.Please gimme me if any prebuild code or related link.
So why can't you add more fprintf() calls, or add more arguments to the one you are already using?
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
|
|
|
|
|
|
I have a CRichEditCtrl derived object which resizes itself whenever the size of text inside it exceeds the control size. This control is a child of CWnd derived object and I am resizing using MoveWindow. THe problem is whenever I resize the window, cursor stops blinking. i can still type the text and it is displayed in the control but the cursor remains static and does not blink.
what can be the reason for this? I tried forcing SetCapture in PreTranslateMessage but nothing seems to work.
|
|
|
|
|
Maybe try moving the cursor with CRichEditCtrl::SetSel[^] (you could use GetSel to determine where the cursor should be maybe)
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
> Life: great graphics, but the gameplay sux. <
|
|
|
|
|
After two disappointing days, the problem was found to be with parent window CWnd object. making rich edit control a child of cdialog works correctly.
anyway, thanks for the reply.
|
|
|
|
|
Hi all,
I m using CFile to open any text file,i want to detect that the selected file is readonly or not.
please tell me how can i chk the selected file is readonly or not.
thanks in advance.
To accomplish great things, we must not only act, but also dream;
not only plan, but also believe.
|
|
|
|
|
|
CFileStatus status;
if( CFile::GetStatus( OpenFile, status ) )
{
if(status.m_attribute==0x01)
AfxMessageBox(_T("readOnly"));
}
but the messagebox not displayed.or when i debug the code in place of status.m_attribute the '!' display.
To accomplish great things, we must not only act, but also dream;
not only plan, but also believe.
|
|
|
|
|
You have to put a mask on the attribute byte to check the read only bit:
if (status.m_attribute & 0x01)
|
|
|
|
|
"_$h@nky_" wrote: if(status.m_attribute==0x01)
It should read
if(status.m_attribute & 0x01)
m_attribute is a bit field which can contain more than one bit setting; check the documentation for the significance of the other bits.
|
|
|
|
|
Thanks
To accomplish great things, we must not only act, but also dream;
not only plan, but also believe.
|
|
|
|
|
I want to associate an extension to my MFC application - I know I can call RegisterShellFileType which will do some of that. My problem is that for a given extension, I do not want to start a new instance of my application... I'd like the current instance (ideally all instances but let's not get there right away) to be notified that they need to read the file.
If you're wondering why I want this : let me explain. I have this SDI application that creates documents (for lack of a better word). I want the users to be able to download some plugins (with the remarkable extension) from the wwww- and when they open the file from their browser, I want those plugins to be installed... I hope I am making sense!
Thanks in advance!
|
|
|
|
|
You would need to configure this into the browser so it recognises the file type and passes that file to the relevant application.
|
|
|
|