|
The typedef's are used to behave the UDT(User defined Data types) like inbuild data types
as well the code overheads are minimized and one can easily change the datatype through out the scope of the typedef
for e.g.
typedef std::map < short,_bstr_t >::iterator Iterator
here Iterator represent's std::map < short,_bstr_t >::iterator
Knock out 'T' from CAN'T ,
You 'CAN' if you think you 'CAN'
|
|
|
|
|
Hi thanks for the response. I have found the following code snippet from a website:
class CSimSerial
{
public:
virtual ~CSimSerial(){}
//some more virtual functions
};
typedef CSimSerial *(*GET_SIM_INTF_CREATOR)(void);
The typedef in here created an alias for the class and can be used to create objects. But what purpose would the double pointer and void serve?
-- modified at 8:07 Tuesday 16th May, 2006
|
|
|
|
|
If you use the rule I gave it's easy to figure out. First remove the typedef and see what it means:
CSimSerial* (*GET_SIM_INTF_CREATOR)(void);
Note that I've adjusted the formatting slightly. This would declare a variable called "GET_SIM_INTF_CREATOR" which is a pointer to a function which returns a "CSimSerial*" and takes no parameters.
So with the typedef on the front:
typedef CSimSerial* (*GET_SIM_INTF_CREATOR)(void);
This creates an alias called "GET_SIM_INTF_CREATOR" for a pointer to a function which returns a "CSimSerial*" and takes no parameters.
Steve
|
|
|
|
|
Hi,
I have developed the program that record a AVIs and the program that record sound to wav file,
Now I want to develop a other program to merge AVIs and wav file to avi with sound,
Have anybody know how to do this? Please help me!
The follow are some my code:
The separate module that record just avis (no sound) worked well
//Add Frame to avi file
bool CAVIUtil::AddFrame(HBITMAP hBitmap)
{
BITMAPINFO bmpInfo;
bmpInfo.bmiHeader.biBitCount = 0;
bmpInfo.bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
GetDIBits(m_hAviDC, hBitmap, 0, 0, NULL, &bmpInfo, DIB_RGB_COLORS);
bmpInfo.bmiHeader.biCompression = BI_RGB;
GetDIBits(m_hAviDC, hBitmap, 0, bmpInfo.bmiHeader.biHeight, m_lpBits, &bmpInfo, DIB_RGB_COLORS);
if (FAILED(AVIStreamWrite(m_pAviCompressedStream, m_lSample++, 1, m_lpBits, bmpInfo.bmiHeader.biSizeImage, 0, NULL, NULL)))
{
strcpy(m_szErrorMessage, "AppendFrameUsual(): AVIStreamWrite failed");
return (false);
}
return (true);
}
The record wav and record avi run with two other thread, when they finished I just add the follow code to add them togetther, but it can not play(seem to wrong format).
HRESULT CAVIUtil::AddAviWav(const char *src)
{
char *buf=0; WavChunk *wav = (WavChunk*)src;
HANDLE hf=CreateFile(src,GENERIC_READ,FILE_SHARE_READ,NULL,OPEN_EXISTING,0,NULL);
if (hf==INVALID_HANDLE_VALUE) {
MessageBox(NULL,"AVIERR_FILEOPEN","ERROR",MB_OK);
return AVIERR_FILEOPEN;
}
DWORD size = GetFileSize(hf,NULL);
buf = new char[size];
DWORD red; ReadFile(hf,buf,size,&red,NULL);
CloseHandle(hf);
wav = (WavChunk*)buf;
// check that format doesn't clash
bool badformat=false;
if (m_wfx.nChannels==0)
{ m_wfx.wFormatTag=wav->fmt.wFormatTag;
m_wfx.cbSize=0;
m_wfx.nAvgBytesPerSec=wav->fmt.dwAvgBytesPerSec;
m_wfx.nBlockAlign=wav->fmt.wBlockAlign;
m_wfx.nChannels=wav->fmt.wChannels;
m_wfx.nSamplesPerSec=wav->fmt.dwSamplesPerSec;
m_wfx.wBitsPerSample=wav->fmt.wBitsPerSample;
}
else
{
if (m_wfx.wFormatTag!=wav->fmt.wFormatTag) badformat=true;
if (m_wfx.nAvgBytesPerSec!=wav->fmt.dwAvgBytesPerSec) badformat=true;
if (m_wfx.nBlockAlign!=wav->fmt.wBlockAlign) badformat=true;
if (m_wfx.nChannels!=wav->fmt.wChannels) badformat=true;
if (m_wfx.nSamplesPerSec!=wav->fmt.dwSamplesPerSec) badformat=true;
if (m_wfx.wBitsPerSample!=wav->fmt.wBitsPerSample) badformat=true;
}
if (badformat) {if (buf!=0) delete[] buf;
MessageBox(NULL,"AVIERR_BADFORMAT","ERROR",MB_OK);
return AVIERR_BADFORMAT;
}
//
// create the stream if necessary
if(m_pAudioStream==0){
AVISTREAMINFO ahdr; ZeroMemory(&ahdr,sizeof(ahdr));
ahdr.fccType=streamtypeAUDIO;
ahdr.dwScale=m_wfx.nBlockAlign;
ahdr.dwRate=m_wfx.nSamplesPerSec*m_wfx.nBlockAlign;
ahdr.dwSampleSize=m_wfx.nBlockAlign;
ahdr.dwQuality=(DWORD)-1;
HRESULT hr = AVIFileCreateStream(m_pAviFile,&m_pAudioStream, &ahdr);
if (hr!=AVIERR_OK) {if (buf!=0) delete[] buf; return hr;}
hr = AVIStreamSetFormat(m_pAudioStream,0,&m_wfx,sizeof(WAVEFORMATEX));
if (hr!=AVIERR_OK) {if (buf!=0) delete[] buf;return hr;}
}
// now we can write the data
unsigned long numbytes = wav->dat.size;
unsigned long numsamps = numbytes*8 / m_wfx.wBitsPerSample;
HRESULT hr = AVIStreamWrite(m_pAudioStream,m_lSample,numsamps,wav->dat.data,numbytes,0,NULL,NULL);
if (buf!=0) delete[] buf;
if (hr!=AVIERR_OK) {
MessageBox(NULL,"AVIERR_OK","ERROR",MB_OK);
return hr;
}
m_lSample+=numsamps;
MessageBox(NULL,"AVIS_OK","S_OK",MB_OK);
return S_OK;
}
Please help me soon if you can
Thank in advance
|
|
|
|
|
I m using ATL Service to start another Application, problem is that Application is executed but its Window not appears. If I use another application to start this application then it working properly. Plz, tell me if anyone knows this problem
STARTUPINFO siStartupInfo;
PROCESS_INFORMATION piProcessInfo;
memset(&siStartupInfo, 0, sizeof(siStartupInfo));
memset(&piProcessInfo, 0, sizeof(piProcessInfo));
siStartupInfo.cb = sizeof(siStartupInfo);
CreateProcess
(L"D:\\TestingApplication\\DialogTest\\Debug\\DialogTest.exe",0,0,0,false, CREATE_DEFAULT_ERROR_MODE,0,0,&siStartupInfo,&piProcessInfo);
Musharraf Hussain
|
|
|
|
|
Hi ppl,
I am writing a simple TCP chat app in MFC c++ (dialog based), using two threads - one for listening and acceping and another one is for receiving and sending. The problem actualy occurs when I close (click on OK or Cancel) while some thread is running. I get an assert or/and unhandled exception pointing to a my code or some code inside dbgheap.c (Ln 1974: if (_BLOCK_TYPE(pHead->nBlockUse) >= 0 && _BLOCK_TYPE(pHead->nBlockUse) < _MAX_BLOCKS) )
I suspect something about threads that are still running, though I tried to end them with TerminateThread and ExitThread. Please help.
|
|
|
|
|
Don't use TerminateThread or ExitThread to stop your thread. Instead, use a flag to signal that the thread should stop:
while (bThreadActive)
{
}
Then, when you want to stop this thread (through your main thread), set this variable to false and wait[^] for the thread to finish.
Cédric Moonen
Software developer
Charting control
|
|
|
|
|
A helluva idea... I'll try that one, 10x
|
|
|
|
|
I am facing problem during remote debugging. If i start the process from host machine ( the one having Visual Studio) by pressing F5, i can debug the process successfully. But if some other application is going to start my process on remote machine and i want to debug the same process then how do i do it? Can somehow debugger window started on host machine when the process is running on remote machine and some error occurs on remote machine? Plz reply as soon as possible.
|
|
|
|
|
How to calculate the memory size of HBITMAP after loading it.As the size of Bitmap depends upon the system settings(Pexels, color etc.)
-- modified at 4:37 Tuesday 16th May, 2006
|
|
|
|
|
Can you be more specific
WhiteSky
|
|
|
|
|
Hi,
Use GetObject API
The GetObject function retrieves information for the specified graphics object.
int GetObject(
HGDIOBJ hgdiobj, // handle to graphics object
int cbBuffer, // size of buffer for object information
LPVOID lpvObject // buffer for object information
);
|
|
|
|
|
try this one.
CBitmap bitmap;
bitmap.LoadBitmap(IDB_BITMAP1);
BITMAP bm;
bitmap.GetBitmap( &bm );
bmWidth = bm.bmWidth;
bmHeight = bm.bmHeight;
this will work.
-Sarath
|
|
|
|
|
Use:
HBITMAP hBitmap = LoadBitmap(...);
BITMAP bmp;
GetObject(hBitmap, sizeof(bmp), &bmp);
int nWidth = bmp.bmWidth;
int nHeight = bmp.bmHeight;
"The largest fire starts but with the smallest spark." - David Crow
|
|
|
|
|
Hi guys,
I have been teaching myself c++/mfc, and I was wondering if there is a way to read and write to a file at the same time?
Like read the file first and if it encounters this text, replace that text with a new text (so write to the file)?
I observed that we can only read to a file first, close it, then write to it, or vice versa. But is there a way to do both? I did not want to use fseek() since my number of bytes per line are not fixed.
I'd appreciate all the help I can get. And if I got a concept wrong, please do correct me.
Thanks a lot!
The Buggy
|
|
|
|
|
waxie wrote: we can only read to a file first, close it, then write to it,
Who said this ?
we can both, read and write to a file at the same ..For this u must open the file in read-write mode..
nave
|
|
|
|
|
Really? can you give me a snippet of the working code please?
Thanks!
TheBuggy
|
|
|
|
|
if ur using CFile in MFC open the file as follows..
CFile File;
File.Open( _T("C:\\out.txt"),CFile::modeReadWrite );
Now u can use both Read and Write function CFile..
nave
|
|
|
|
|
I wonder... why doesn't this code work?
CString csCurrLine;
while(oFile.ReadString(csCurrLine))
{
if(csCurrLine==_T("String"))
{
oFile.WriteString(_T("Overwrite String"));
break;
}
}
oItemListFile.Close();
TheBuggy
|
|
|
|
|
First:
Beacuse the file pointer is placed on the character after "String" in the file, so that's where you will be writing "Overwrite String"
You will have to position the file pointer to the beginning of "String" before writing to the file.
Second:
Since "Overwrite String" is longer than "String", if the file pointer was placed at the beginning of "String", the "String " would be overwritten, *but* also the 10 characters after "String" in the file.
Pls read my post.
|
|
|
|
|
Yeah, OK, say the pointer is really not in the right position.
But why doesn't my 'overwriting' string appear in any parts of the text file? Am I correct to assume that it should appear? Say, on the next line?
Thanks so much for all your replies.
|
|
|
|
|
If you did open the file for reading and writing (see Naveen's post), then it should be writtened to the file, immediately after "String".
-- modified at 4:51 Tuesday 16th May, 2006
That is, provided the expression
if(csCurrLine==_T("String")) evaluates to a value != 0
|
|
|
|
|
Honestly, it really does not work. My new string does not appear anywhere in the file - or as expected, after the old string.
|
|
|
|
|
OK, I beleive you!
I can think of two things:
First:
Does the expression
if(csCurrLine==_T("String")) evaluate to a value != 0
That is, does your program find "String" in your present file?
Second:
Do you check the return code of the write-statement?
|
|
|
|
|
Yes, the program finds the evaluated string. I'm sure with that.
And yes, it can write coz i tried writing to a file without reading and it does write. WriteString doesn't have a return value - it returns void.
|
|
|
|
|