|
This is for the most part, the area of the program I am dealing with. The part that I am concerned with is the last function of UpdateVolumeSettings(). The rest seems to work correctly, as I am able to adjust the volume with the slider control.
Thanks for any help!
Mark Keeling
void CHalloweenView::OnInitialUpdate()
{
m_pSet = &GetDocument()->m_halloweenSet;
CRecordView::OnInitialUpdate();
GetParentFrame()->RecalcLayout();
ResizeParentToFit();
// Set the range of the volume control.
m_ctlVolume.SetRangeMax(100);
m_ctlVolume.SetRangeMin(0);
// Count the number of database entries.
CountDataBaseEntries();
// Connect to the PLC through RSLinx DDE, this is what triggers the sound to play.
StartPLCComms();
// Initialize the DirectSound Objects. And load all the sounds into buffers.
InitDirectSound();
// Update the volume settings for each sound.
UpdateVolumeSettings();
// Update the pan settings for each sound.
UpdatePanSettings();
// Initialize the record number for display.
m_nRecordNumber = 1;
m_strSoundNumber.Format("Sound 1 of %d", m_pSet->GetRecordCount());
// Load the data from the first record into the display.
RefreshDisplayValues();
// Create the timer used to trigger the sound effects from the PLC.
SetTimer(1, 500, NULL);
// Start the welcome sound (Sound #1) on card #1.
sound_fx[0][0].dsbuffer->Play(0,0,0);
UpdateData(FALSE);
}
void CHalloweenView::SetSoundVolume(int nSound, long lVolume)
{
// Loop once for each sound card detected.
for (int nIndex = 0; nIndex < nNumberOfSoundDevices; nIndex++)
{
// If the sound_fx buffer was created (ie. sound file exists).
if (sound_fx[nIndex][nSound].dsbuffer != NULL)
// Change the volume of the sound.
if (sound_fx[nIndex][nSound].dsbuffer->SetVolume(lVolume) != DS_OK)
MessageBox("Can not set volume!");
}
}
void CHalloweenView::OnReleasedcaptureSliderVolume(NMHDR* pNMHDR, LRESULT* pResult)
{
// TODO: Add your control notification handler code here
long lVolume;
// Return to the position in the database that the display is currently showing.
m_pSet->MoveFirst();
m_pSet->Move(m_nRecordNumber - 1);
// Save the changes to the database.
m_pSet->Edit();
m_pSet->m_Volume = m_ctlVolume.GetPos();
m_pSet->Update();
// Set the volume of the sound.
lVolume = m_pSet->m_Volume * 30 - 3000;
SetSoundVolume(m_nRecordNumber, lVolume);
*pResult = 0;
}
void CHalloweenView::UpdateVolumeSettings()
{
long lVolume = 0;
// Make sure to start at the first database record.
m_pSet->MoveFirst();
// Set the volume for each sound that was loaded from the database records.
for (int nSound = 1; nSound <= m_pSet->GetRecordCount(); nSound ++)
{
// Volume settings.
lVolume = m_pSet->m_Volume * 30 - 3000;
SetSoundVolume(nSound, lVolume);
// Move to the next databse entry,
m_pSet->MoveNext();
}
// Move back to the first database entry.
m_pSet->MoveFirst();
}
|
|
|
|
|
zwzcode wrote:
pRst->Fields->Item[0L]->Value=100L; //But it throw a excpetion here. I dont know the reason. If I alter the datatype of ID to CHAR(10) ,it is all right.
Well, the answer is obvious, isn't it ? The value needs to be a string.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
I am trying to put a button on the main window of a simple SDI project. The button appears ok but it doesn't respond to the mouse. I am declaring the button in the CMainFrame class and creating it in OnCreate (see below). The same code works fine for a dialog but not for the main window.
class CMainFrame : public CFrameWnd
{
...
CButton m_wndPushButton;
int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
...
m_wndPushButton.Create(_T("test"),WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON, rect, this, 1);
Any pointers would be appreciated.
Thanks,
Scott
|
|
|
|
|
shfinfrock wrote:
I am trying to put a button on the main window of a simple SDI project. The button appears ok but it doesn't respond to the mouse. I am declaring the button in the CMainFrame class and creating it in OnCreate (see below). The same code works fine for a dialog but not for the main window.
[...]
int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
...
m_wndPushButton.Create(_T("test"),WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON, rect, this, 1);
In an SDI app, you'll always have a CView covering the entire client area. You see the button in the screen, because the view is painted before the button. However, the button is actually behind the view in the z-order, so it's not receiving any mouse message.
If you add the WS_CLIPSIBLINGS style to the button, you won't even see it. If you add the following line after the button creation, you'll see it and it will start receiving (and reacting to) mouse messages:
m_wndPushButton.SetWindowPos(&wndTop, 0,0,0,0, SWP_NOMOVE | SWP_NOSIZE);
However, you should note this button will actually overlap with the view, obscuring some part of it. I'm not sure if that's what you want... Consider placing the button in a toolbar or dialog bar so that it doesn't overlap with the view.
--
jlr
http://jlamas.blogspot.com/[^]
|
|
|
|
|
hi!
how can i send a GET, POST request to a HTTPS server?
is it easy to do that with c# und System.Web Namespace?
do anybody know the cURL lib? http://curl.haxx.se/
ps.: i want to do that to do that as easy as possible!
cu+thx
|
|
|
|
|
Hello
You can try to make it using CHttpConnection with MFC. Or you can use API functions: WinHttpOpen , WinHttpConnect , WinHttpOpenRequest .
Andrew
|
|
|
|
|
hi, but can i use a socketlib instead? i need it for windows and linux!! i dont want to use OpenSSL because the docu ist bad!!
such a socket lib i search:
<br />
Socket *socket = new Socket();<br />
socket->connectSSL("google.com", 443);<br />
socket->sends("GET / HTTP/1.0\n\n");<br />
const char *response = socket->reads();<br />
cout << response;<br />
socket->close();<br />
cu+thx
|
|
|
|
|
The thread 0xE9C has exited with code 0 (0x0).
The thread 0x50C has exited with code -1073741819 (0xC0000005).
The program 'C:\Program Files\Microsoft Visual Studio\MyProjects\wordlist\Debug\wordlist.exe' has exited with code -1073741819 (0xC0000005).
can someone please tell me what that means i cant figure it out
|
|
|
|
|
I don't recognize 0xC0000005 as a Windows error code, but it is the number you see for an access violation exception. If that's the case, you've got a bad pointer value somewhere (using an uninitialized pointer, dereferencing NULL , using memory after it's freed, etc.).
Software Zen: delete this;
|
|
|
|
|
0xC0000005 is a windows error code!!!
To be precisely, it is an exception code (EXCEPTION_ACCESS_VIOLATION).
Don't try it, just do it!
|
|
|
|
|
Hey there.
Can someone provide me with a few examples of how to handle exceptions? Below is some code I used in an application. p->ShowWindow(SW_SHOW) is used to display a dialog containing an ActiveX Control. If the control is not registered I should get an exception, but it is not working. I must have something set up wrong. I have many places in my application where I need to do exception handling, thought I should start with this example.
Jerry
/////Not sure if I need these 2 lines of code???
#include <new>
using std::bad_alloc;
///////
try
{
p->ShowWindow(SW_SHOW);
}
catch(bad_alloc exception)
{
MessageBox("Data", "Memory Allocation Error", _OK);
}
//////
|
|
|
|
|
I left out: #include <new>
|
|
|
|
|
First off, you really should be catching exceptions by reference, as catching them by value will create two copies, instead of one.
That apart, IIRC, bad_alloc is thrown only when the new operator fails to allocate memory. AFAIK, the CRT that comes with VC++ doesn't do that, it instead returns NULL. Your code is most probably throwing some other exception. If you *really* want to catch all exceptions, your code should look like
try
{
...
}
catch(...)
{
}
This is not recommended though, I'd suggest figuring out the exact exception thrown and catching it.
Regards
Senthil
_____________________________
My Blog | My Articles | WinMacro
|
|
|
|
|
I tried catch(...), it didnt catch any exceptions either.
Something else must be wrong with the code.
Thanks,
Jerry
|
|
|
|
|
S. Senthil Kumar wrote:
bad_alloc is thrown only when the new operator fails to allocate memory. AFAIK, the CRT that comes with VC++ doesn't do that, it instead returns NULL.
It depends on compiler settings.
My programming blahblahblah blog. If you ever find anything useful here, please let me know to remove it.
|
|
|
|
|
hello,
just like we can tile the MDI child windows in our application can we write code for tiling the dialog boxes opened in parent dialog boxes?I thought of deriving our child dialog class from CFrameWnd.But then we have to tile them on clicking a menu option which then has to written in OnInitDialog() of CDialogDlgi.e the parent class.
please guide if i am proceeding in proper way?
thanks
|
|
|
|
|
|
Hi!
I am a college student.I wrote a filter demux the DVB-s mpeg-2 TS.Now it can render more than one audio streams But it can only render one video stream.It will be dead lock when rendering more than one video stream at the same time.
I dont know the reason.
I sincerely wait for the master's help!
please dont laugh at my poor english,I am a chinses student.
|
|
|
|
|
I have a question concerning your demultiplexer.
What kind of error corrections did you use?
I've also written a demux, but when there are many bitstream errors, the video and audio playback will get asynchron, although the media samples are all timestamped.
Now to your question:
You should trace where exactly the deadlock occurs (which filter, which routine...).
Don't try it, just do it!
|
|
|
|
|
Alexander:
I have no error correcttion,because the data source is DVB-S there is few error in the sattelite channle. Do you exactly know the wrong data ? whether you can drop the data,drop the audio and video data at the same time.
how do you process with the two video out put pin ?
|
|
|
|
|
|
I have no idea yet.
|
|
|
|
|
I resovled this problem.The sample number of output pin is not enough!
I increased the number from 100 to 4000,and the COutputQueue object's list cache from 10 to 1024*1024.Now everything runs well.
|
|
|
|
|
Question: In my Edit Control i want the users to input HEX Values (I know they dont except HEX values so I can only use them in a CString as Characters). They would input something like "AA BB". What i want to do is take those 2 values ("AA" being 1 value and "BB" being the other value) and put them into a UINT array. i am just not sure how to go about extracting characters from a string.
Anyone have any suggestions on how I could do this?
Thanks
|
|
|
|
|
CNewbie wrote:
am just not sure how to go about extracting characters from a string.
You can use the function
WCHAR <code>GetAt</code>(int nIndex)
"Success is the ability of going from one failure to another with no loss of enthusiasm" - W.Churchill
|
|
|
|