|
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.
|
|
|
|
|
I respectfully disagree - it should be an Explorer settings - the browser simply asking if you want to save or open the file...
|
|
|
|
|
BadJerry wrote: I respectfully disagree - it should be an Explorer settings - the browser simply asking if you want to save or open the file...
Sorry, but your original question was not clear.
You mention associating a file type with your application, then talk about downloading files and sending them to your application. Could you clarify exactly how you expect this process to operate, including the interaction (or interdependency) between your application and the browser?
|
|
|
|
|
As I see it, you have two issues...
1/ You want a website, with files of some custome format (call it fwibble.badjerry). In the same way as a (eg) pdf, the browser will run an external application - badjerry.exe, or acrobatreader.exe.
2/ You only ever want one of these programs running, even if they click on multiple files.
I hope that's a reasonable summary.
1/ Is a non issue - use RegisterShellFileType as normal. Whether the file comes from a website, via a temp directory, or it comes from the users My Dcuments directory is irrelevant.
2/ Is marginally harder, but there are several erticles on codeproject dealing with single instance applications, and their headaches. An article I've recently used to good effect was:
Limiting an application to a single Instance - the MFC way[^].
I did find a bug with huge impact but a simple fix - look at my comment at the end of the article. Other than that, it was a joy to use. Just a daft error.
Enjoy,
Iain.
I have now moved to Sweden for love (awwww).
If you're in Scandinavia and want an MVP on the payroll (or happy with a remote worker), or need cotract work done, give me a job! http://cv.imcsoft.co.uk/[ ^]
|
|
|
|
|
It's not exactly what I want : the badjerry.exe is not single instance - it can open many .pdf or .doc files but if it tries to open a .badjerry the exisiting instance should be used.
But you gave me an idea of how I could implement this - I could associate the .badjerry extension to another single instance program which will then relay the information to the other instances... or start one if there isn't... it's a bit long-winded but... hey...
Thanks for your help!
|
|
|
|
|
OK, I'm confused. Unless badjerry.exe is a browser in its own right, it as no business opening pdf files... (I assume it's not a pdf viewer).
And if it only handles .badjerry's, then the article I gave you a link to handles that - if a 2nd instance opens, it communicated with the first, to get the first one to open the desired file, then close the 2nd one.
Iain.
I have now moved to Sweden for love (awwww).
If you're in Scandinavia and want an MVP on the payroll (or happy with a remote worker), or need cotract work done, give me a job! http://cv.imcsoft.co.uk/[ ^]
|
|
|
|
|
Iain Clarke, Warrior Programmer wrote: 2/ Is marginally harder, but there are several erticles on codeproject dealing with single instance applications, and their headaches. An article I've recently used to good effect was:
Limiting an application to a single Instance - the MFC way[^].
The procedure from that article seems awfully complicated. I always use this code in InitInstance (if it's a MFC app, otherwise WinMain):
CreateMutex(NULL, TRUE, _T("Unique_String_Identifying_The_Application"));
if (GetLastError() == ERROR_ALREADY_EXISTS)
{
return FALSE;
}
|
|
|
|
|
That's what I used to do to...
But that does nothing about running the previous (only) instance, let alone get the 1st instance to open any document that the 2nd instance had been... instantiated... to do.
Iain.
I have now moved to Sweden for love (awwww).
If you're in Scandinavia and want an MVP on the payroll (or happy with a remote worker), or need cotract work done, give me a job! http://cv.imcsoft.co.uk/[ ^]
|
|
|
|