|
I'm pretty much a complete newbie to the programming scene. I can't for the life of me work out how to play a wave file. Preferably during the startup of the application but even if it was on the press of a button. I have read about the PlaySound and DirectSound classes/functions (whatever they are) but cannot get them to work. Also i have come across what looks like a really good class (cSound) for download on this website but apparently it doesnt work in Windows XP, and i cant get that to work either. I need to know everything i would need to do (initialisation and all that) coz im completely lost and this is getting very frustrating. even a link to a class i can use or step by step tutorial would be a big help.
o and im using VC++.net
Cheers
jace
|
|
|
|
|
Whether you beleive or not it is really as easy to play a wave file from your app as writing the following:
sndPlaySound("c:\\yourwavetoplay.wav",SND_ASYNC);
Put it into your OnInitDialog override to play it on application startup.
However, in order to use it, you have to add the windows multimedia library to your project
So, BEFORE you call the above line, add to your code:
#include "mmsystem.h"
#pragma comment(lib,"Winmm.lib")
Peter Molnar
|
|
|
|
|
does anyone know the code for a calculator like the one microsoft uses in the accessories file I am interested in how they get the plus and equal buttons to add the values using only one edit box.
thanks JKohm
|
|
|
|
|
They use a spare variable in addition to the display, and also an operation variable (i.e. three variables). By clicking on an operation button (+,-,*,/) the contents of the display are put into the spare variable, and the the button is stored in the operation variable.
The equal sign calculates: spare variable OPERAND display, where OPERAND is the operation variable.
Peter Molnar
|
|
|
|
|
I haved binded the MSHFlexGrid with a recordset, and now I want the result that if I scroll the mouse wheel, the record showed in the MSHFlexGrid would scroll(like the effect as we scroll the mouse wheel while we read a web page,the scrollbar move up or down);I have coded below:
BOOL Class::OnMouseWheel(UINT nFlags, short zDelta, CPoint pt)
{
// TODO: Make the mouse wheel take the MSHFlexGrid scroll
this->m_cHFlexGridPerform.SetScrollTrack(true);
//Would u tell me how can I make it work please
return CFormView::OnMouseWheel(nFlags, zDelta, pt);
}
thank you in advance;
|
|
|
|
|
//code
Bitmap *bmp;
bmp=Bitmap::FromHICON(imglist.ExtractIcon(0));
grapics->DrawImage(bmp,x1,y1,x2,y2);
//imagelist is globe variable
Upwards code,Memory leak out,why?
|
|
|
|
|
Bitmap *bmp; is a pointer to a bitmap ... u havnt allocated any memory for the actual bitmap
"there is no spoon" biz stuff about me
|
|
|
|
|
Wrong with imglist.ExtractIcon(0)?
|
|
|
|
|
In MFC for VC++ 6.0, how can I get information about the processor on the current computer such as the name and speed of the processor? How can I find out how much RAM the computer has and how much disk space is available on the primary drive?
|
|
|
|
|
|
Thank you! I can understand how to use those functions but how would I access the data in
HKEY_LOCAL_MACHINE\HARDWARE\DESCRIPTION\System\CentralProcessor ?
|
|
|
|
|
That's just a regular registry key. If you haven't used the registry before, there are many articles here on CP on the registry and wrapper classes for reading it.
--Mike--
Ericahist | CP SearchBar v2.0.2 | Homepage | RightClick-Encrypt | 1ClickPicGrabber
"That probably would've sounded more commanding if I wasn't wearing my yummy sushi pajamas."
-- Buffy
|
|
|
|
|
|
I need to get the titles of the history list of a running web browser control.The IE browser can Show the titles of visited web pages in it's drop-down buttons like "Back" and "Forward".How can I do that just like IE?
|
|
|
|
|
You cannot, because the IWebBrowser2 interface does not allow you to do this.
The only thing you can do is navigating the webbrowser to the last or next item:
CComQIPtr<IWebBrowser2> pBrowser(pView->GetHtmlDocument());
pBrowser->GoBack();
pBrowser->GoForward();
If you want the same with IE, then first create an interface IShellWindows, find a connection point to DShellWindowsEvents, after which you enumerate all open shell windows. If the specified shell window supports (i.e. can succesfully be QueryInterface-d for) IWebBrowser2 then you have valid pointer.
Peter Molnar
|
|
|
|
|
i am a collegestudent in China,i does a hard work to learn vc++ well,now I encountered cwindowdc but i have no ideas about it ,please give me some detail device or example ,thanks alot!
besides,i want to know how to learn vc++ very well.
|
|
|
|
|
Hi,
I need to implement Undo/Redo feature in a simple Notepad application. Is this task involve SaveDC() and RestoreDC() APIs??
Note: Solution should only be in Win32 APIs. No MFC please. (It is the requirement.)
|
|
|
|
|
ummmmm think about it for a minute
savedc() etc is dealing with the device context u have drawn into ... ie, a grafics surface in effect
this has NOTHING to do with the text u are displaying which should come from ur document in the doc / view model
when a user makes an edit to the document u need to save the changes to the doc data and be able to restore / remove those changes
"there is no spoon" biz stuff about me
|
|
|
|
|
i need a function the removes a char array from another. here is the description:
textString = new char[ strlen(ptr) + 1 ]
void remove(int startPos, int numToRemove);
// Removes the indicated number of characters from the text,
// starting at the indicated position. This involves allocating
// a new (smaller) array and copying characters from the original
// array into it, not including the ones to be removed.
the remove function removes characters from the array given an int staring position and an into number to remove
for example:
char* textString[] = "I like stinky cheese";
remove(7,7);
cout<<textString;
would yield: "I like cheese"
|
|
|
|
|
We are not here to do your homework. Shows us what you have done so far and then we might be able to help you.
|
|
|
|
|
ive been working on this forever. this is all i came up with:
void text::remove(int startPos, int numToRemove) {
char* temp = new char[strlen(textString) - numToRemove];
for (int i = 0; i <strlen(textString); i++) {
if (i != startPos) {
temp[i] = textString[i];
}
else {
i += (numToRemove -1);
}
}
textString = temp;
}
it doesnt work though. it seems to remove everything after startPos regardless of numToRemove
|
|
|
|
|
nevermind. i got it. this code seems to work:
void text::remove(int startPos, int numToRemove) {
char* temp = new char[strlen(textString) - numToRemove];
for (int i = 0; i <strlen(textString); i++) {
if (i < startPos) {
temp[i] = textString[i];
}
else if (i>startPos) {
temp[i-numToRemove] = textString[i];
}
else {
i += (numToRemove -1);
}
}
textString = temp;
}
|
|
|
|
|
Don't forget to delete temp !
Rickard Andersson
Here is my card, contact me later!
UIN: 50302279
Sonork: 37318
|
|
|
|
|
I am creating a dialog-based application using C++, MFC.
This application will need to open a socket and retrieve
data from a socket, assign it to a buffer and need to process
the buffer after that.
The application is working fine but while it is retrieving
the data and processing on it, the GUI seems "hang" and not
responsive!. So I wanted to create a worker thread to taking
care of the retrieving and processing the data, but I am not
familiar much with thread.
So do you have any simple window applications/samples that creates a
worker thread that is taking care of the processing part while
the GUI is still "active", responsive to user's action?
Currently, I have a wrapper class derived from CAsynSocket that
takes care of connecting and getting the data buffer from the
socket. Then when I have a complete data buffer, I notify the
dialog using a callback function.
So in the main dialog, I have:
CMainDialog::OnReceiveCompleteMessage( BYTE * pbData, int len)
And this method will be called everytime there is a new complete
data buffer. I have to process these messages so within this
method, I call "ProcessingMessage()". It works OK so far but
after it is running for while, if I bring up some other applications,
and then click on the icon to bring this dialog back up, it seems
"freeze" for awhile, and takes some time to refresh and display
the whole dialog..
So I want to create worker thread so that everytime the
OnReceiveCompleteMessage() is called, this thread will do the
processing part background and the GUI is still "active". Is it
OK if within the OnReceiveCompleteMessage(), I have the code:
m_hRunThread = ::CreateThread(NULL, 0, RunThreadFunc,
(LPVOID) this, 0, &dwThreadId);
so that each time the function is called, it will create a new
thread to do the processing (with same m_hRunThread handle but
different dwThreadId)? Within the RunThreadFunc(), I call the
ProcessingMessage().
I tried but it didn't work. So please help!
Thanks a lot!!!
TQD
|
|
|
|
|
tqdo wrote:
The application is working fine but while it is retrieving
the data and processing on it, the GUI seems "hang"
tqdo wrote:
Currently, I have a wrapper class derived from CAsynSocket that
takes care of connecting and getting the data buffer from the
socket.
The two statements contradict each other. CAsyncSocket is used asynchronously, that is in a non blocking manner. No hanging should be possible then.
If you decided to use multiple threads I would recommend you to use syncronous socket - just as you describe- in your worker thread.
Worker threads are really easy to use:
1. Create a global function wich will execute your communication task (if you insist on using dialog member functions for this purpose then create a static member of your dialog)
2. From your dialog call AfxBeginThread which will launch your worker thread (i.e. the function from 1./
3.AfxBeginThread returns immediately after you called it so your app reserves responsiveness
while your worker thread "works".
Peter Molnar
|
|
|
|