Sign In

Close
Forgot your password? No account yet?

C++ Random Reference Sheet by oneandonly

C++ Random Reference Sheet
Visual C++ Random Reference Sheet
Note that this will be a constantly updated file while I learn new features.

Adding References (Untested)

1. Add the file you want to your source code folder. (Projects/<Project Name>/<Project Name>) Here we are going to add a Wave file to our project called "WELCOM98.WAV"
2. Open app.rc from the Resource Files (Right click, Open With, Source Code (Text) Editor)
3. We are going to add the line IDR_STARTUP WAVE "WELCOM98.WAV" to our project. I reccomend below your programs Icon, but that's optional. IDR_STARTUP is our resource name. Try to keep it something like IDR_RESOURCENAME or IDW_RESOURCENAME, WAVE is our resource type, and "WELCOME90.WAV" is our actual file name.
4. We are now going to open our resource.h file.
5. Append "#define IDR_STARTUP         2000" to the file. REMINDER: LEAVE A DAMN SPACE AT THE END OF THE FILE OR YOU WILL GET AN UNEXPECTED END OF FILE ERROR! 

IDR_STARTUP was that resource name, 2000 is the identifier. It can be anything, as long as it doesn't interfere with another resource.

(You're done. The following code is only for adding the wave file we used to your project.)

6. Open your application's source and include resource.h. #include <resource.h>
7. Also add the following code after that last include:
#include <windows.h>
#include <mmsystem.h> 
#pragma comment(lib, "winmm.lib")

8. Make a button in your application (unless you are making a console application)
9. Double click that icon and add the code:
PlaySound(MAKEINTRESOURCE(IDR_STARTUP),
        GetModuleHandle(NULL),SND_RESOURCE | SND_ASYNC);

PlaySound is a method of playing wave files
Notice that IDR_STARTUP? Yep, that's the resource we used. SND_RESOURCE | SND_ASYNC tells the program it is reading from a resource, and tells the sound to play with the program, so it doesn't lock up your application while it plays your sound.

10. Compile! Enjoy!

RESOURCES:
Sound File (Of nostalgia)
No source for you. If you want to learn, you're going to need to do it yourself.

More later.

C++ Random Reference Sheet

oneandonly

This will be updated often.

image description

Submission Information

Views:
730
Comments:
2
Favorites:
0
Rating:
General
Category:
Literary / Other

Tags

(No tags)

Comments