|
|
Hi,
I have created a TabControl in my VC++ project in VS2003 IDE. I would like to switch the tabs with the help of hotkeys (eg:Alt+A).
Suppose i have two tabs with the titles &General ,&About. So I am expecting Alt+G should switch General tab and Alt+A should switch to About tab. But that is not happening. Do i need to set some thing else?
Thanks in advance...
Birajendu
SonicWALL
Bangalore
India
|
|
|
|
|
Hi, I am developing a document/view program with MFC Ribbon Features, I want to disable the close button of some of DockablePanes so that the user could not close them. I use the following code But It didnot work what should I do?
CMenu* pm = m_wndObjectProperties.GetSystemMenu(FALSE);
if(pm!= NULL)
{
pm->DeleteMenu(1, MF_BYPOSITION);
pm->EnableMenuItem(SC_CLOSE, MF_BYCOMMAND | MF_DISABLED);
pm->DeleteMenu(SC_CLOSE, MF_BYCOMMAND);
}
|
|
|
|
|
hello guys....im new to this. I have a mic attached to my PC. Now following code should show appropriate message but it does't.
const int NUMPTS = 8000 * 10;
int sampleRate = 8000;
short int waveIn[NUMPTS];
HWAVEIN hWaveIn;
WAVEHDR WaveInHdr;
MMRESULT result = 0;
void CALLBACK waveInProc(HWAVEIN hwi,UINT msg, DWORD dwInstance, DWORD dwArg1, DWORD dwArg2) {
switch(msg) {
case WIM_OPEN:
MessageBox(NULL,"Device Opened Successfuly","Device Opened",NULL);
break;
case WIM_DATA:
MessageBox(NULL,"Data Recieving","data",NULL);
break;
case WIM_CLOSE:
MessageBox(NULL,"Device Closed Successfuly","Device Closed",NULL);
break;
default:
break;
}
}
void CwaveFileDlg::OnOpenDev()
{
CFile file;
CFileException cfe;
TCHAR* filename = "d:\\file.wav";
WAVEFORMATEX pFormat;
if (!file.Open(filename,CFile::modeCreate|CFile::modeReadWrite,&cfe))
MessageBox("File could't be opened","",cfe.m_cause);
result = waveInOpen(&hWaveIn,WAVE_MAPPER,&pFormat,(DWORD_PTR) waveInProc,(DWORD_PTR) this,(DWORD)WAVE_FORMAT_DIRECT);
}
what can be the reason??
|
|
|
|
|
I suggest you improve the observability by adding:
- a MessageBox showing the result of waveInOpen()
- a MessageBox showing the value of msg in your switch default.
Chances are that will tell you what is really going on.
|
|
|
|
|
1) I had a MessageBox for waveInOpen for both cases (true and false against MMSYSERR_NOERROR) but removed them for making it look less complicated. swicth default message can be added but only if goes in the switch (specifically....waveInProc), but there is an error b4 that. When I debug, it shows 32 against the MMRESULT variable (result).
|
|
|
|
|
if you have an error number or message, you should take it from there.
32 probably is WAVERR_BADFORMAT, so your data is bad.
|
|
|
|
|
well im new to this, and this is getting me little confused. I am not using any data, it is just the mic attached to PC (input device), so which data is bad??
|
|
|
|
|
The line I suspect most is:
WAVEFORMATEX pFormat;
Why would the values be correct (and why do you remove debug statements) while the lot isn't working yet?
I'm not familiar with all this, but from what I see, you either didn't read the documentation or made some mistake. You have two choices: locate the problem yourself, or accurately provide actual code and symptoms.
|
|
|
|
|
There is nothing to hide...following are the lines after the suspected line
pFormat.wFormatTag = WAVE_FORMAT_PCM;
pFormat.nChannels = 1;
pFormat.nSamplesPerSec = 8000;
pFormat.nAvgBytesPerSec = 16000;
pFormat.nBlockAlign = 1;
pFormat.wBitsPerSample = 16;
pFormat.cbSize = 0;
I wanna make it clear that it is logical error (that audio input device is't opening), not the syntax error (if I have made things complicated).
|
|
|
|
|
I don't think your values satisfy the documented requirements:
nBlockAlign (not OK)
Block alignment, in bytes. The block alignment is the minimum atomic unit of data for the wFormatTag format type. If wFormatTag is WAVE_FORMAT_PCM, nBlockAlign should be equal to the product of nChannels and wBitsPerSample divided by 8 (bits per byte).
nAvgBytesPerSec (OK)
Required average data-transfer rate, in bytes per second, for the format tag. If wFormatTag is WAVE_FORMAT_PCM, nAvgBytesPerSec should be equal to the product of nSamplesPerSec and nBlockAlign.
|
|
|
|
|
thanx....thanx alot. I hope I"ll b able to do something better now, while discussing this, I tried all the error options returned by waveInOpen and it was WAVERR_BADFORMAT. lets hope kim clijster wins the US Open once again...
|
|
|
|
|
My app crashed, I did find probrlm point.
to simplify code, I add a line inside crashed function for testing:
BYTE*pp=new BYTE[iSize];
iSize is an int,
if iSize is 1016, the line is OK.
if iSize is 1017, the line crashes, that is, the pointer can't be allocated, or pp is NULL.
My PC has 2G memory, so memory should be OK.
Do you know why?
virus? VC problem? Project settings?
|
|
|
|
|
maybe the statement is executed many times before it crashes your app, as memory is really running low?
you should show actual code to get effective help!
|
|
|
|
|
If that memory is not free'd then you have introduced a memory leak and as stated above me this could very well be the reason for the crash in that its running out of memory, but more code would help greatly.
|
|
|
|
|
includeh10 wrote: My PC has 2G memory, so memory should be OK.
Be aware that each executable file has an header that hold information about the heap commit size and heap reserve size (see /HEAP (Set Heap Size)[^]); the reserve size has the meaning of the maximum stack size that your executable can use, and its default is 1 MB.
If you are allocating more than 1 MB (both in a single shot or with multiple allocations), you can get a similar problem; it doesn't matter if your system is equipped with 2 GB.
|
|
|
|
|
Put the new inside a try/catch block which should give you some more information regarding the crash.
try
{
BYTE*pp=new BYTE[iSize];
}
catch (exception& e)
{
cout << e.what();
}
|
|
|
|
|
«_Superman_» wrote: try
{ BYTE*pp=new BYTE[iSize];}catch (exception& e){ cout << e.what();}
It one the correct way to resolve problem, but still there are some exception which can't be handlled by exception block too.
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow Never mind - my own stupidity is the source of every "problem" - Mixture
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
Support CRY- Child Relief and You
|
|
|
|
|
Seeing as the man said the pointer was sometimes 0 when it came back from new he's using an antique compiler which doesn't follow the standard (e.g. VC++6). Catching anything isn't going to help here.
Cheers,
Ash
|
|
|
|
|
It could be a symptom of another memory problem elsewhere. Enable memory testing and rerun your program.
It could also be (as someone else suggested) a memory leak being repeatedly executed. If so, this one is easy to fix: make the bb variable static and initially NULL. Then if it's not NULL, free it before assigning the new buffer to it.
|
|
|
|
|
In visual Studio, there is a shortcut for going to the function definition. Let me give an example
VOID ABC::abc() {
int result;
result = someFUNC();
}
Now if we press some shortcut key on someFUNC, it takes us to that function. What is that shorcut?? thanx
|
|
|
|
|
Place your mouse over the function and press Right-Click, the pop-up menu will show you the option. In VC++ Express Edition it is F12.
It's time for a new signature.
|
|
|
|
|
F12 will work not only on Express editions
|
|
|
|
|
By my knowledge, in order to make a class recognizable in another module of an application, I need to include it's header file or, at least, to use a forward declaration.
I'll ask my question using an example. Let's suppose I have an application named Test. In the CTestView class I have the function GetDocument() returning a pointer of CTestDoc* type. How doess the view class know about the CTestDoc* type if there is no "#include TestDoc.h" declaration in the CViewTest class ?
|
|
|
|
|
As you have mentioned, to use CTestDoc*, you will have to include TestDoc.h. If the CTestDoc* referenced only in the .CPP file, then check if the .CPP has included TestDoc.h
|
|
|
|